Only count estimated restoration as different if they're 30+m apart (#63)
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/vulnerability-scan Pipeline was successful

Initial attempt at solving #62.

Currently setting to 30m, can adjust if needed.

Reviewed-on: #63
This commit is contained in:
Liam Steckler 2024-10-27 10:54:56 -07:00
parent 5075e73494
commit 13e08bb890

13
scl.py
View file

@ -326,7 +326,18 @@ with Session(engine) as session:
existing_record = lookup_result.one() existing_record = lookup_result.one()
updated_properties = [] updated_properties = []
updated_entries = [] updated_entries = []
if estimated_restoration_time != existing_record.estimated_restoration_time:
est_restoration_diff_mins = (
abs(
(
estimated_restoration_time
- existing_record.estimated_restoration_time
).total_seconds()
)
/ 60
)
# Only post if estimated restoration time has changed by 30m or more
if est_restoration_diff_mins >= 30:
existing_record.estimated_restoration_time = estimated_restoration_time existing_record.estimated_restoration_time = estimated_restoration_time
if estimated_restoration_time > datetime.now(): if estimated_restoration_time > datetime.now():
# New estimated restoration time is in the future, so likely to be a real time # New estimated restoration time is in the future, so likely to be a real time