import os

from celery import Celery
from celery.schedules import crontab

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

app = Celery("news")

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

app.autodiscover_tasks()


@app.task(bind=True)
def debug_task(self):
    print(f"Request: {self.request!r}")


app.conf.beat_schedule = {
    "reset-upvotes": {
        "task": "posts.tasks.reset_upvotes",
        "schedule": crontab(minute=0, hour=0),
    }
}
