Skip to content

feat: add limit/offset pagination to /alerts/unlabeled/latest#588

Open
Acruve15 wants to merge 1 commit intomainfrom
feat/alerts-unlabeled-latest-pagination
Open

feat: add limit/offset pagination to /alerts/unlabeled/latest#588
Acruve15 wants to merge 1 commit intomainfrom
feat/alerts-unlabeled-latest-pagination

Conversation

@Acruve15
Copy link
Copy Markdown
Collaborator

@Acruve15 Acruve15 commented May 7, 2026

Summary

  • Adds optional limit (default 15) and offset (default 0) query parameters to GET /api/v1/alerts/unlabeled/latest, replacing the hardcoded .limit(15).
  • Matches the convention already used by GET /alerts/all/fromdate and GET /sequences/all/fromdate.
  • Default limit=15 preserves 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

  • New test_alerts_unlabeled_latest_pagination covers the full page, page 1 (limit=1&offset=0), and page 2 (limit=1&offset=1).
  • Existing test_alerts_unlabeled_latest still passes with the new defaults.
  • CI runs the full backend test suite.

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
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.92%. Comparing base (077eeda) to head (13afa33).

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           
Flag Coverage Δ
backend 89.89% <ø> (ø)
client 90.40% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Acruve15 Acruve15 requested a review from fe51 May 7, 2026 10:15
Copy link
Copy Markdown
Member

@fe51 fe51 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @Acruve15 , thanks a lot for this efficient PR !
Respects codebase structure and is tested ! Good to merge !

I juste added a small suggestion

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"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add limit/offset param to GET /api/v1/alerts/unlabeled/latest

2 participants