Skip to content

Commit

Permalink
Filters out deprecated places from the fetch_places helper method.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmechali committed Dec 9, 2024
1 parent a38ca26 commit ddf2b3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions server/routes/dev_place/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion server/routes/dev_place/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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

Expand Down

0 comments on commit ddf2b3b

Please sign in to comment.