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

OKRS24-94 #1402

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/server/endpoints/covidcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ def handle_export():
start_day, is_day = start_time_set.time_values[0], start_time_set.is_day
end_time_set = parse_day_or_week_arg("end_day", 202020 if weekly_signals > 0 else 20200901)
end_day, is_end_day = end_time_set.time_values[0], end_time_set.is_day

format_date = time_value_to_iso if is_day else lambda x: time_value_to_week(x).cdcformat()

try:
formatted_start_day = format_date(start_day)
formatted_end_day = format_date(end_day)
except ValueError as e:
raise ValidationFailedException("Invalid date format: " + str(e))

if is_day != is_end_day:
raise ValidationFailedException("mixing weeks with day arguments")
_verify_argument_time_type_matches(is_day, daily_signals, weekly_signals)
Expand All @@ -268,10 +277,9 @@ def handle_export():

q.apply_as_of_filter(history_table, as_of)

format_date = time_value_to_iso if is_day else lambda x: time_value_to_week(x).cdcformat()
# tag as_of in filename, if it was specified
as_of_str = "-asof-{as_of}".format(as_of=format_date(as_of)) if as_of is not None else ""
filename = "covidcast-{source}-{signal}-{start_day}-to-{end_day}{as_of}".format(source=source, signal=signal, start_day=format_date(start_day), end_day=format_date(end_day), as_of=as_of_str)
filename = "covidcast-{source}-{signal}-{start_day}-to-{end_day}{as_of}".format(source=source, signal=signal, start_day=formatted_start_day, end_day=formatted_end_day, as_of=as_of_str)
p = CSVPrinter(filename)

def parse_row(i, row):
Expand Down
Loading