Skip to content

Commit

Permalink
feat:add pagination and sorting to search results
Browse files Browse the repository at this point in the history
Implemented pagination and sorting functionality in the search results. Updated filter conditions, added pagination logic, introduced new config parameters, and adjusted the dataset to support these features.
  • Loading branch information
hareshkainthdbt committed Oct 13, 2024
1 parent 80218c4 commit 7c290cb
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 7c290cb

Please sign in to comment.