Skip to content

Commit

Permalink
Merge branch 'main' of github.com:uktrade/orp into ORPD-31-document-d…
Browse files Browse the repository at this point in the history
…etails-page
  • Loading branch information
gdbarnes committed Oct 14, 2024
2 parents f25697e + b06ad4f commit cc8e2c2
Show file tree
Hide file tree
Showing 5 changed files with 958 additions and 861 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 cc8e2c2

Please sign in to comment.