From 04a3e3922a63acbeac121d341685614715c8f093 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 11 Aug 2023 16:07:24 +0300 Subject: [PATCH] make blocks faster and order it by most recent --- files/routes/static.py | 12 ++---------- files/templates/blocks.html | 16 +++++++++++----- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/files/routes/static.py b/files/routes/static.py index f22ca7db6..fb43b4d46 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -341,17 +341,9 @@ def badges(v): @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) @admin_level_required(PERMS['USER_BLOCKS_VISIBLE']) def blocks(v): - blocks=g.db.query(UserBlock).all() - users = [] - targets = [] - for x in blocks: - acc_user = get_account(x.user_id) - acc_tgt = get_account(x.target_id) - if acc_user.shadowbanned or acc_tgt.shadowbanned: continue - users.append(acc_user) - targets.append(acc_tgt) + blocks = g.db.query(UserBlock).order_by(UserBlock.created_utc.desc()).all() - return render_template("blocks.html", v=v, users=users, targets=targets) + return render_template("blocks.html", v=v, blocks=blocks) @app.get("/formatting") @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) diff --git a/files/templates/blocks.html b/files/templates/blocks.html index eefc1c8b2..7c7cb1d99 100644 --- a/files/templates/blocks.html +++ b/files/templates/blocks.html @@ -5,16 +5,22 @@
- -{% for user in users %} +{% for block in blocks %} - - - + + {% endfor %}
# User Target
{{loop.index}}{{user.user_name}}{{targets[loop.index-1].user_name}} + {% with user = block.user %} + {% include "user_in_table.html" %} + {% endwith %} + + {% with user = block.target %} + {% include "user_in_table.html" %} + {% endwith %} +