fix(labrinth): fix filtering not working unless breakdown set to same field#6608
Conversation
Pull request changelogAppAddedChangedDeprecatedRemovedFixedSecurityWebsiteAddedChangedDeprecatedRemovedFixedSecurityHostingAddedChangedDeprecatedRemovedFixedSecurity |
ee71433 to
7690607
Compare
7e6fc2a to
914f090
Compare
|
would appreciate it if someone could look at this |
3f3f6e0 to
6941b45
Compare
b5e9649 to
9231f66
Compare
9231f66 to
abd5ab5
Compare
|
Thanks for PR'ing a fix! With the way the analytics endpoint was designed, if API users want to filter on a certain metric, they are supposed to also bucket by that metric explicitly. My rationale for this was that bucketing changes the response schema, whereas filtering will only remove certain items from arrays (but the schema of the items within the arrays stays the same). With this PR's behavior, if an API client chooses to filter by a field, they will also inherently break down by it. For example if I have 200 total downloads from X, Y, and Z, if I send a request to filter by only download sources X and Y, I'll get:
When in reality what I want is:
This requires that we split out the fields we query by, from the fields that we aggregate/bucket by at the end when we actually reutrn the response. I can implement this on top of your PR. Also re cargo sqlx prepare: you need to also prepare the test queries, so |
that should go in the docs :) also, is the CI flaky? tests seem to be working fine on my computer. it could probably do with a re-run @aecsocket is there anything else i need to do for this? |
|
Good catch! I'll add it to the docs in this PR. Also yes CI is quite flaky, ghcr is having a lot of issues with pulling images. I'll handle this though |

fixes #6607 plus some similar cases
a few notes:
|| !metrics.filter_by.<COLUMN>.is_empty()addedcargo sqlx preparedeleted a bunch of files. we've put that into its own commit so it can be dropped withgit reset --hardorgit rebase -irelatively easily if it's not meant to be thereand a screenshot of it doing the right thing:
