Revert to looking up all, only post if previously posted

This commit is contained in:
Liam Steckler 2024-01-31 21:30:44 -08:00
parent 421fee8933
commit b3474e24c9

8
scl.py
View file

@ -409,10 +409,8 @@ with Session(engine) as session:
session.add(new_outage_record)
session.commit()
lookup_active_outages_statement = (
select(SclOutage)
.where(SclOutage.no_longer_in_response_time == None)
.where(SclOutage.most_recent_post_id != None)
lookup_active_outages_statement = select(SclOutage).where(
SclOutage.no_longer_in_response_time == None
)
for active_outage in session.scalars(lookup_active_outages_statement):
if (
@ -420,6 +418,7 @@ with Session(engine) as session:
and event
):
# Event ID no longer exists in response
if active_outage.most_recent_post_id:
post_result = mastodon.status_post(
status="This outage is reported to be resolved.\n\n#SeattleCityLightOutage #SCLOutage #SCLOutage{}".format(
active_outage.outage_user_id
@ -428,7 +427,6 @@ with Session(engine) as session:
visibility="public",
language="en",
)
active_outage.most_recent_post_id = post_result["id"]
active_outage.no_longer_in_response_time = datetime.now()
session.commit()