Only post "resolved" posts if previously posted
This commit is contained in:
parent
2f90d1b236
commit
08d896fb61
1 changed files with 5 additions and 2 deletions
7
scl.py
7
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(
|
||||
|
|
Loading…
Reference in a new issue