Skip to content

fix(labrinth): fix filtering not working unless breakdown set to same field#6608

Merged
clrxbl merged 4 commits into
modrinth:mainfrom
penguinencounter:fix-analytics-filters
Jul 12, 2026
Merged

fix(labrinth): fix filtering not working unless breakdown set to same field#6608
clrxbl merged 4 commits into
modrinth:mainfrom
penguinencounter:fix-analytics-filters

Conversation

@penguinencounter

@penguinencounter penguinencounter commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

fixes #6607 plus some similar cases

a few notes:

  • project ID & dependent project ID work without changing their column enable logic
    • i did not check how they work, but they seem to work on prod so i didn't touch it
  • pretty much all other fields needed a || !metrics.filter_by.<COLUMN>.is_empty() added
  • user agent already had that, but was instead broken by not checking the correct thing when attaching the user agent data
  • cargo sqlx prepare deleted a bunch of files. we've put that into its own commit so it can be dropped with git reset --hard or git rebase -i relatively easily if it's not meant to be there
    • feel free to force-push the PR as needed

and a screenshot of it doing the right thing:
image

@modrinth-bot

Copy link
Copy Markdown
Member

Pull request changelog

App

Added

Changed

Deprecated

Removed

Fixed

Security

Website

Added

Changed

Deprecated

Removed

Fixed

Security

Hosting

Added

Changed

Deprecated

Removed

Fixed

Security

@penguinencounter penguinencounter force-pushed the fix-analytics-filters branch 9 times, most recently from ee71433 to 7690607 Compare July 5, 2026 02:10
@penguinencounter penguinencounter changed the title fix(labrinth): send columns relevant to analytics filters fix(labrinth): fix filtering not working unless breakdown set to same field Jul 6, 2026
@penguinencounter penguinencounter force-pushed the fix-analytics-filters branch 7 times, most recently from 7e6fc2a to 914f090 Compare July 8, 2026 06:13
@penguinencounter

Copy link
Copy Markdown
Contributor Author

would appreciate it if someone could look at this

@penguinencounter penguinencounter force-pushed the fix-analytics-filters branch 2 times, most recently from 3f3f6e0 to 6941b45 Compare July 9, 2026 16:50
@Hallskii Hallskii requested a review from aecsocket July 10, 2026 16:48
@penguinencounter penguinencounter force-pushed the fix-analytics-filters branch 2 times, most recently from b5e9649 to 9231f66 Compare July 11, 2026 01:23
@aecsocket

Copy link
Copy Markdown
Contributor

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:

  • { "downloads": 100, "source": "X" }
  • { "downloads": 50, "source": "Y" }
  • (the other 50 downloads from Z are excluded)

When in reality what I want is:

  • { "downloads": 150 }
  • (the other 50 downloads from Z are excluded)

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 cargo sqlx prepare -- --tests

@penguinencounter

Copy link
Copy Markdown
Contributor Author

you need to also prepare the test queries, so cargo sqlx prepare -- --tests

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
image

@aecsocket is there anything else i need to do for this?

@aecsocket

Copy link
Copy Markdown
Contributor

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

@clrxbl clrxbl merged commit 7c4df74 into modrinth:main Jul 12, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Monetization data does not load unless "Monetization" breakdown is selected

4 participants