[preview] Add `preview --num-days=N` to extend preview time window.

In the future, we might teach the preview window computation to
consider `window_size` for relevant alerts such as those with `type =
"avg_diff"`.
This commit is contained in:
Nick Alexander 2022-11-22 15:33:13 -08:00 коммит произвёл Anna Scholtz
Родитель 45f1fde118
Коммит 2360578bd9
1 изменённых файлов: 15 добавлений и 6 удалений

Просмотреть файл

@ -457,6 +457,13 @@ def backfill(
metavar="YYYY-MM-DD",
required=False,
)
@click.option(
"--num-days",
"--num-days",
type=int,
help="Number of days for which the project be analyzed. Default: 3",
default=3,
)
@click.option(
"--slug",
help="Experimenter or Normandy slug associated with the project to create a preview for",
@ -478,6 +485,7 @@ def preview(
derived_dataset_id,
start_date,
end_date,
num_days,
slug,
config_file,
config_repos,
@ -485,16 +493,17 @@ def preview(
):
"""Create a preview for a specific project based on a subset of data."""
if start_date is None and end_date is None:
start_date = datetime.today() - timedelta(days=3)
start_date = datetime.today() - timedelta(days=num_days)
end_date = datetime.today() - timedelta(days=1)
start_date = pytz.utc.localize(start_date)
end_date = pytz.utc.localize(end_date)
elif start_date is None:
start_date = end_date - timedelta(days=3)
start_date = pytz.utc.localize(start_date)
elif end_date is None:
end_date = start_date + timedelta(days=3)
end_date = pytz.utc.localize(end_date)
start_date = end_date - timedelta(days=num_days)
else:
end_date = start_date + timedelta(days=num_days)
start_date = pytz.utc.localize(start_date)
end_date = pytz.utc.localize(end_date)
table = bq_normalize_name(slug)