"""
https://docs.celeryq.dev/en/stable/django/first-steps-with-django.html
"""

import os

from celery import Celery

from django.conf import settings
from celery.schedules import crontab

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "caracole_ph_api.settings")

app = Celery("caracole_ph_api")
app.config_from_object("django.conf:settings", namespace="CELERY")

app.conf.beat_schedule = {
    "monthly_delete_archived_products": {
        "task": "products.tasks.delete_archived_products",
        "schedule": crontab(day_of_month=1, hour=0, minute=0),
    }
}

# discover and load tasks.py from from all registered Django apps
# app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.autodiscover_tasks()

# Define the periodic task
app.conf.update()
