From dcaf407536993cce9ae37482d3fbb9c699477a4b Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Thu, 17 Feb 2022 17:42:24 -0800 Subject: [PATCH] fix: /packages search result count We need to query for this after we've applied all filters. Signed-off-by: Kevin Morris --- aurweb/routers/packages.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aurweb/routers/packages.py b/aurweb/routers/packages.py index 34c09d86..bc12455d 100644 --- a/aurweb/routers/packages.py +++ b/aurweb/routers/packages.py @@ -61,11 +61,6 @@ async def packages_get(request: Request, context: Dict[str, Any], for keyword in keywords: search.search_by(search_by, keyword) - # Collect search result count here; we've applied our keywords. - # Including more query operations below, like ordering, will - # increase the amount of time required to collect a count. - num_packages = search.count() - flagged = request.query_params.get("outdated", None) if flagged: # If outdated was given, set it up in the context. @@ -90,7 +85,12 @@ async def packages_get(request: Request, context: Dict[str, Any], search.query = search.query.filter( models.PackageBase.MaintainerUID.is_(None)) - # Apply user-specified specified sort column and ordering. + # Collect search result count here; we've applied our keywords. + # Including more query operations below, like ordering, will + # increase the amount of time required to collect a count. + num_packages = search.count() + + # Apply user-specified sort column and ordering. search.sort_by(sort_by, sort_order) # Insert search results into the context.