Add sort_by parameter to GET /v1/packages#45
Closed
alanzabihi wants to merge 1 commit into
Closed
Conversation
Contributor
|
@alanzabihi this will be deprecated and moved to https://github.com/superagnet-ai/brin-core |
Contributor
Author
When? I might need this sooner. |
Contributor
I have rebuilt everything from the ground up based on the tiered origin based security model. new api, new db etc. This repo will be only host the dataset we produce. The CLI will be moved to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional
sort_byquery parameter toGET /v1/packages.Accepted values:
weekly_downloads(default, existing behaviour unchanged) andscanned_at(orders byscanned_at DESC). Any other value returns400 { "error": "invalid sort_by value" }.Composes with all existing filters:
registry,risk_level,latest,q,limit,offset.Why
The homepage "latest findings" feed needs to surface recently flagged packages. Today the frontend fetches the top 50 most-downloaded critical/warning packages and filters client-side by
scanned_at >= now - 7 days. If none of the top 50 were scanned recently, the section renders empty.With this change the frontend can call:
and drop the client-side date filter entirely.
Changes
crates/common/src/models.rs— addedPackageSortByenum, addedsort_by: Option<String>toPaginationParamscrates/common/src/db.rs— all four paginated query methods (get_packages_paginated,search_packages,get_packages_paginated_latest,search_packages_latest) now accept and applyPackageSortBycrates/api/src/handlers.rs— validatessort_by, returns 400 on unknown values, passes the parsed enum to all DB call pathsTest plan
cargo buildclean,cargo test97 passed / 0 failed