import os
from celery import Celery
from celery.schedules import crontab

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'musee_mcn.settings_production')

app = Celery('musee_mcn')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

# Beat schedule
app.conf.beat_schedule = {
    'generate-daily-stats': {
        'task': 'artworks.tasks.generate_daily_statistics',
        'schedule': crontab(hour=2, minute=0),
    },
    'send-daily-report': {
        'task': 'artworks.tasks.send_daily_report',
        'schedule': crontab(hour=8, minute=0),
    },
    'cleanup-old-visits': {
        'task': 'artworks.tasks.cleanup_old_visits',
        'schedule': crontab(hour=3, minute=0, day_of_week=0),
    },
    'warm-cache': {
        'task': 'artworks.tasks.warm_cache',
        'schedule': crontab(minute=0),
    },
}