WEEE-Open / tarallo

T.A.R.A.L.L.O. Inventory System
GNU Affero General Public License v3.0
16 stars 9 forks source link

Filtering in getRecentAuditByType. Closes #243 #262

Closed Learath2 closed 1 year ago

Learath2 commented 1 year ago

I went for v2/stats/getRecentAuditByType/U/5/<feature>=<value> instead of the requested v2/stats/getRecentAuditByType/U/5/<value> mostly because filtering on the feature is also free.

So recent audits related to cases would be v2/stats/getRecentAuditByType/U/5/type=case.

There should be no performance regression on the unfiltered case and the filtered query doesn't seem to have an outrageous execution plan in MariaDB 10.4

Q: I've noticed the API shies away from using query parameters (URIs don't really identify resources either so it's not very usual). Is there a reason for that? Something along the lines of v2/stats/getRecentAudits?type=<auditType>&filter=<feature>:<value>&limit=<limit> would feel more natural, at least to me.

lvps commented 1 year ago

A: The reason is that typing ? and & is annoying 😆 Plus, there would be just a long and messy list of parameters with these stats API endpoints, which means: whoever has to write a client will complain non-stop that it is too hard to remember all the parameters, there are too many symbols, ...

As you noted, these endpoints don't even identify resources so it's not RESTful at all, it's more like RPC with JSON, but we have to implement the maximum amount of features with the minimum amount of code and dependencies and characters and "things to explain to other people" given that nobody maintains the software in the long term, the students working on it are constantly changing and we have very little time to explain how everything works before people graduate and leave