bullish/backend/app/apps.py
Ameya Shenoy d8c78bd111
feat: get rq working and schedule job at 6
Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
2021-02-09 18:00:52 +05:30

36 lines
915 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Initializer and scheduling done here."""
# standard imports
import datetime
import logging
# third-party imports
import django_rq
from django.apps import AppConfig
from django_rq.management.commands import rqscheduler
class AppConfig(AppConfig):
name = 'app'
def ready(self):
from app.utils import populate_bhav_copy_data, get_next_update_datetime
# 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
next_date_time = get_next_update_datetime()
scheduler.schedule(
scheduled_time=next_date_time, # UTC
func=populate_bhav_copy_data,
interval=86400,
)