Skip to content

Commit

Permalink
fix: added country to search endpoint response
Browse files Browse the repository at this point in the history
  • Loading branch information
cka-y committed Aug 9, 2024
1 parent 799fd33 commit f73fc30
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/src/feeds/impl/models/search_feed_item_result_impl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from feeds_gen.models.latest_dataset import LatestDataset
from feeds_gen.models.search_feed_item_result import SearchFeedItemResult
from feeds_gen.models.source_info import SourceInfo
import pycountry


class SearchFeedItemResultImpl(SearchFeedItemResult):
Expand Down Expand Up @@ -83,6 +84,8 @@ def _translate_locations(cls, feed_search_row):

for location in feed_search_row.locations:
location["country"] = country_translations.get(location["country"], location["country"])
if location["country"] is None:
location["country"] = pycountry.countries.get(alpha_2=location["country_code"]).name
location["subdivision_name"] = subdivision_translations.get(
location["subdivision_name"], location["subdivision_name"]
)
Expand Down

0 comments on commit f73fc30

Please sign in to comment.