Skip to content

feat: add project_type filter to random projects endpoint#6687

Open
creeperkatze wants to merge 5 commits into
modrinth:mainfrom
creeperkatze:random-project-improvements
Open

feat: add project_type filter to random projects endpoint#6687
creeperkatze wants to merge 5 commits into
modrinth:mainfrom
creeperkatze:random-project-improvements

Conversation

@creeperkatze

Copy link
Copy Markdown
Contributor

Adds an optional project_type filter to /projects_random.

Also fixes a sampling bias where filtered results could repeat the same project many calls in a row, and a query planning issue that caused a full table scan for common project types.

@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

@creeperkatze

Copy link
Copy Markdown
Contributor Author

Benchmark:

Scenario main random-project-improvements
Unfiltered, count=1 0.47 ms 0.62 ms
Unfiltered, count=100 0.41 ms 0.61 ms
project_type=mod (common, ~all rows), count=1 n/a 0.52 ms
project_type=mod (common, ~all rows), count=100 n/a 7.62 ms

@Prospector Prospector requested a review from a team July 10, 2026 16:52
@Hallskii Hallskii requested a review from fetchfern July 10, 2026 16:55
Comment thread apps/labrinth/src/routes/v3/projects.rs
@creeperkatze

Copy link
Copy Markdown
Contributor Author

Unrelated, but imo a route like /projects/random would make more sense for a future api spec.

@Sychic

Sychic commented Jul 10, 2026

Copy link
Copy Markdown
Member

Don't forget to run cargo sqlx prepare -- --tests

@creeperkatze

Copy link
Copy Markdown
Contributor Author

Don't forget to run cargo sqlx prepare -- --tests

Doing that rn, sadly have to use wsl since my local rust toolchain still wont compile labrinth for some reason, some issue when compiling a dependency.

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.

4 participants