-
-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Motivation
Currently, the /api/v1/detections/ POST endpoint allow to create detections but the creation date (created_at) is imposed (= now)
While this may have been satisfactory for a while, detections can sometimes be cached on the engine side, meaning that when they are posted on the API, they get published almost all at the same datetime, even though each detection occured at different times.
Bonus point : As of today in the envdenv, this is not straight forward to create alerts in the past (for demonstration purpose), it will be easier once this issue is solved !
What should be done
-
Adds recorded_at field to
detectionstable. -
Updates endpoints of the api adding recorded_at in :
- /api/v1/detections/ POST (in order to be able to set date as recorded_at as parameter )
- /api/v1/detections/{detection_id} GET
- /api/v1/detections/ GET
- /api/v1/sequences/{sequence_id}/detections GET
-
Updates how detections are linked to sequences : Currently based on the created_at field, must be related to the recorded_at field
- mainly in pyro-api/src/app/api/api_v1/endpoints/detections.py
- updates creation rule and sequence creation/update of started_eat and last_seen_at fields
-
Add migration script (in
migrationsdirectory).- add upgrade (create created_at field if does not exists, and copy data as described below) and downgrade function (drop field) -> you can check other migration scripts !
- Migrations rules : copy data from created_at field if recorded_at is empty, probably something like
UPDATE detections
SET recorded_at = created_at
WHERE recorded_at IS NULL;
- do not forget to add tests ;)
Happy to discuss it :)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status