Fixing search last page button bug.
Review Request #14656 — Created Oct. 27, 2025 and updated
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.
| Summary | ID |
|---|---|
| 29a273f3849f4e6c606115f3fa9d412fce05ef0b | |
| 3ae03836a62c63be67334ef7a061b4b00ef8c6a8 |
- Description:
-
~ The "Last Page" button in search should navigate to the final page of results, but previously it used
paginator.num_pages - 1, which fails because Django’sPaginatoris 1-indexed, not 0-indexed. This change resolves the issue by usingpaginator.num_pagesdirectly, ensuring the button correctly goes to the last page.~ The "Last Page" button in search should navigate to the final page of results,
+ but previously it used paginator.num_pages - 1, which fails because Django’s+ Paginatoris 1-indexed, not 0-indexed. This change resolves the issue by+ using paginator.num_pagesdirectly, ensuring the button correctly goes to the+ last page. - Testing Done:
-
~ 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 calculatedlast_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’snum_pagesproperty, ensuring it accurately reflects the total number of pages.~ In
test_pagination(), the test originally passed by returning 20 for the last+ page after creating 20 mock review requests with search_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. - Commits:
-
Summary ID 29a273f3849f4e6c606115f3fa9d412fce05ef0b 9180c51a30c16a286c25e6b91ce8399a3dde3dea 29a273f3849f4e6c606115f3fa9d412fce05ef0b 3ae03836a62c63be67334ef7a061b4b00ef8c6a8