Fixing search last page button bug.
Review Request #14656 — Created Oct. 27, 2025 and updated — Latest diff uploaded
The "Last Page" button in search should navigate to the final page of results,
but previously it usedpaginator.num_pages - 1, which fails because Django’s
Paginatoris 1-indexed, not 0-indexed. This change resolves the issue by
usingpaginator.num_pagesdirectly, ensuring the button correctly goes to the
last page.
In
test_pagination(), the test originally passed by returning 20 for the last
page after creating 20 mock review requests withsearch_results_per_pageset
to 1. However,reindex_search()adds an additional page during indexing,
resulting in a total of 21 pages. Consequently, the view calculated
last_page_numas 20, which did not match the actual last page. To address
this, the test was updated to assert the last page based on the paginator’s
num_pagesproperty, ensuring it accurately reflects the total number of
pages.