From 6c6ecd39712a8c26a54e0394acb467b9df5f37a7 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 16 Aug 2024 21:32:22 +0200 Subject: [PATCH] perf(aurweb): create a context with what is required The pkgbase/util.py `make_context` helper does a lot of unrelated expensive queries which are not required for any of the templates. Only the 404 template shows git_clone_uri_* and pkgbase. --- aurweb/asgi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aurweb/asgi.py b/aurweb/asgi.py index 3f60dabf..4fb62bac 100644 --- a/aurweb/asgi.py +++ b/aurweb/asgi.py @@ -22,7 +22,6 @@ from starlette.middleware.sessions import SessionMiddleware import aurweb.captcha # noqa: F401 import aurweb.config import aurweb.filters # noqa: F401 -import aurweb.pkgbase.util as pkgbaseutil from aurweb import aur_logging, prometheus, util from aurweb.aur_redis import redis_connection from aurweb.auth import BasicAuthBackend @@ -215,7 +214,9 @@ async def http_exception_handler(request: Request, exc: HTTPException) -> Respon if matches and len(tokens) == 2: try: pkgbase = get_pkg_or_base(matches.group(1)) - context = pkgbaseutil.make_context(request, pkgbase) + context["pkgbase"] = pkgbase + context["git_clone_uri_anon"] = aurweb.config.get("options", "git_clone_uri_anon") + context["git_clone_uri_priv"] = aurweb.config.get("options", "git_clone_uri_priv") except HTTPException: pass