From 09f792ecc4e9c4f60e091a4f12414b7c1e3cc959 Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Sat, 20 Apr 2024 15:40:31 -0700 Subject: [PATCH 1/4] Remove post hashtag with Outage ID --- scl.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scl.py b/scl.py index f2c31a3..1bcda11 100644 --- a/scl.py +++ b/scl.py @@ -99,9 +99,7 @@ def classify_event_size(num_people: int) -> dict[str, str | bool]: def get_hashtag_string(event) -> str: - hashtag_string = "#SeattleCityLightOutage #SCLOutage #SCLOutage{}".format( - event["identifier"] - ) + hashtag_string = "#SeattleCityLightOutage #SCLOutage" return hashtag_string -- 2.45.2 From 2a240a1f3f4f1ff5801cf09ac9fb33df0823ba13 Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Sat, 20 Apr 2024 16:49:25 -0700 Subject: [PATCH 2/4] Add neighborhood hashtag --- scl.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/scl.py b/scl.py index 1bcda11..5faf0d8 100644 --- a/scl.py +++ b/scl.py @@ -99,7 +99,23 @@ def classify_event_size(num_people: int) -> dict[str, str | bool]: def get_hashtag_string(event) -> str: - hashtag_string = "#SeattleCityLightOutage #SCLOutage" + city = str() + try: + city = event["geoloc_city"] + except KeyError: + city = event["city"] + + neighborhood_text = str() + try: + neighborhood = event["neighborhood"] + if neighborhood != city: + neighborhood_text = " #{}".format(neighborhood).title().replace(" ", "") + except KeyError: + pass + + hashtag_string = "#SeattleCityLightOutage #SCLOutage{} #{}".format( + neighborhood_text, city.title().replace(" ", "") + ) return hashtag_string @@ -189,22 +205,27 @@ def do_initial_post( city_not_seattle_text, ) area_text = "the {} area{}".format(locality, city_not_seattle_text) + event["neighborhood"] = locality elif "district" in geocode["features"][0]["properties"]["geocoding"]: + district = geocode["features"][0]["properties"]["geocoding"]["district"] alt_text = "A map showing the location of the outage, centered around {} in the {} area{}.".format( street, - geocode["features"][0]["properties"]["geocoding"]["district"], + district, city_not_seattle_text, ) area_text = "the {} area{}".format( - geocode["features"][0]["properties"]["geocoding"]["district"], + district, city_not_seattle_text, ) + event["neighborhood"] = district else: + city = geocode["features"][0]["properties"]["geocoding"]["city"] alt_text = "A map showing the location of the outage, centered around {} in {}.".format( street, - geocode["features"][0]["properties"]["geocoding"]["city"], + city, ) - area_text = geocode["features"][0]["properties"]["geocoding"]["city"] + area_text = city + event["geoloc_city"] = city except Exception: alt_text = "A map showing the location of the outage." -- 2.45.2 From ac10d50db235d3941ff3eff84b34c084d8ec27c3 Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Sat, 20 Apr 2024 16:53:08 -0700 Subject: [PATCH 3/4] Fix neighborhood string formatting --- scl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scl.py b/scl.py index 5faf0d8..d69be4a 100644 --- a/scl.py +++ b/scl.py @@ -109,7 +109,7 @@ def get_hashtag_string(event) -> str: try: neighborhood = event["neighborhood"] if neighborhood != city: - neighborhood_text = " #{}".format(neighborhood).title().replace(" ", "") + neighborhood_text = " #{}".format(neighborhood.title().replace(" ", "")) except KeyError: pass -- 2.45.2 From d6de76377f62c86b64c849a9217fea22a7951dd4 Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Sat, 20 Apr 2024 17:14:14 -0700 Subject: [PATCH 4/4] Set geoloc_city one level up so it's always set --- scl.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scl.py b/scl.py index d69be4a..2796837 100644 --- a/scl.py +++ b/scl.py @@ -182,15 +182,15 @@ def do_initial_post( print("JSON could not be loaded from nominatim API") raise - if geocode["features"][0]["properties"]["geocoding"]["city"] != "Seattle": - city_not_seattle_text = " of {}".format( - geocode["features"][0]["properties"]["geocoding"]["city"] - ) + city = geocode["features"][0]["properties"]["geocoding"]["city"] + street = geocode["features"][0]["properties"]["geocoding"]["name"] + event["geoloc_city"] = city + + if city != "Seattle": + city_not_seattle_text = " of {}".format(city) else: city_not_seattle_text = "" - street = geocode["features"][0]["properties"]["geocoding"]["name"] - if ( "locality" in geocode["features"][0]["properties"]["geocoding"] and event_class["size"] != "Large" @@ -219,13 +219,11 @@ def do_initial_post( ) event["neighborhood"] = district else: - city = geocode["features"][0]["properties"]["geocoding"]["city"] alt_text = "A map showing the location of the outage, centered around {} in {}.".format( street, city, ) area_text = city - event["geoloc_city"] = city except Exception: alt_text = "A map showing the location of the outage." -- 2.45.2