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