From 08d896fb6144826c406c6ebc44a5bb9a7a29c4de Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Wed, 31 Jan 2024 21:23:39 -0800 Subject: [PATCH] Only post "resolved" posts if previously posted --- scl.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scl.py b/scl.py index 3bf8fa4..6fefe4f 100644 --- a/scl.py +++ b/scl.py @@ -119,7 +119,7 @@ class SclOutage(Base): return f"SclOutage(scl_outage_id={self.scl_outage_id!r}, most_recent_post_id={self.most_recent_post_id!r}, initial_post_id={self.initial_post_id!r}, map_media_post_id={self.map_media_post_id!r}, last_updated_time={self.last_updated_time!r}, no_longer_in_response_time={self.no_longer_in_response_time!r}), start_time={self.start_time!r}), num_people={self.num_people!r}), max_num_people={self.max_num_people!r})" -engine = create_engine("sqlite:///scl.db") +engine = create_engine("sqlite:///scl.db", echo=True) Base.metadata.create_all(engine) with Session(engine) as session: @@ -411,9 +411,12 @@ with Session(engine) as session: lookup_active_outages_statement = select(SclOutage).where( SclOutage.no_longer_in_response_time == None + + ).where( + SclOutage.most_recent_post_id ) for active_outage in session.scalars(lookup_active_outages_statement): - if not any(event["id"] == active_outage.scl_outage_id for event in scl_events): + if not any(event["id"] == active_outage.scl_outage_id for event in scl_events) and event: # Event ID no longer exists in response post_result = mastodon.status_post( status="This outage is reported to be resolved.\n\n#SeattleCityLightOutage #SCLOutage #SCLOutage{}".format(