-
-
Notifications
You must be signed in to change notification settings - Fork 11
Add detections_count to sequence and alert responses #559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8f8cd89
feat(schemas): add detection_count to SequenceRead schema
ThbltLmr c3587bd
feat(endpoints): add helper function to get sequence count
ThbltLmr 747c755
feat(endpoints): add sequence count to alerts endpoints
ThbltLmr 687e938
feat(endpoints): add sequence count to sequences endpoint
ThbltLmr 71460a7
Fix local CI ordering and ruff issues
ThbltLmr d59fc46
refactor(services): move detection-count helper to services/
ThbltLmr 65c3734
refactor(alerts): align _serialize_sequence signature across endpoints
ThbltLmr d8b1d5b
refactor: drop redundant int() casts on model id attributes
ThbltLmr b598e19
test(alerts): use strict=True when zipping fixture sequences and counts
ThbltLmr a011104
test(sequences): use utcnow() helper in detections-count test
ThbltLmr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,4 +22,4 @@ class SequenceLabel(BaseModel): | |
|
|
||
|
|
||
| class SequenceRead(Sequence): | ||
| pass | ||
| detections_count: int = 0 | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Copyright (C) 2025-2026, Pyronear. | ||
|
|
||
| # This program is licensed under the Apache License 2.0. | ||
| # See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details. | ||
|
|
||
|
|
||
| from typing import Any, Dict, List, cast | ||
|
|
||
| from sqlmodel import func, select | ||
| from sqlmodel.ext.asyncio.session import AsyncSession | ||
|
|
||
| from app.models import Detection | ||
|
|
||
|
|
||
| async def get_detection_counts_by_sequence_ids(session: AsyncSession, sequence_ids: List[int]) -> Dict[int, int]: | ||
| if not sequence_ids: | ||
| return {} | ||
|
|
||
| stmt: Any = ( | ||
| select(cast(Any, Detection.sequence_id), func.count(Detection.id)) | ||
| .where(cast(Any, Detection.sequence_id).in_(sequence_ids)) | ||
| .group_by(cast(Any, Detection.sequence_id)) | ||
| ) | ||
| res = await session.exec(stmt) | ||
| return {sequence_id: detections_count for sequence_id, detections_count in res.all() if sequence_id is not None} |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.