
import os
from celery import Celery
from django.conf import settings

# Set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project.settings.production')

app = Celery('optinet_system')

# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
app.config_from_object('django.conf:settings', namespace='CELERY')

# Load task modules from all registered Django apps.
app.autodiscover_tasks()

# Celery Beat Schedule
app.conf.beat_schedule = {
    'process-customer-service-statuses': {
        'task': 'customers.tasks.process_customer_service_statuses',
        'schedule': 3600.0,  # Run every hour
    },
    'send-daily-reminders': {
        'task': 'customers.tasks.send_daily_reminders',
        'schedule': 86400.0,  # Run every 24 hours
    },
}

app.conf.timezone = 'Africa/Nairobi'

@app.task(bind=True)
def debug_task(self):
    print(f'Request: {self.request!r}')
