Fix pagination link handling in search results

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Fix pagination link handling in search results

Maciek Sakrejda-3

Hi!

Thanks for maintaining pgweb.

I noticed this issue when searching mailing lists. I did not test  the change in the application, but I did test the logic in a local python console and I think it's right.

Commit message of the attached commit follows, explaining the issue:

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.


fix-pagination-link-handling.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Fix pagination link handling in search results

Jonathan S. Katz-3
Hi Maciek,

On 11/16/20 5:55 PM, Maciek Sakrejda wrote:
> Hi!
>
> Thanks for maintaining pgweb.

Thanks!

> I noticed this issue when searching mailing lists. I did not test  the
> change in the application, but I did test the logic in a local python
> console and I think it's right.

Funny enough, it's kind of tough to test the search features locally :(

> Commit message of the attached commit follows, explaining the issue:
>
> 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
> <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.
I was able to reproduce the issue and do agree that it is a bug. I have
not been able to verify your solution yet but I have it on my TODO.

Thanks,

Jonathan

OpenPGP_0xF1049C729F1C6527.asc (13K) Download Attachment
OpenPGP_signature (855 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Fix pagination link handling in search results

Magnus Hagander-2
On Wed, Nov 18, 2020 at 3:24 AM Jonathan S. Katz <[hidden email]> wrote:

>
> Hi Maciek,
>
> On 11/16/20 5:55 PM, Maciek Sakrejda wrote:
> > Hi!
> >
> > Thanks for maintaining pgweb.
>
> Thanks!
>
> > I noticed this issue when searching mailing lists. I did not test  the
> > change in the application, but I did test the logic in a local python
> > console and I think it's right.
>
> Funny enough, it's kind of tough to test the search features locally :(
>
> > Commit message of the attached commit follows, explaining the issue:
> >
> > 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
> > <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.
>
> I was able to reproduce the issue and do agree that it is a bug. I have
> not been able to verify your solution yet but I have it on my TODO.

I've verified that it does work in my local dev env, so I've pushed the fix.

Thanks!

--
 Magnus Hagander
 Me: https://www.hagander.net/
 Work: https://www.redpill-linpro.com/