feat: add limit/offset pagination to /alerts/unlabeled/latest#588
Open
feat: add limit/offset pagination to /alerts/unlabeled/latest#588
Conversation
Replaces the hardcoded .limit(15) on GET /api/v1/alerts/unlabeled/latest with optional limit and offset query parameters, matching the convention already used by /alerts/all/fromdate. Default limit=15 preserves prior behavior; clients can now paginate or request more alerts. Closes #587
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #588 +/- ##
=======================================
Coverage 89.92% 89.92%
=======================================
Files 55 55
Lines 2451 2451
=======================================
Hits 2204 2204
Misses 247 247
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fe51
approved these changes
May 8, 2026
| summary="Fetch all the alerts with unlabeled sequences from the last 24 hours", | ||
| ) | ||
| async def fetch_latest_unlabeled_alerts( | ||
| limit: Union[int, None] = Query(15, description="Maximum number of alerts to fetch"), |
Member
There was a problem hiding this comment.
small suggestion to avoid silent fail
Suggested change
| limit: Union[int, None] = Query(15, description="Maximum number of alerts to fetch"), | |
| limit: Union[int, None] = Query(15, ge=1, description="Maximum number of alerts to fetch"), |
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.
Summary
limit(default 15) andoffset(default 0) query parameters toGET /api/v1/alerts/unlabeled/latest, replacing the hardcoded.limit(15).GET /alerts/all/fromdateandGET /sequences/all/fromdate.limit=15preserves prior behavior for existing callers; the platform Alerts page can now request more or paginate.Closes #587 (also unblocks pyronear/new-pyro-platform#202).
Test plan
test_alerts_unlabeled_latest_paginationcovers the full page, page 1 (limit=1&offset=0), and page 2 (limit=1&offset=1).test_alerts_unlabeled_lateststill passes with the new defaults.