pulsar-edit / package-backend

Pulsar Server Backend for Packages
https://api.pulsar-edit.dev
MIT License
12 stars 11 forks source link

[BUG] Reports incorrect pagination totals #213

Open savetheclocktower opened 9 months ago

savetheclocktower commented 9 months ago

Is this Bug Present in the upstream API Server?

What is the Bug

The query-total header is returning the total number of pages, not the total number of results. That's why pagination controls look wrong.

How to Replicate the Bug

Look at the query-total header on this endpoint:

curl -I "https://api.pulsar-edit.dev/api/packages?service=outline-view&serviceType=provided"
query-total: 4

Now count how many results are returned on the same endpoint for the first page alone:

curl "https://api.pulsar-edit.dev/api/packages?service=outline-view&serviceType=provided" | jq
30
savetheclocktower commented 9 months ago

Here's your problem:

https://github.com/pulsar-edit/package-backend/blob/main/src/database.js#L1625-L1627

Terminology-wise, you probably want to distinguish count and total from each other. Maybe rename them to result-count & total-pages.

confused-Techie commented 8 months ago

@savetheclocktower Just to clarify, did #215 fully address this concern?

savetheclocktower commented 8 months ago

No, I believe this still needs a fix on the frontend.

confused-Techie commented 8 months ago

Thanks for clarifying, just wanting to check in