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

Add min_issue to metadata #1413

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
22 changes: 13 additions & 9 deletions docs/api/covidcast_meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ None required.
| `epidata[].max_value` | maximum value | float |
| `epidata[].mean_value` | mean of value | float |
| `epidata[].stdev_value` | standard deviation of value | float |
| `epidata[].min_issue` | oldest date data was issued (e.g., 20200710) | integer |
| `epidata[].max_issue` | most recent date data was issued (e.g., 20200710) | integer |
| `epidata[].min_lag` | smallest lag from observation to issue, in `time_type` units | integer |
| `epidata[].max_lag` | largest lag from observation to issue, in `time_type` units | integer |
Expand All @@ -51,19 +52,22 @@ https://api.delphi.cmu.edu/epidata/covidcast_meta/
{
"result": 1,
"epidata": [
{
{
"data_source": "doctor-visits",
"signal": "smoothed_adj_cli",
"last_update": 1592707979,
"stdev_value": 2.6647410028331,
"num_locations": 2500,
"time_type": "day",
"max_value": 87.190476,
"mean_value": 1.4439366759191,
"geo_type": "county",
"min_value": 0,
"max_time": 20200617,
"min_time": 20200201
"min_time": 20200201,
"max_time": 20240321,
"num_locations": 2586,
"min_value": 0.0,
"max_value": 87.670832,
"mean_value": 2.4972178,
"stdev_value": 3.6433783,
"last_update": 1711412545,
"max_issue": 20240325,
nmdefries marked this conversation as resolved.
Show resolved Hide resolved
"min_lag": 2,
"max_lag": 129
},
...
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def test_caching(self):
'max_value': 1,
'mean_value': 1,
'stdev_value': 0,
'min_issue': 20200422,
'max_issue': 20200423,
'min_lag': 0,
'max_lag': 1,
Expand Down
26 changes: 13 additions & 13 deletions integrations/client/test_delphi_epidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,14 @@ def test_covidcast_meta(self):
# 1st issue: 0 10 20
# 2nd issue: 1 11 21
# 3rd issue: 2 12 22
rows = [
CovidcastTestRow.make_default_row(
time_value=DEFAULT_TIME_VALUE + t,
issue=DEFAULT_ISSUE + i,
value=t*10 + i
)
for i in range(3) for t in range(3)
]
self._insert_rows(rows)
for i in range(3):
for t in range(3):
row = CovidcastTestRow.make_default_row(
time_value=DEFAULT_TIME_VALUE + t,
issue=DEFAULT_ISSUE + i,
value=t*10 + i
)
self._insert_rows([row])
nmdefries marked this conversation as resolved.
Show resolved Hide resolved

# cache it
update_covidcast_meta_cache(args=None)
Expand All @@ -308,17 +307,18 @@ def test_covidcast_meta(self):
del response['epidata'][0]['last_update']

expected = dict(
data_source=rows[0].source,
signal=rows[0].signal,
time_type=rows[0].time_type,
geo_type=rows[0].geo_type,
data_source=row.source,
signal=row.signal,
time_type=row.time_type,
geo_type=row.geo_type,
min_time=DEFAULT_TIME_VALUE,
max_time=DEFAULT_TIME_VALUE + 2,
num_locations=1,
min_value=2.,
mean_value=12.,
max_value=22.,
stdev_value=8.1649658, # population stdev, not sample, which is 10.
min_issue=DEFAULT_ISSUE,
max_issue=DEFAULT_ISSUE + 2,
min_lag=0,
max_lag=0, # we didn't set lag when inputting data
Expand Down
1 change: 1 addition & 0 deletions integrations/server/test_covidcast_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def insert_placeholder_data(self):
'mean_value': 15,
'stdev_value': 5,
'last_update': 123,
'min_issue': 1,
'max_issue': 2,
'min_lag': 0,
'max_lag': 0,
Expand Down
1 change: 1 addition & 0 deletions src/acquisition/covidcast/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ def compute_covidcast_meta(self, table_name=None, n_threads=None):
ROUND(AVG(`value`),7) AS `mean_value`,
ROUND(STD(`value`),7) AS `stdev_value`,
MAX(`value_updated_timestamp`) AS `last_update`,
MIN(`issue`) as `min_issue`,
MAX(`issue`) as `max_issue`,
MIN(`lag`) as `min_lag`,
MAX(`lag`) as `max_lag`
Expand Down
Loading