fix: reduce the number of subqueries against User by loading eagerly the Users from PackageComaintainer

This commit is contained in:
Muflone 2024-08-20 17:54:56 +02:00 committed by Fabio Castelli
parent 4f68532ee2
commit a40283cdb2

View file

@ -2,6 +2,7 @@ from typing import Any
from fastapi import Request
from sqlalchemy import and_
from sqlalchemy.orm import joinedload
from aurweb import config, db, defaults, l10n, time, util
from aurweb.models import PackageBase, User
@ -40,7 +41,7 @@ def make_context(
context["pkgbase"] = pkgbase
context["comaintainers"] = [
c.User
for c in pkgbase.comaintainers.order_by(
for c in pkgbase.comaintainers.options(joinedload(PackageComaintainer.User)).order_by(
PackageComaintainer.Priority.asc()
).all()
]