Skip to content

Commit

Permalink
fix: no "next" link when no results
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Oct 5, 2023
1 parent 2e4ea80 commit 9439886
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions share/search/index_strategy/trove_indexcard_flats.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,11 +733,10 @@ def _cardsearch_response(
if _es8_total['relation'] != 'eq':
cursor.result_count = -1 # "too many"
else: # exact (and small) count
if cursor.result_count is None or not cursor.random_sort:
cursor.result_count = _es8_total['value']
elif cursor.first_page_uuids and not cursor.is_first_page():
cursor.result_count = _es8_total['value']
if cursor.random_sort and not cursor.is_first_page():
# account for the filtered-out first page
cursor.result_count = _es8_total['value'] + len(cursor.first_page_uuids)
cursor.result_count += len(cursor.first_page_uuids)
_results = []
for _es8_hit in es8_response['hits']['hits']:
_card_iri = _es8_hit['_id']
Expand Down Expand Up @@ -1026,12 +1025,6 @@ def from_params(cls, params: CardsearchParams) -> '_CardsearchCursor':
),
)

def next_cursor(self) -> str | None:
if self.random_sort and self.is_first_page() and not self.first_page_uuids:
# "next page" is another independent random sample
return encode_cursor_dataclass(self)
return super().next_cursor()

def cardsearch_start_index(self) -> int:
if self.is_first_page() or not self.random_sort:
return self.start_index
Expand Down

0 comments on commit 9439886

Please sign in to comment.