Revert to looking up all, only post if previously posted
This commit is contained in:
parent
421fee8933
commit
b3474e24c9
1 changed files with 12 additions and 14 deletions
26
scl.py
26
scl.py
|
@ -409,10 +409,8 @@ with Session(engine) as session:
|
||||||
session.add(new_outage_record)
|
session.add(new_outage_record)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
lookup_active_outages_statement = (
|
lookup_active_outages_statement = select(SclOutage).where(
|
||||||
select(SclOutage)
|
SclOutage.no_longer_in_response_time == None
|
||||||
.where(SclOutage.no_longer_in_response_time == None)
|
|
||||||
.where(SclOutage.most_recent_post_id != None)
|
|
||||||
)
|
)
|
||||||
for active_outage in session.scalars(lookup_active_outages_statement):
|
for active_outage in session.scalars(lookup_active_outages_statement):
|
||||||
if (
|
if (
|
||||||
|
@ -420,15 +418,15 @@ with Session(engine) as session:
|
||||||
and event
|
and event
|
||||||
):
|
):
|
||||||
# Event ID no longer exists in response
|
# Event ID no longer exists in response
|
||||||
post_result = mastodon.status_post(
|
if active_outage.most_recent_post_id:
|
||||||
status="This outage is reported to be resolved.\n\n#SeattleCityLightOutage #SCLOutage #SCLOutage{}".format(
|
post_result = mastodon.status_post(
|
||||||
active_outage.outage_user_id
|
status="This outage is reported to be resolved.\n\n#SeattleCityLightOutage #SCLOutage #SCLOutage{}".format(
|
||||||
),
|
active_outage.outage_user_id
|
||||||
in_reply_to_id=active_outage.most_recent_post_id,
|
),
|
||||||
visibility="public",
|
in_reply_to_id=active_outage.most_recent_post_id,
|
||||||
language="en",
|
visibility="public",
|
||||||
)
|
language="en",
|
||||||
|
)
|
||||||
active_outage.most_recent_post_id = post_result["id"]
|
active_outage.most_recent_post_id = post_result["id"]
|
||||||
active_outage.no_longer_in_response_time = datetime.now()
|
active_outage.no_longer_in_response_time = datetime.now()
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
Loading…
Reference in a new issue