Fixing search last page button bug.

Review Request #14656 — Created Oct. 27, 2025 and updated

Information

Review Board
master

Reviewers

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 Paginator is 1-indexed, not 0-indexed. This change resolves the issue by using paginator.num_pages directly, 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 with search_results_per_page set to 1. However, reindex_search() adds an additional page during indexing, resulting in a total of 21 pages. Consequently, the view calculated last_page_num as 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_pages property, ensuring it accurately reflects the total number of pages.

Summary ID
Fixing search last page button bug.
The "last page" button in the search is supposed to take you to the last page of the results, however it does this with `paginator.num_pages - 1`. This fails because the Django Paginator is 1-indexed instead of 0-indexed. This change fixes this issue by no longer subtracting 1.
29a273f3849f4e6c606115f3fa9d412fce05ef0b
Corrected search test for "Last Page" button.
The test in test_pagination() was correctly passing by returning 20 for the last page after 20 mock review requests were made with a search_results_per_page of 1 because reindex_search() at some point adds an additional page, leaving a total of 21 pages for the test, instead of 20. This meant that when the view calculated `last_num_page`, it was set to 20, when in reality, based on the number of pages, it should have been 21. To correct this, I altered the test to now check based on the paginator's `num_pages` for the last page assertion.
9180c51a30c16a286c25e6b91ce8399a3dde3dea
Description From Last Updated

The description and testing done sections need to wrap at 79 characters (each line can be no longer than 79 …

maubinmaubin

I'm not quite sure what the "for debugging" part of this comment means. Also can you capitalize and add a …

maubinmaubin
Checks run (2 succeeded)
flake8 passed.
JSHint passed.
maubin
  1. Looks good! Just have some style nits.

  2. Show all issues

    The description and testing done sections need to wrap at 79 characters (each line can be no longer than 79 characters).

  3. Show all issues

    I'm not quite sure what the "for debugging" part of this comment means. Also can you capitalize and add a period to make it a proper sentence.

  4.