Skip to content

Quoted date string when fetching obserations#1459

Merged
dwnoble merged 1 commit intodatacommonsorg:masterfrom
dwnoble:fix-fetch-observations-date-with-month
Nov 18, 2024
Merged

Quoted date string when fetching obserations#1459
dwnoble merged 1 commit intodatacommonsorg:masterfrom
dwnoble:fix-fetch-observations-date-with-month

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
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