You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add detections_count to sequence and alert responses (#559)
* feat(schemas): add detection_count to SequenceRead schema
* feat(endpoints): add helper function to get sequence count
* feat(endpoints): add sequence count to alerts endpoints
* feat(endpoints): add sequence count to sequences endpoint
* Fix local CI ordering and ruff issues
* refactor(services): move detection-count helper to services/
Per review feedback on PR #559: get_detection_counts_by_sequence_ids
is an aggregation query, not a CRUD/route helper, so it belongs in
services/ where it can be reused outside of endpoint modules.
* refactor(alerts): align _serialize_sequence signature across endpoints
Per review feedback on PR #559: _serialize_sequence in alerts.py took
the full Dict[int, int] of counts and did the lookup inside. Match the
sequences.py version (scalar int param, caller does the lookup) so the
helper has one shape repo-wide and only does serialization.
* refactor: drop redundant int() casts on model id attributes
Per review feedback on PR #559: Sequence.id and Alert.id are typed
int on the model, so int(sequence.id) / int(alert.id) is redundant.
Same for the dict comprehension in get_detection_counts_by_sequence_ids
where the row values are already int.
The int(alert_id) at alerts.py:46 stays because alert_id there is
unpacked from a raw SQL row tuple, not a model attribute.
* test(alerts): use strict=True when zipping fixture sequences and counts
Per review feedback on PR #559: strict=False silently swallows length
mismatches. Both lists have length 3 today, so flipping to strict=True
guards against future fixture edits drifting out of sync.
* test(sequences): use utcnow() helper in detections-count test
Rebase fallout from #574 (datetime.utcnow deprecation): one new test
function still called datetime.utcnow() while the datetime import had
been removed from the file, causing NameError on collection.
0 commit comments