bullish/backend/app/apps.py
Ameya Shenoy bc21b1c6db
fix: cronjob to only run on weekdays
Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
2021-02-14 23:15:00 +05:30

30 lines
702 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Initializer and scheduling done here."""
# third-party imports
import django_rq
from django.apps import AppConfig
class AppConfig(AppConfig):
name = 'app'
def ready(self):
from app.utils import populate_bhav_copy_data
# This is necessary to prevent dupes
scheduler = django_rq.get_scheduler('default')
# Delete any existing jobs in the scheduler when the app starts up
for job in scheduler.get_jobs():
job.delete()
# Schedule jobs here as required
scheduler.cron(
"0 6 * * 1-5",
func=populate_bhav_copy_data,
repeat=None,
)