mirror of
https://github.com/flancian/garden.git
synced 2026-08-08 07:26:21 +00:00
Go back to humble cachetools.func
This commit is contained in:
+14
-1
@@ -25,10 +25,11 @@ from flask_cors import CORS
|
|||||||
cache = Cache()
|
cache = Cache()
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
filename='agora.log',
|
filename='agora.log',
|
||||||
level=logging.WARNING,
|
level=logging.DEBUG,
|
||||||
format='%(asctime)s %(levelname)s %(name)s %(threadName)s : %(message)s'
|
format='%(asctime)s %(levelname)s %(name)s %(threadName)s : %(message)s'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# what is this doing here, I have no idea.
|
# what is this doing here, I have no idea.
|
||||||
# todo: move to util.
|
# todo: move to util.
|
||||||
def wikilink_to_url(label, base, end):
|
def wikilink_to_url(label, base, end):
|
||||||
@@ -89,4 +90,16 @@ def create_app(test_config=None):
|
|||||||
output = s
|
output = s
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@app.before_request
|
||||||
|
def log_entry():
|
||||||
|
app.logger.debug('Initiating request handling.')
|
||||||
|
|
||||||
|
@app.after_request
|
||||||
|
def log_exit(req):
|
||||||
|
app.logger.debug(f'Finished handling {req}.')
|
||||||
|
return req
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ def jump():
|
|||||||
@bp.route('/node/<node>')
|
@bp.route('/node/<node>')
|
||||||
@bp.route('/node/<node>/uprank/<user_list>')
|
@bp.route('/node/<node>/uprank/<user_list>')
|
||||||
def node(node,user_list=[]):
|
def node(node,user_list=[]):
|
||||||
|
# current_app.logger.debug(f'Assembling node {node}.')
|
||||||
if user_list:
|
if user_list:
|
||||||
rank = user_list.split(",")
|
rank = user_list.split(",")
|
||||||
else:
|
else:
|
||||||
@@ -175,6 +176,7 @@ def node(node,user_list=[]):
|
|||||||
|
|
||||||
search_subnodes = db.search_subnodes(node)
|
search_subnodes = db.search_subnodes(node)
|
||||||
|
|
||||||
|
# current_app.logger.debug(f'Assembled node {node}.')
|
||||||
return render_template(
|
return render_template(
|
||||||
# yuck
|
# yuck
|
||||||
'content.html',
|
'content.html',
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import cachetools.func
|
||||||
import glob
|
import glob
|
||||||
import itertools
|
import itertools
|
||||||
import re
|
import re
|
||||||
@@ -80,7 +81,8 @@ class Graph:
|
|||||||
nodes = [node for node in G.nodes() if node.wikilink in permutations and node.subnodes]
|
nodes = [node for node in G.nodes() if node.wikilink in permutations and node.subnodes]
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
@cache.memoize(timeout=30)
|
# @cache.memoize(timeout=30)
|
||||||
|
@cachetools.func.ttl_cache(ttl=20)
|
||||||
def nodes(self, include_journals=True):
|
def nodes(self, include_journals=True):
|
||||||
current_app.logger.debug('Loading graph.')
|
current_app.logger.debug('Loading graph.')
|
||||||
# returns a list of all nodes
|
# returns a list of all nodes
|
||||||
@@ -122,6 +124,7 @@ class Graph:
|
|||||||
|
|
||||||
# does this belong here?
|
# does this belong here?
|
||||||
# @cache.memoize(timeout=30)
|
# @cache.memoize(timeout=30)
|
||||||
|
@cachetools.func.ttl_cache(ttl=30)
|
||||||
def subnodes(self, sort=lambda x: x.uri.lower()):
|
def subnodes(self, sort=lambda x: x.uri.lower()):
|
||||||
# Markdown.
|
# Markdown.
|
||||||
subnodes = [Subnode(f) for f in glob.glob(os.path.join(config.AGORA_PATH, '**/*.md'), recursive=True)]
|
subnodes = [Subnode(f) for f in glob.glob(os.path.join(config.AGORA_PATH, '**/*.md'), recursive=True)]
|
||||||
|
|||||||
Reference in New Issue
Block a user