from celery import shared_task

from .workflows import prepare_due_notifications, retry_failed_notifications, send_scheduled_notifications


@shared_task(name="notifications.prepare_due_notifications")
def prepare_due_notifications_task():
    return prepare_due_notifications(send=False, automatic=True)


@shared_task(name="notifications.send_scheduled_notifications")
def send_scheduled_notifications_task():
    return send_scheduled_notifications()


@shared_task(name="notifications.retry_failed_notifications")
def retry_failed_notifications_task():
    return retry_failed_notifications()


@shared_task(name="notifications.daily_notification_cycle")
def daily_notification_cycle_task():
    prepared = prepare_due_notifications(send=False, automatic=True)
    sent = send_scheduled_notifications()
    retried = retry_failed_notifications()
    return {"prepared": prepared, "scheduled": sent, "retried": retried}
