From e7fee4999e53199069fb2238261d8e085e8db050 Mon Sep 17 00:00:00 2001 From: Simple_Not <44047940+moonbaseDelta@users.noreply.github.com> Date: Wed, 19 Jul 2023 00:14:13 +1000 Subject: [PATCH] check many hexes --- app.py | 37 ++++++++++++++++++++++++++++++++ templates/interactive-posts.html | 25 ++++++++------------- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/app.py b/app.py index 403739a..d16f393 100644 --- a/app.py +++ b/app.py @@ -102,6 +102,43 @@ def post_a_post(post_key): return render_template("i-posts.html", host_id=docker_short_id, postos=postos) + +@app.route('/post_to_another_post/', methods=['POST']) +def post_a_post(post_key): + + + postos = db.collection('posts') + + data = request.form['send_this_text'] + + metadata = postos.insert({ + 'texto': data, + 'parent_post': f'{post_key}' + }, overwrite_mode='update') + + metadata = db.collection('post_parents').insert({ + '_from': f'posts/{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""" + ) + cursor = db.aql.execute( + """FOR ppp IN posts + LET children = (FOR v IN 1OUTBOUND ppp post_parents RETURN v) + UPDATE ppp WITH { answers_num : COUNT_DISTINCT( children[*]._key ) } IN posts""" + ) + + postos = db.collection('posts') + postos = sorted(postos, key=lambda posto: posto['_key'], reverse=False) + + return render_template("i-posts.html", host_id=docker_short_id, postos=postos) + + # @app.route('/post_my_file', method=['POST']) # def post_a_file(): # pass diff --git a/templates/interactive-posts.html b/templates/interactive-posts.html index 2c84068..ad5832f 100644 --- a/templates/interactive-posts.html +++ b/templates/interactive-posts.html @@ -18,24 +18,17 @@ -
- -
-