diff --git a/server/routes/dev_place/api.py b/server/routes/dev_place/api.py index 882d4456e5..e0b61d2875 100644 --- a/server/routes/dev_place/api.py +++ b/server/routes/dev_place/api.py @@ -160,9 +160,9 @@ def related_places(place_dcid: str): # Get place objects for nearby, similar, and child places all_place_by_dcid = {p.dcid: p for p in all_places} - nearby_places = [all_place_by_dcid[dcid] for dcid in nearby_place_dcids] - similar_places = [all_place_by_dcid[dcid] for dcid in similar_place_dcids] - child_places = [all_place_by_dcid[dcid] for dcid in child_place_dcids] + nearby_places = [all_place_by_dcid[dcid] for dcid in nearby_place_dcids if dcid in all_place_by_dcid] + similar_places = [all_place_by_dcid[dcid] for dcid in similar_place_dcids if dcid in all_place_by_dcid] + child_places = [all_place_by_dcid[dcid] for dcid in child_place_dcids if dcid in all_place_by_dcid] response = RelatedPlacesApiResponse(childPlaceType=child_place_type, childPlaces=child_places, diff --git a/server/routes/dev_place/utils.py b/server/routes/dev_place/utils.py index 92619e760b..f977264f69 100644 --- a/server/routes/dev_place/utils.py +++ b/server/routes/dev_place/utils.py @@ -232,7 +232,7 @@ def fetch_places(place_dcids: List[str], locale=DEFAULT_LOCALE) -> List[Place]: Returns: List[Place]: A list of Place objects with names in the specified locale. """ - props = ['typeOf', 'name'] + props = ['typeOf', 'name', 'dissolutionDate'] # Only fetch names with locale-specific tags if the desired locale is non-english if locale != DEFAULT_LOCALE: props.append('nameWithLanguage') @@ -245,6 +245,10 @@ def fetch_places(place_dcids: List[str], locale=DEFAULT_LOCALE) -> List[Place]: name_with_locale = select_string_with_locale(place_name_with_languages_strs, locale=locale) + if place_props.get('dissolutionDate', []): + # skip places that have a dissolution date. + continue + place_names = place_props.get('name', []) default_name = place_names[0] if place_names else place_dcid