@@ -193,7 +193,10 @@ def handle_trend():
193
193
_verify_argument_time_type_matches (is_day , daily_signals , weekly_signals )
194
194
basis_time_value = extract_date ("basis" )
195
195
if basis_time_value is None :
196
- basis_time_value = shift_time_value (time_value , - 7 ) if is_day else shift_week_value (time_value , - 7 )
196
+ base_shift = extract_integer ("basis_shift" )
197
+ if base_shift is None :
198
+ base_shift = 7
199
+ basis_time_value = shift_time_value (time_value , - 1 * base_shift ) if is_day else shift_week_value (time_value , - 1 * base_shift )
197
200
198
201
# build query
199
202
q = QueryBuilder ("covidcast" , "t" )
@@ -241,11 +244,10 @@ def handle_trendseries():
241
244
242
245
time_window , is_day = parse_day_or_week_range_arg ("window" )
243
246
_verify_argument_time_type_matches (is_day , daily_signals , weekly_signals )
244
- basis_shift = extract_integer ("basis" )
247
+ basis_shift = extract_integer (( "basis" , "basis_shift" ) )
245
248
if basis_shift is None :
246
249
basis_shift = 7
247
250
248
-
249
251
# build query
250
252
q = QueryBuilder ("covidcast" , "t" )
251
253
@@ -369,7 +371,7 @@ def handle_export():
369
371
daily_signals , weekly_signals = count_signal_time_types (source_signal_pairs )
370
372
source_signal_pairs , alias_mapper = create_source_signal_alias_mapper (source_signal_pairs )
371
373
start_day , is_day = parse_day_or_week_arg ("start_day" , 202001 if weekly_signals > 0 else 20200401 )
372
- end_day , is_end_day = parse_day_or_week_arg ("end_day" , 202020 if weekly_signals > 0 else 20200901 )
374
+ end_day , is_end_day = parse_day_or_week_arg ("end_day" , 202020 if weekly_signals > 0 else 20200901 )
373
375
if is_day != is_end_day :
374
376
raise ValidationFailedException ("mixing weeks with day arguments" )
375
377
_verify_argument_time_type_matches (is_day , daily_signals , weekly_signals )
@@ -380,7 +382,7 @@ def handle_export():
380
382
if geo_values != "*" :
381
383
geo_values = geo_values .split ("," )
382
384
383
- as_of , is_as_of_day = parse_day_or_week_arg (' as_of' ) if ' as_of' in request .args else (None , is_day )
385
+ as_of , is_as_of_day = parse_day_or_week_arg (" as_of" ) if " as_of" in request .args else (None , is_day )
384
386
if is_day != is_as_of_day :
385
387
raise ValidationFailedException ("mixing weeks with day arguments" )
386
388
@@ -390,7 +392,7 @@ def handle_export():
390
392
q .set_fields (["geo_value" , "signal" , "time_value" , "issue" , "lag" , "value" , "stderr" , "sample_size" , "geo_type" , "source" ], [], [])
391
393
q .set_order ("time_value" , "geo_value" )
392
394
q .where_source_signal_pairs ("source" , "signal" , source_signal_pairs )
393
- q .where_time_pairs ("time_type" , "time_value" , [TimePair (' day' if is_day else ' week' , [(start_day , end_day )])])
395
+ q .where_time_pairs ("time_type" , "time_value" , [TimePair (" day" if is_day else " week" , [(start_day , end_day )])])
394
396
q .where_geo_pairs ("geo_type" , "geo_value" , [GeoPair (geo_type , True if geo_values == "*" else geo_values )])
395
397
396
398
_handle_lag_issues_as_of (q , None , None , as_of )
0 commit comments