mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Merge branch 'master' into live
This commit is contained in:
commit
e33f115d44
2 changed files with 8 additions and 11 deletions
|
@ -222,14 +222,9 @@ class PackageSearch:
|
||||||
ordering = self.FULL_SORT_ORDER.get(ordering)
|
ordering = self.FULL_SORT_ORDER.get(ordering)
|
||||||
return callback(ordering)
|
return callback(ordering)
|
||||||
|
|
||||||
def count(self, limit: int) -> int:
|
def count(self) -> int:
|
||||||
"""
|
""" Return internal query's count. """
|
||||||
Return internal query's count up to `limit`.
|
return self.query.count()
|
||||||
|
|
||||||
:param limit: Upper bound
|
|
||||||
:return: Database count up to `limit`
|
|
||||||
"""
|
|
||||||
return self.query.limit(limit).count()
|
|
||||||
|
|
||||||
def results(self) -> orm.Query:
|
def results(self) -> orm.Query:
|
||||||
""" Return internal query. """
|
""" Return internal query. """
|
||||||
|
|
|
@ -31,7 +31,10 @@ async def packages_get(request: Request, context: Dict[str, Any],
|
||||||
request.query_params.get("O", defaults.O),
|
request.query_params.get("O", defaults.O),
|
||||||
request.query_params.get("PP", defaults.PP))
|
request.query_params.get("PP", defaults.PP))
|
||||||
context["O"] = offset
|
context["O"] = offset
|
||||||
context["PP"] = per_page
|
|
||||||
|
# Limit PP to options.max_search_results
|
||||||
|
max_search_results = aurweb.config.getint("options", "max_search_results")
|
||||||
|
context["PP"] = per_page = min(per_page, max_search_results)
|
||||||
|
|
||||||
# Query search by.
|
# Query search by.
|
||||||
search_by = context["SeB"] = request.query_params.get("SeB", "nd")
|
search_by = context["SeB"] = request.query_params.get("SeB", "nd")
|
||||||
|
@ -56,8 +59,7 @@ async def packages_get(request: Request, context: Dict[str, Any],
|
||||||
# Collect search result count here; we've applied our keywords.
|
# Collect search result count here; we've applied our keywords.
|
||||||
# Including more query operations below, like ordering, will
|
# Including more query operations below, like ordering, will
|
||||||
# increase the amount of time required to collect a count.
|
# increase the amount of time required to collect a count.
|
||||||
limit = config.getint("options", "max_search_results")
|
num_packages = search.count()
|
||||||
num_packages = search.count(limit)
|
|
||||||
|
|
||||||
flagged = request.query_params.get("outdated", None)
|
flagged = request.query_params.get("outdated", None)
|
||||||
if flagged:
|
if flagged:
|
||||||
|
|
Loading…
Add table
Reference in a new issue