From 5075e734947d27ff86f29666329ea57fc5ec1912 Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Sun, 27 Oct 2024 10:30:54 -0700 Subject: [PATCH 1/2] Move declarations to the right spot --- scl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scl.py b/scl.py index c8d002e..8fcb2b2 100644 --- a/scl.py +++ b/scl.py @@ -421,6 +421,8 @@ with Session(engine) as session: print("Existing record not found") post_id = None map_media_post_id = None + neighborhood = None + city = None if not event_class["is_postable"]: print( "Outage is {} considered postable, will not post".format( @@ -438,13 +440,11 @@ with Session(engine) as session: post_id = initial_post_result["post_id"] map_media_post_id = initial_post_result["map_media_post_id"] - neighborhood = str() try: neighborhood = initial_post_result["neighborhood"] except KeyError: pass - city = str() try: city = initial_post_result["city"] except KeyError: From fa8a14e539e9a2f075313d747d0874b7e0d0163a Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Sun, 27 Oct 2024 10:51:32 -0700 Subject: [PATCH 2/2] Only count estimated restoration as different if they're 30+m apart --- scl.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scl.py b/scl.py index 8fcb2b2..c37f50c 100644 --- a/scl.py +++ b/scl.py @@ -326,7 +326,18 @@ with Session(engine) as session: existing_record = lookup_result.one() updated_properties = [] 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 if estimated_restoration_time > datetime.now(): # New estimated restoration time is in the future, so likely to be a real time