Skip to content

Commit

Permalink
update scheduler times for data
Browse files Browse the repository at this point in the history
  • Loading branch information
vantage-ola committed Aug 26, 2024
1 parent 2c8163e commit 80a7431
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tracknow/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ def create_app(config_class='config.Config'):

scheduler = BackgroundScheduler()

trigger = CronTrigger(day_of_week='*', hour=18, minute=0, timezone=timezone.utc)
scheduler.add_job(update_f1_standings, trigger)
scheduler.add_job(update_youtube_data, trigger)
# Update Formula 1 standings every Sunday at 3:45 PM and every day at 12:00 AM
f1_trigger = CronTrigger(day_of_week='sun', hour=15, minute=45, timezone=timezone.utc)
trigger_daily = CronTrigger(hour=0, minute=0, timezone=timezone.utc)

scheduler.add_job(update_f1_standings, f1_trigger)
scheduler.add_job(update_f1_standings, trigger_daily)
scheduler.add_job(update_youtube_data, trigger_daily)

# Start the scheduler
scheduler.start()
Expand All @@ -73,6 +77,7 @@ def update_f1_standings():

driver_data = get_driver_standings()
r.set(f"f1_drivers_{current_year}", json.dumps(driver_data))
print(f"{current_year} standings updated !")

def update_youtube_data():
r = redis_instance()
Expand All @@ -81,6 +86,7 @@ def update_youtube_data():
youtube_data = youtube_results()

r.set(f"youtube_data_{today_date}", json.dumps(youtube_data))
print(f"{today_date} youtube data updated !")

app = create_app()

Expand Down

0 comments on commit 80a7431

Please sign in to comment.