Skip to content

Commit

Permalink
Fix CrontabSchedule create and update operations (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgonnav committed Jul 24, 2023
1 parent 536eaca commit e41f62f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions estela-api/core/cronjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@


def create_cronjob(name, key, args, env_vars, tags, schedule, data_expiry_days=None):
m, h, d_w, d_m, m_y = schedule.split(" ")
minute, hour, day_of_month, month, day_of_week = schedule.split(" ")
cjid, sid, pid = key.split(".")
data = {"cronjob": cjid, "args": args, "env_vars": env_vars, "tags": tags}
schedule, _ = CrontabSchedule.objects.get_or_create(
minute=m,
hour=h,
day_of_week=d_w,
day_of_month=d_m,
month_of_year=m_y,
minute=minute,
hour=hour,
day_of_week=day_of_week,
day_of_month=day_of_month,
month_of_year=month,
)
response = PeriodicTask.objects.create(
crontab=schedule,
Expand Down Expand Up @@ -67,13 +67,13 @@ def delete_cronjob(key):
def update_schedule(key, schedule):
try:
cronjob = PeriodicTask.objects.get(name=key)
m, h, d_w, d_m, m_y = schedule.split(" ")
minute, hour, day_of_month, month, day_of_week = schedule.split(" ")
schedule, _ = CrontabSchedule.objects.get_or_create(
minute=m,
hour=h,
day_of_week=d_w,
day_of_month=d_m,
month_of_year=m_y,
minute=minute,
hour=hour,
day_of_week=day_of_week,
day_of_month=day_of_month,
month_of_year=month,
)
cronjob.crontab = schedule
cronjob.save()
Expand Down

0 comments on commit e41f62f

Please sign in to comment.