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)