Adjust timestamps to reflect actual detection time instead of audio file start time #235
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
Fixes #227
Problem: Currently, the detection timestamp stored in the database corresponds to the start time of the original audio file. As a result, several detections generated from the same file all share the same timestamp, even though these detections actually occurred at different moments within that file.
Proposed change: Adjust the timestamp stored in the database to reflect the actual detection time, by adding the delay in seconds between the start of the audio file and the start of the detection.
Detailed description of the changes
Detection
class inhelpers.py
:datetime (datetime.datetime)
: The actual detection start time, calculated as the audio file's start datetime plus de delay (in seconds) between the audio file start and detection start.date (str)
: Date in format YYYY-mm-dd.time (str)
: Time in format HH:MM:SS.iso8601 (str)
: Detection datetime in ISO 8601 format.week (int)
: Week number of the detection.ParseFileName
class inhelpers.py
. However attributes are used here instead of properties since these values do not need recalculating when accessed.file_date
is added to theDetection
constructor to calculate these attributes based on the known audio file start datetime.date
andtime
properties of theParseFileName
class inhelpers.py
are removed, as they are no longer used in the codebase.reporting.py
, the detection timestamp is now based on the actual detection datetime instead of the audio file datetime. The updated timestamp is used in:Detection
, aligning with the updatedDetection
constructor