Skip to content

Commit

Permalink
fix: fix sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Sep 22, 2023
1 parent ea25d36 commit 313ea26
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def search(
query = build_search_query(
q=q, langs=langs, size=page_size, page=page, config=CONFIG, sort_by=sort_by
)
logger.debug("Elasticsearch query: %s", query.to_dict())
results = query.execute()

projection = set(fields.split(",")) if fields else None
Expand All @@ -144,11 +145,10 @@ def html_search(
langs: str = "fr,en",
sort_by: str | None = None,
):
if q:
results = search(q, langs, page_size, page, sort_by)
else:
if not q:
return templates.TemplateResponse("search.html", {"request": request})

results = search(q=q, langs=langs, page_size=page_size, page=page, sort_by=sort_by)
page_count = results["page_count"]
pagination = [
{"name": p, "selected": p == page, "page_id": p}
Expand Down

0 comments on commit 313ea26

Please sign in to comment.