Skip to content

Commit

Permalink
Fix bug with failing to restore bid budgets snapshots
Browse files Browse the repository at this point in the history
If snapshots are missing for more than 28 days, restore then only for 28 days

Change-Id: Ic071c184c56cfde453f3818d01a3ae453010e997
  • Loading branch information
AVMarkin committed Sep 11, 2024
1 parent 55669b5 commit bba7969
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/scripts/backfill_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,16 @@ def _get_bid_budget_snapshot_dates(
)
""",
)
if not result:
today = datetime.datetime.today()
end_date = today - datetime.timedelta(days=1)
start_date = today - datetime.timedelta(days=28)
return {
date.strftime('%Y-%m-%d')
for date in pd.date_range(start_date, end_date).to_pydatetime().tolist()
}
return set(result['day'])

except bq_executor.BigQueryExecutorException:
logging.error('Fail to find bid_budget snapshots')
return set()
Expand Down Expand Up @@ -531,9 +540,7 @@ def main():
bigquery_executor, bq_dataset
)
):
for table_id, query in restore_missing_cohorts(
snapshot_dates, bq_dataset
):
for table_id, query in restore_missing_cohorts(snapshot_dates, bq_dataset):
save_restored_asset_cohort(bigquery_executor, query, table_id)


Expand Down

0 comments on commit bba7969

Please sign in to comment.