Compare commits
2 commits
1aa5ea0975
...
fa8a14e539
Author | SHA1 | Date | |
---|---|---|---|
fa8a14e539 | |||
5075e73494 |
1 changed files with 14 additions and 3 deletions
17
scl.py
17
scl.py
|
@ -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
|
||||||
|
@ -421,6 +432,8 @@ with Session(engine) as session:
|
||||||
print("Existing record not found")
|
print("Existing record not found")
|
||||||
post_id = None
|
post_id = None
|
||||||
map_media_post_id = None
|
map_media_post_id = None
|
||||||
|
neighborhood = None
|
||||||
|
city = None
|
||||||
if not event_class["is_postable"]:
|
if not event_class["is_postable"]:
|
||||||
print(
|
print(
|
||||||
"Outage is {} considered postable, will not post".format(
|
"Outage is {} considered postable, will not post".format(
|
||||||
|
@ -438,13 +451,11 @@ with Session(engine) as session:
|
||||||
post_id = initial_post_result["post_id"]
|
post_id = initial_post_result["post_id"]
|
||||||
map_media_post_id = initial_post_result["map_media_post_id"]
|
map_media_post_id = initial_post_result["map_media_post_id"]
|
||||||
|
|
||||||
neighborhood = str()
|
|
||||||
try:
|
try:
|
||||||
neighborhood = initial_post_result["neighborhood"]
|
neighborhood = initial_post_result["neighborhood"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
city = str()
|
|
||||||
try:
|
try:
|
||||||
city = initial_post_result["city"]
|
city = initial_post_result["city"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
Loading…
Reference in a new issue