pulsar-edit / package-backend

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

Fix inability to search and filter packages at the same time #214

Closed savetheclocktower closed 8 months ago

savetheclocktower commented 9 months ago

Is this feature Currently Implemented in any way with the upstream API Server

Is your feature request related to a problem? Please describe.

There's one endpoint — /package/search for searching against the name of a package. There's another endpoint — /packages — for filtering on packages with fields like service. This means there appears to be no way to search and filter at the same time.

Describe the solution you'd like

I think there should be one endpoint — probably just /packages. If q is present, a search is performed. If other fields are present, other clauses are added to the SQL query.

confused-Techie commented 9 months ago

You are totally right here that it seems weird for them to be broken up.

And this issue gets even worse when you consider that the search endpoint does already support the order parameter.

It'll likely take some time to get the SQL statement right to accommodate all of these different features, but this is a great idea.

I'll add, what we would likely want to do is perfect one of the database functions to be able to handle each use case, then have these two endpoints rely on the same function, maybe even deprecating the special search endpoint, as it's redundant at that point.