diff --git a/scl.py b/scl.py index 6fefe4f..867994f 100644 --- a/scl.py +++ b/scl.py @@ -409,14 +409,16 @@ 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 + lookup_active_outages_statement = ( + select(SclOutage) + .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): - if not any(event["id"] == active_outage.scl_outage_id for event in scl_events) and event: + 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(