Reverse best place type selection logic#6421
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where incorrect place type selection was causing display problems in explore pages and map tools. By reversing the sorting logic for place types, the system now correctly prioritizes more specific classifications (like City or State) over generic ones (like Place), ensuring consistent data rendering even when multiple types are associated with a single entity. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the _get_best_type helper function in server/services/datacommons.py to prioritize more specific place types (lower non-zero ranks) and place unrecognized types last, updating the associated unit tests accordingly. Feedback on this change points out a typo in the updated docstring and suggests using min() instead of sorted() to find the best type more efficiently in O(N) time.
juliawu
left a comment
There was a problem hiding this comment.
Thank you for also updating the docstring and tests!
Issue
b/530339277
Description
This issue manifests in two places: maps being dropped in explore pages (just showing ranking charts), and the map tool being unable to load charts for certain places.
This can be seen at the following link:
https://dev.datacommons.org/tools/map#%26sv%3DUnemploymentRate_Person%26pc%3D0%26denom%3DCount_Person%26pd%3DgeoId%2F34%26ept%3DCounty
The problem became symptomatic with the introduction of a data problem: places like the US, Canada, New Jersey now have "Place" as a placeType in addition to "Country", "Country" and "State" respectively.
While this data ingestion issue needs to be separately fixed, it highlighted an issue in the way that website prioritized order.