Files
KeepItGoingServer/config/celery.py
T
Keith SmithandClaude Sonnet 4.5 aca8abca56 Fix daily email timing to work across all timezones
Critical fix: Task now runs every hour instead of once at 6 AM UTC.
This ensures users in all timezones receive their email at 6 AM local time.

Changes:
- Run task every hour instead of once daily
- Check if it's 6-7 AM in user's timezone (1 hour window)
- Track sent emails in Notification model to prevent duplicates
- Add 'daily_email' notification type

Without this fix, users in timezones where 6 AM UTC is not morning
would never receive their daily email.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-09 09:34:39 -07:00

39 lines
983 B
Python

"""
Celery configuration for KeepItGoing.
"""
import logging
import os
from celery import Celery
from celery.schedules import crontab
logger = logging.getLogger(__name__)
# Set the default Django settings module
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
app = Celery('keepitgoing')
# Load config from Django settings
app.config_from_object('django.conf:settings', namespace='CELERY')
# Auto-discover tasks in all installed apps
app.autodiscover_tasks()
# Celery Beat schedule for periodic tasks
app.conf.beat_schedule = {
'send-daily-task-email': {
'task': 'notifications.tasks.send_daily_task_email',
'schedule': crontab(minute=0), # Every hour on the hour
},
'process-recurring-tasks': {
'task': 'notifications.tasks.process_recurring_tasks',
'schedule': crontab(hour=0, minute=0), # Daily at midnight
},
}
@app.task(bind=True)
def debug_task(self):
logger.debug(f'Request: {self.request!r}')