Skip to content
Snippets Groups Projects
Commit edc1ab94 authored by Jelle van der Waa's avatar Jelle van der Waa :construction: Committed by Leonidas Spyropoulos
Browse files

perf(captcha): simplify count() query for user ids

Using .count() isn't great as it runs a count query on a subquery which
selects all fields in the Users table. This rewrites it into a simple
SELECT count(ID) from USers query.
parent 97cc6196
No related branches found
No related tags found
1 merge request!823perf(captcha): simplify count() query for user ids
Pipeline #107069 passed
......@@ -3,6 +3,7 @@
import hashlib
from jinja2 import pass_context
from sqlalchemy import func
from aurweb.db import query
from aurweb.models import User
......@@ -11,7 +12,8 @@ from aurweb.templates import register_filter
def get_captcha_salts():
"""Produce salts based on the current user count."""
count = query(User).count()
count = query(func.count(User.ID)).scalar()
salts = []
for i in range(0, 6):
salts.append(f"aurweb-{count - i}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment