From f1856a6ec245820c7585fc9935dd11d686d188d3 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 7 Jul 2023 23:40:16 +0300 Subject: [PATCH] only call calc_users when its necessary --- files/routes/front.py | 4 +++- files/routes/jinja2.py | 3 ++- files/routes/posts.py | 4 +++- files/routes/wrappers.py | 2 -- files/templates/header.html | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index 0c59152b1..acbbae997 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -50,7 +50,9 @@ def front_all(v, sub=None): if not v: result = cache.get(f'frontpage_{sort}_{t}_{page}_{sub}_{pins}') - if result: return result + if result: + calc_users() + return result ids, total, size = frontlist(sort=sort, page=page, diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index 85f772dc5..ac7705a7a 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -11,6 +11,7 @@ from files.helpers.config.const import * from files.helpers.regex import * from files.helpers.settings import * from files.helpers.cloudflare import * +from files.helpers.wrappers import calc_users from files.helpers.sorting_and_time import make_age_string from files.routes.routehelpers import get_alt_graph, get_formkey from files.__main__ import app, cache @@ -121,5 +122,5 @@ def inject_constants(): "BIO_FRIENDS_ENEMIES_LENGTH_LIMIT":BIO_FRIENDS_ENEMIES_LENGTH_LIMIT, "IMMUNE_TO_AWARDS": IMMUNE_TO_AWARDS, "SITE_FULL_IMAGES": SITE_FULL_IMAGES, "IS_FISTMAS":IS_FISTMAS, "IS_HOMOWEEN":IS_HOMOWEEN, "IS_DKD":IS_DKD, "IS_EVENT":IS_EVENT, "IS_BIRTHGAY":IS_BIRTHGAY, - "CHUD_PHRASES":CHUD_PHRASES, "hasattr":hasattr, + "CHUD_PHRASES":CHUD_PHRASES, "hasattr":hasattr, "calc_users":calc_users, } diff --git a/files/routes/posts.py b/files/routes/posts.py index 9c6aed3c7..1dda648b2 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -103,7 +103,9 @@ def post_id(pid, anything=None, v=None, sub=None): if not v: result = cache.get(f'post_{p.id}_{sort}') - if result: return result + if result: + calc_users() + return result if v: execute_shadowban_viewers_and_voters(v, p) diff --git a/files/routes/wrappers.py b/files/routes/wrappers.py index 9bc89893e..ba1af9f3a 100644 --- a/files/routes/wrappers.py +++ b/files/routes/wrappers.py @@ -119,8 +119,6 @@ def get_logged_in_user(): g.is_api_or_xhr = bool((v and v.client) or request.headers.get("xhr")) - calc_users() - return v def auth_desired(f): diff --git a/files/templates/header.html b/files/templates/header.html index 25e03d6df..9e0678acb 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -5,6 +5,7 @@