Add agora.log.

This commit is contained in:
2021-03-07 18:45:55 +01:00
parent 4d668e1ef9
commit 43f27a4643
3 changed files with 11 additions and 0 deletions
+1
View File
@@ -4,3 +4,4 @@
__pycache__ __pycache__
venv venv
tags tags
agora.log
+7
View File
@@ -13,6 +13,7 @@
# limitations under the License. # limitations under the License.
import datetime import datetime
import logging
import jsons import jsons
from flask import Blueprint, url_for, render_template, current_app, Response, redirect, request, jsonify from flask import Blueprint, url_for, render_template, current_app, Response, redirect, request, jsonify
from markupsafe import escape from markupsafe import escape
@@ -26,6 +27,12 @@ from . import util
bp = Blueprint('agora', __name__) bp = Blueprint('agora', __name__)
G = db.G G = db.G
logging.basicConfig(
filename='agora.log',
level=logging.DEBUG,
format='%(asctime)s %(levelname)s %(name)s %(threadName)s : %(message)s'
)
# Special # Special
@bp.route('/index') @bp.route('/index')
@bp.route('/') @bp.route('/')
+3
View File
@@ -17,6 +17,7 @@ import glob
import itertools import itertools
import re import re
import os import os
from flask import current_app
from . import config from . import config
from . import feed from . import feed
from . import render from . import render
@@ -81,6 +82,7 @@ class Graph:
@cachetools.func.ttl_cache(maxsize=2, ttl=20) @cachetools.func.ttl_cache(maxsize=2, ttl=20)
def nodes(self, include_journals=True): def nodes(self, include_journals=True):
current_app.logger.debug('Loading graph.')
# returns a list of all nodes # returns a list of all nodes
# first we fetch all subnodes, put them in a dict {wikilink -> [subnode]}. # first we fetch all subnodes, put them in a dict {wikilink -> [subnode]}.
@@ -101,6 +103,7 @@ class Graph:
if not include_journals: if not include_journals:
nodes = [node for node in nodes if not util.is_journal(node.wikilink)] nodes = [node for node in nodes if not util.is_journal(node.wikilink)]
current_app.logger.debug('Graph loaded.')
# TODO: experiment with other ranking. # TODO: experiment with other ranking.
# return sorted(nodes, key=lambda x: -x.size()) # return sorted(nodes, key=lambda x: -x.size())
return sorted(nodes, key=lambda x: x.wikilink.lower()) return sorted(nodes, key=lambda x: x.wikilink.lower())