check posts
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simple_Not 2023-07-14 01:32:56 +10:00
parent 10b0643899
commit 1d5369d73a

8
app.py
View File

@ -63,7 +63,7 @@ def page_posts_from_db():
postos = db.collection('posts') postos = db.collection('posts')
postos = [ p for p in postos] postos = [ p for p in postos]
postos = sorted(postos, key=lambda posto: posto['_key'], reverse=False) postos = sorted(postos, key=lambda posto: posto['_key'], reverse=False)
return render_template("interactive-posts.html", postos=postos) return render_template("interactive-posts.html", postos=postos)
@ -85,6 +85,12 @@ def post_a_post(post_key):
'_to': f'posts/{metadata["_key"]}' '_to': f'posts/{metadata["_key"]}'
}, overwrite_mode='update') }, 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 = db.collection('posts')
postos = sorted(postos, key=lambda posto: posto['_key'], reverse=False) postos = sorted(postos, key=lambda posto: posto['_key'], reverse=False)