From 1d5369d73ab69f408f84f7d6929761a9f51dcb0c Mon Sep 17 00:00:00 2001 From: Simple_Not <44047940+moonbaseDelta@users.noreply.github.com> Date: Fri, 14 Jul 2023 01:32:56 +1000 Subject: [PATCH] check posts --- app.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index ff4e338..a7945e3 100644 --- a/app.py +++ b/app.py @@ -63,7 +63,7 @@ def page_posts_from_db(): postos = db.collection('posts') postos = [ p for p in postos] postos = sorted(postos, key=lambda posto: posto['_key'], reverse=False) - + return render_template("interactive-posts.html", postos=postos) @@ -85,6 +85,12 @@ def post_a_post(post_key): '_to': f'posts/{metadata["_key"]}' }, overwrite_mode='update') + + cursor = db.aql.execute( + """FOR ppp IN posts + LET children = (FOR v IN 1..9999 OUTBOUND ppp post_parents RETURN v) + UPDATE ppp WITH { children_num : COUNT_DISTINCT( children[*]._key ) } IN posts""" + ) postos = db.collection('posts') postos = sorted(postos, key=lambda posto: posto['_key'], reverse=False)