From 2f90d1b2366c9e8ee321e017ae2c030533ff3c38 Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Tue, 30 Jan 2024 17:57:25 -0800 Subject: [PATCH] Determine if the event has ever hit the class to post --- scl.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/scl.py b/scl.py index 5582254..3bf8fa4 100644 --- a/scl.py +++ b/scl.py @@ -175,6 +175,7 @@ with Session(engine) as session: if existing_record.max_num_people < event["numPeople"]: # Used to determine the maximum number of people affected by this outage, to determine if it's worth posting about existing_record.max_num_people = event["numPeople"] + max_event_class = classify_event_size(existing_record.max_num_people) if updated_properties: updated_properties.sort() @@ -196,15 +197,20 @@ with Session(engine) as session: ) updated_entries.append("") updated_entries.append(hashtag_string) - post_result = mastodon.status_post( - status="\n".join(updated_entries), - in_reply_to_id=existing_record.most_recent_post_id, - visibility="public", - language="en", - ) - existing_record.most_recent_post_id = post_result["id"] + if max_event_class["is_postable"] and existing_record.initial_post_id: + post_result = mastodon.status_post( + status="\n".join(updated_entries), + in_reply_to_id=existing_record.most_recent_post_id, + visibility="public", + language="en", + ) + existing_record.most_recent_post_id = post_result["id"] + elif max_event_class["is_postable"]: + print( + "This event would have been able to be posted, but someone didn't write the logic to do that for events that scaled up." + ) - session.commit() + session.commit() except NoResultFound: print("Existing record not found")