Skip to content

Commit

Permalink
Merge pull request #37 from uktrade/feature/orpd-54-search-term-query
Browse files Browse the repository at this point in the history
chore:reduce result count and fix pagination handling
  • Loading branch information
hareshkainthdbt authored Oct 30, 2024
2 parents dc37c98 + 6bf5d0b commit 80c0c05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 6 additions & 3 deletions orp/orp_search/legislation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def search(self, config: SearchDocumentConfig):
"lang": "en",
"title": search_terms,
"text": search_terms,
"results-count": 100,
"results-count": 20,
}

# Register namespaces
Expand Down Expand Up @@ -137,12 +137,15 @@ def _extract_entries(root):
all_entries += _extract_entries(root)

morePages = int(page_data["morePages"])
logger.info(f"legislation more pages: {morePages}")
if morePages > 1:
logger.info(f"legislation more pages: {morePages}")

# Get remaining pages
for page in range(2, morePages + 1):
params["page"] = page
root, _ = _do_request()
all_entries.append(_extract_entries(root))
results = _extract_entries(root)
all_entries += results

logger.info(f"legislation total results: {len(all_entries)}")
return all_entries
6 changes: 0 additions & 6 deletions orp/orp_search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,6 @@ def search(request: HttpRequest) -> HttpResponse:
search_results = public_gateway.search(config)

# Legislation search
# If config.search_terms is empty then we don't need to
# search for legislation
if not config.search_terms or "" in config.search_terms:
logger.info("no search terms provided")
return render(request, template_name="orp.html", context=context)

if not config.document_types or "legislation" in config.document_types:
logger.info("searching for legislation: %s", config.search_terms)
legislation = Legislation()
Expand Down

0 comments on commit 80c0c05

Please sign in to comment.