Skip to content

Commit

Permalink
Merge pull request #11 from uktrade/feature/orpd-33-backend-services
Browse files Browse the repository at this point in the history
feat:add pagination and sorting to search results
  • Loading branch information
hareshkainthdbt authored Oct 13, 2024
2 parents 5c96352 + 7c290cb commit b06ad4f
Show file tree
Hide file tree
Showing 5 changed files with 958 additions and 868 deletions.
22 changes: 19 additions & 3 deletions orp/orp_search/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@

class SearchDocumentConfig:
def __init__(
self, search_terms: str, document_types=None, timeout=None, dummy=False
self,
search_terms: str,
document_types=None,
timeout=None,
dummy=False,
limit=10,
offset=1,
publisher_terms=None,
sort_by=None,
):
"""
Initializes a new instance of the class.
Expand All @@ -20,6 +28,10 @@ def __init__(
self.document_types = document_types
self.timeout = None if timeout is None else int(timeout)
self.dummy = dummy
self.limit = limit
self.offset = offset
self.publisher_terms = publisher_terms
self.sort_by = sort_by

def validate(self):
"""
Expand All @@ -35,7 +47,11 @@ def validate(self):
bool
True if 'searchTerms' is present and non-empty, False otherwise.
"""
if not self.search_terms:
logger.error("search terms are required")
if self.offset < 0:
logger.error("offset must be a positive integer")
return False

if self.limit < 0:
logger.error("limit must be a positive integer")
return False
return True
Loading

0 comments on commit b06ad4f

Please sign in to comment.