2024-07-20 12:16:46 +02:00
|
|
|
"""task model"""
|
|
|
|
|
|
|
|
from django.db import models
|
2024-08-23 21:13:00 +02:00
|
|
|
from django_celery_beat.models import PeriodicTask, cronexp
|
2024-07-20 12:16:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
class CustomPeriodicTask(PeriodicTask):
|
|
|
|
"""add custom metadata to task"""
|
|
|
|
|
|
|
|
task_config = models.JSONField(default=dict)
|
2024-08-23 21:13:00 +02:00
|
|
|
|
|
|
|
@property
|
|
|
|
def schedule_parsed(self):
|
|
|
|
"""parse schedule"""
|
|
|
|
minute = cronexp(self.crontab.minute)
|
|
|
|
hour = cronexp(self.crontab.hour)
|
|
|
|
day_of_week = cronexp(self.crontab.day_of_week)
|
|
|
|
|
|
|
|
return f"{minute} {hour} {day_of_week}"
|