mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
perf(aurweb/pkgbase): use exists() to avoid fetching a row
The previous approach fetched the matching row, by using `exists()` SQLAlchemy changes the query to a `SELECT 1`.
This commit is contained in:
parent
b65d6c5e3a
commit
d1a66a743e
1 changed files with 4 additions and 2 deletions
|
@ -73,8 +73,10 @@ def make_context(
|
|||
context["out_of_date"] = bool(pkgbase.OutOfDateTS)
|
||||
|
||||
if is_authenticated:
|
||||
context["voted"] = request.user.package_votes.filter(
|
||||
PackageVote.PackageBaseID == pkgbase.ID
|
||||
context["voted"] = db.query(
|
||||
request.user.package_votes.filter(
|
||||
PackageVote.PackageBaseID == pkgbase.ID
|
||||
).exists()
|
||||
).scalar()
|
||||
else:
|
||||
context["voted"] = False
|
||||
|
|
Loading…
Add table
Reference in a new issue