"""
Celery Beat schedule configuration for periodic tasks.
Import this in your Django settings.
"""
from celery.schedules import crontab

CELERY_BEAT_SCHEDULE = {
    # Collect all system metrics every minute
    'collect-system-metrics': {
        'task': 'monitoring.collect_system_metrics',
        'schedule': 60.0,  # Every 60 seconds
        'options': {'queue': 'monitoring'}
    },
    
    # Collect error metrics every minute
    'collect-error-metrics': {
        'task': 'monitoring.collect_error_metrics',
        'schedule': 60.0,
        'options': {'queue': 'monitoring'}
    },
    
    # Collect performance metrics every minute
    'collect-performance-metrics': {
        'task': 'monitoring.collect_performance_metrics',
        'schedule': 60.0,
        'options': {'queue': 'monitoring'}
    },
    
    # Collect queue metrics every 30 seconds
    'collect-queue-metrics': {
        'task': 'monitoring.collect_queue_metrics',
        'schedule': 30.0,
        'options': {'queue': 'monitoring'}
    },
    
    # Data retention cleanup tasks
    'run-data-retention-cleanup': {
        'task': 'monitoring.run_data_retention_cleanup',
        'schedule': crontab(hour=3, minute=0),  # Daily at 3 AM
        'options': {'queue': 'maintenance'}
    },
    
    'cleanup-old-metrics': {
        'task': 'monitoring.cleanup_old_metrics',
        'schedule': crontab(hour=3, minute=30),  # Daily at 3:30 AM
        'options': {'queue': 'maintenance'}
    },
    
    'cleanup-old-anomalies': {
        'task': 'monitoring.cleanup_old_anomalies',
        'schedule': crontab(hour=4, minute=0),  # Daily at 4 AM
        'options': {'queue': 'maintenance'}
    },
    
    # Existing user tasks
    'cleanup-expired-tokens': {
        'task': 'users.cleanup_expired_tokens',
        'schedule': crontab(hour='*/6', minute=0),  # Every 6 hours
        'options': {'queue': 'maintenance'}
    },
    
    'cleanup-inactive-users': {
        'task': 'users.cleanup_inactive_users',
        'schedule': crontab(hour=2, minute=0, day_of_week=1),  # Weekly on Monday at 2 AM
        'options': {'queue': 'maintenance'}
    },
    
    'update-user-statistics': {
        'task': 'users.update_user_statistics',
        'schedule': crontab(hour='*', minute=0),  # Every hour
        'options': {'queue': 'analytics'}
    },
}
