Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quoted date string when fetching obserations #1459

Merged

Conversation

dwnoble
Copy link
Contributor

@dwnoble dwnoble commented Nov 18, 2024

This fixes a bug where requesting observations for a date that contains a hyphen (Example: 2024-09) would return an empty result set.

Before:

curl -XPOST "http://localhost:8080/core/api/v2/observation" -d '
{
     "select": [
         "date",
         "value",
         "variable",
         "entity"
     ],
     "entity": {
         "expression": "country/USA<-containedInPlace+{typeOf:State}"
     },
     "variable": {
         "dcids": [
             "Count_SubsidizedHousingUnit"
         ]
     },
     "date": "2023-12-31"
}
'

Returns

{"byVariable":{"Count_SubsidizedHousingUnit":{}}}

After:

Returns

{"byVariable":{"Count_SubsidizedHousingUnit":{"byEntity":{"geoId/40":{"orderedFacets":[{"facetId":"4243125145","observations":[{"date":"2023-12-31","value":53562}],"obsCount":1,"earliestDate":"2023-12-31","latestDate":"2023-12-31"}]},"geoId/41":{"orderedFacets":[{"facetId":"4243125145","observations":[{"date":"2023-12-31","value":57113}],"obsCount":1,"earliestDate":"2023-12-31","latestDate":"2023-12-31"}]},"geoId/02":{"orderedFacets":[{"facetId":"4243125145","observations":[{"date":"2023-12-31","value":7962}],"obsCount":1,"earliestDate":"2023-12-31","latestDate":"2023-12-31"}]}, ... }}

TODO: Add test cases

@dwnoble dwnoble requested a review from keyurva November 18, 2024 23:47
Copy link
Contributor

@keyurva keyurva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dan!

The fix may be a 1-liner but involved a ton of digging and troubleshooting. Thanks for figuring it out.

Tests in a follow-up PR SG.

@dwnoble dwnoble merged commit 3518530 into datacommonsorg:master Nov 18, 2024
3 checks passed
@dwnoble
Copy link
Contributor Author

dwnoble commented Nov 19, 2024

Thanks @keyurva ! here are the test cases: #1460

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants