act-now-coalition / covid-data-model

Data backend providing computed data for the graphs displayed at https://covidactnow.org
https://covidactnow.org/
MIT License
149 stars 57 forks source link

Add community levels to API #1275

Closed mikelehen closed 2 years ago

mikelehen commented 2 years ago

Wires up communityLevels.cdcCommunityLevel and communityLevels.canCommunityLevel.

All of the changes (except my last commit to ffill() the metrics before calculating canCommunityLevel) are in this snapshot which is visible at https://covid-projections-git-mikelehen-wire-up-comm-a4e145-covidactnow.vercel.app/?s=31461972.

The ffill() change was validated locally with ./run.py api generate-api-v2 --state ID output output/api. An example county with the change in effect can be found here where you'll see communityLevelTimeseries.canCommunityLevel has no gaps since we're forward-filling the nans in the metrics.

mikelehen commented 2 years ago

Add CDC Community Level-related metrics to API.

smcclure17 commented 2 years ago

Let me know if I'm missing something, but I don't seem to see any data for these columns under the csv timeseries: https://data.covidactnow.org/snapshot/3150/v2/states.timeseries.csv https://data.covidactnow.org/snapshot/3150/v2/counties.timeseries.csv https://data.covidactnow.org/snapshot/3150/v2/county/MA.timeseries.json

Edit:

I think maybe we need to add

communityLevels: CommunityLevels = pydantic.Field(...)

to RegionTimeseriesRowWithHeader in api/can_api_v2_definition.py similar to how cdcTransmissionLevel is added, but I'm not 100% sure

mikelehen commented 2 years ago

Hrm. You don't seem to be missing something. Good catch! I'll take a look. It also looks like the full API build failed to generate some endpoints properly, e.g. county data for DC and MP.

smcclure17 commented 2 years ago

Oh huh, I wonder if that has to do with HSAs--I don't think MP counties are mapped to HSA (I don't know about DC) so I wonder if that might be causing a problem. This could be an issue not with this PR specifically, but the new metrics using HSA data