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.
This commit is contained in:
Jelle van der Waa 2024-08-16 21:32:22 +02:00
parent 9b12eaf2b9
commit 6c6ecd3971
No known key found for this signature in database
GPG key ID: C06086337C50773E

View file

@ -22,7 +22,6 @@ from starlette.middleware.sessions import SessionMiddleware
import aurweb.captcha # noqa: F401 import aurweb.captcha # noqa: F401
import aurweb.config import aurweb.config
import aurweb.filters # noqa: F401 import aurweb.filters # noqa: F401
import aurweb.pkgbase.util as pkgbaseutil
from aurweb import aur_logging, prometheus, util from aurweb import aur_logging, prometheus, util
from aurweb.aur_redis import redis_connection from aurweb.aur_redis import redis_connection
from aurweb.auth import BasicAuthBackend 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: if matches and len(tokens) == 2:
try: try:
pkgbase = get_pkg_or_base(matches.group(1)) 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: except HTTPException:
pass pass