Skip to content

Commit

Permalink
fix: fetch data from up to 5 days ago
Browse files Browse the repository at this point in the history
  • Loading branch information
andylolz committed Jul 31, 2024
1 parent 86ff73d commit d9dd2ed
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions x_notes/tsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ def _data_generator() -> Generator:


def get_generator(fname: str, index: int = 0) -> Generator:
num_days_ago_to_try = 5
today = date.today()
try:
return get_data(today, fname, index)
except Exception:
pass
yesterday = today - timedelta(days=1)
return get_data(yesterday, fname, index)
for n in range(num_days_ago_to_try + 1):
try:
n_days_ago = today - timedelta(days=n)
return get_data(n_days_ago, fname, index)
except Exception:
pass

0 comments on commit d9dd2ed

Please sign in to comment.