From aa6985279f71297aeff4c0fd785ef0aa4e5d4050 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 11 Jan 2022 22:42:35 +0200 Subject: [PATCH] bb --- files/helpers/const.py | 15 ++------------- files/helpers/jinja2.py | 6 +++--- files/routes/users.py | 17 +++++++++++++++-- files/templates/leaderboard.html | 2 +- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index ca38bb48d..cee69275a 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -1,4 +1,4 @@ -from os import environ, listdir +from os import environ import re from copy import deepcopy from json import loads @@ -21,15 +21,6 @@ del result marseys = dict(sorted(marseys.items(), key=lambda x: x[1])) -if SITE == 'rdrama.net': - topmakers = {} - for k, val in marseys.items(): - if val in topmakers: topmakers[val] += 1 - else: topmakers[val] = 1 - - topmakers.pop('unknown') - topmakers = sorted(topmakers.items(), key=lambda x: x[1], reverse=True)[:25] - AJ_REPLACEMENTS = { ' your ': " you're ", ' to ': " too ", @@ -775,6 +766,4 @@ NOTIFIED_USERS = { 'dong': DONGER_ID, 'dong': FARTBINN_ID, 'kippy': KIPPY_ID, -} - -num_banners = len(listdir('files/assets/images/Drama/banners')) + 1 +} \ No newline at end of file diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index 0ee962549..5276ae439 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -1,7 +1,8 @@ from files.__main__ import app from .get import * -from files.helpers import const +from os import listdir, environ +num_banners = len(listdir('files/assets/images/Drama/banners')) + 1 @app.template_filter("full_link") def full_link(url): @@ -26,5 +27,4 @@ def post_embed(id, v): @app.context_processor def inject_constants(): - constants = [c for c in dir(const) if not c.startswith("_")] - return {c:getattr(const, c) for c in constants} \ No newline at end of file + return {"num_banners":num_banners, "environ":environ} \ No newline at end of file diff --git a/files/routes/users.py b/files/routes/users.py index c4ac30be6..5a880bba1 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -8,7 +8,7 @@ from files.helpers.sanitize import * from files.helpers.const import * from files.mail import * from flask import * -from files.__main__ import app, limiter +from files.__main__ import app, limiter, db_session from pusher_push_notifications import PushNotifications from collections import Counter @@ -16,7 +16,20 @@ site = environ.get("DOMAIN").strip() beams_client = PushNotifications(instance_id=PUSHER_INSTANCE_ID, secret_key=PUSHER_KEY) +if True: + topmakers = {} + for k, val in marseys.items(): + if val in topmakers: topmakers[val] += 1 + else: topmakers[val] = 1 + topmakers.pop('unknown','anton-d') + db = db_session() + topmakers2 = db.query(User).filter(func.lower(User.username).in_(topmakers.keys())).all() + topmakers3 = [] + for user in topmakers2: + topmakers3.append((user, topmakers[user.username.lower()])) + topmakers = sorted(topmakers3, key=lambda x: x[1], reverse=True)[:25] + db.close() @app.get("/grassed") @auth_desired @@ -317,7 +330,7 @@ def leaderboard(v): for user in users11: users12.append((user, badges[user.id])) users12 = sorted(users12, key=lambda x: x[1], reverse=True)[:25] - if request.host == 'rdrama.net': users13 = topmakers + if True: users13 = topmakers else: users13 = None votes1 = g.db.query(Vote.user_id, func.count(Vote.user_id)).filter(Vote.vote_type==1).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all() diff --git a/files/templates/leaderboard.html b/files/templates/leaderboard.html index 970738173..c642cb651 100644 --- a/files/templates/leaderboard.html +++ b/files/templates/leaderboard.html @@ -296,7 +296,7 @@ {% for user in users13 %} {{loop.index}} - {% if user[0]=='anton-d' %}{{user[0]}}{% else %}@{{user[0]}}'s profile picture{{user[0]}}{% endif %} + @{{user[0].username}}'s profile picture{{user[0].username}} {{user[1]}} {% endfor %}