import os
from celery import Celery
from celery.schedules import crontab

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')

app = Celery('daleeli_backend')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

# Celery Beat Schedule
app.conf.beat_schedule = {
    'schedule-booking-reminders': {
        'task': 'notifications.tasks.schedule_booking_reminders',
        'schedule': crontab(hour=0, minute=0),  # Daily at midnight
    },
    'check-expired-offers': {
        'task': 'notifications.tasks.check_expired_offers',
        'schedule': crontab(hour=1, minute=0),  # Daily at 1 AM
    },
}

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

