Skip to content

Commit

Permalink
Merge branch 'main' of github.com:openpodcast/pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
mre committed Jan 10, 2024
2 parents 844fabc + 1026cb3 commit 9cce5db
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apple/job/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@
)
END_DATE = load_env("END_DATE", (dt.datetime.now()).strftime("%Y-%m-%d"))

# Due to weird behaviour of the Apple API when fetching just a few days,
# extend the date range to 30 days if shorter
if (dt.datetime.strptime(END_DATE, "%Y-%m-%d") - dt.datetime.strptime(START_DATE, "%Y-%m-%d")).days < 30:
START_DATE = (dt.datetime.strptime(END_DATE, "%Y-%m-%d") -
dt.timedelta(days=30)).strftime("%Y-%m-%d")
print(
f"Date range too short, extending to 30 days. New start date: {START_DATE}")

# The trends API supports historical data imports with daily resolution
# up to 4 months in the past.
# If we want to import a longer date-range, we split the date range into chunks
Expand Down

0 comments on commit 9cce5db

Please sign in to comment.