diff --git a/server/routes/dev_place/api.py b/server/routes/dev_place/api.py index 882d4456e5..81fd62c8f3 100644 --- a/server/routes/dev_place/api.py +++ b/server/routes/dev_place/api.py @@ -160,9 +160,21 @@ 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 not all_place_by_dcid[dcid].dissolved + ] + similar_places = [ + all_place_by_dcid[dcid] + for dcid in similar_place_dcids + if not all_place_by_dcid[dcid].dissolved + ] + child_places = [ + all_place_by_dcid[dcid] + for dcid in child_place_dcids + if not all_place_by_dcid[dcid].dissolved + ] response = RelatedPlacesApiResponse(childPlaceType=child_place_type, childPlaces=child_places, diff --git a/server/routes/dev_place/types.py b/server/routes/dev_place/types.py index 4cdedbf45b..ab15849575 100644 --- a/server/routes/dev_place/types.py +++ b/server/routes/dev_place/types.py @@ -46,6 +46,7 @@ class Place: dcid: str name: str types: List[str] + dissolved: bool = False @dataclass diff --git a/server/routes/dev_place/utils.py b/server/routes/dev_place/utils.py index a6152362d5..bf7cc0f84e 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') @@ -247,11 +247,16 @@ def fetch_places(place_dcids: List[str], locale=DEFAULT_LOCALE) -> List[Place]: place_names = place_props.get('name', []) default_name = place_names[0] if place_names else place_dcid + dissolved = bool(place_props.get('dissolutionDate')) place_types = place_props.get('typeOf', []) # Use the name with locale if available, otherwise fall back to the default ('en') name name = name_with_locale or default_name - places.append(Place(dcid=place_dcid, name=name, types=place_types)) + places.append( + Place(dcid=place_dcid, + name=name, + types=place_types, + dissolved=dissolved)) return places