commit ff501cb60ba94f4cbee9d265f0b853ca4d666257 Author: Maciek Sakrejda Date: Mon Nov 16 14:37:11 2020 -0800 Fix pagination link handling If the total number of search results is divisible by the page size, the page count is mis-calculated and there's a link to an additional page of results, even though there are no more results and that page is empty. See issue here: https://www.postgresql.org/search/?m=1&q=contrib&l=76&d=365&s=r&p=2 At the moment, this has 20 results but a link to a second page, which is empty with a label of "Results 21-20 of 20." Previous and Next works still work fine, but that second page does not really need to be there. This changes the page count calculation to avoid this issue. diff --git a/pgweb/search/views.py b/pgweb/search/views.py index 49dbbfb..0a9c238 100644 --- a/pgweb/search/views.py +++ b/pgweb/search/views.py @@ -229,7 +229,7 @@ def search(request): 'query': request.GET['q'], 'pagelinks': " ".join( generate_pagelinks(pagenum, - totalhits // hitsperpage + 1, + (totalhits - 1) // hitsperpage + 1, querystr)), 'hits': [{ 'date': h['d'], @@ -305,7 +305,7 @@ def search(request): 'query': request.GET['q'], 'pagelinks': " ".join( generate_pagelinks(pagenum, - totalhits // hitsperpage + 1, + (totalhits - 1) // hitsperpage + 1, querystr)), 'hits': [{ 'title': h[3],