Skip to content

Fix the celery task scheduler query #719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions backend/app/task/utils/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ async def to_model_schedule(name: str, task: str, schedule: schedules.schedule |
if isinstance(schedule, schedules.schedule):
every = max(schedule.run_every.total_seconds(), 0)
spec = {
'name': name,
'type': TaskSchedulerType.INTERVAL.value,
'interval_every': every,
'interval_period': PeriodType.SECONDS.value,
Expand All @@ -184,10 +185,10 @@ async def to_model_schedule(name: str, task: str, schedule: schedules.schedule |
query = await db.execute(stmt)
obj = query.scalars().first()
if not obj:
obj = TaskScheduler(**CreateTaskSchedulerParam(name=name, task=task, **spec).model_dump())
return obj
obj = TaskScheduler(**CreateTaskSchedulerParam(task=task, **spec).model_dump())
elif isinstance(schedule, schedules.crontab):
spec = {
'name': name,
'type': TaskSchedulerType.CRONTAB.value,
'crontab_minute': schedule._orig_minute
if crontab_verify('m', schedule._orig_minute, False)
Expand All @@ -207,17 +208,12 @@ async def to_model_schedule(name: str, task: str, schedule: schedules.schedule |
query = await db.execute(stmt)
obj = query.scalars().first()
if not obj:
obj = TaskScheduler(
**CreateTaskSchedulerParam(
name=name,
task=task,
**spec,
).model_dump()
)
return obj
obj = TaskScheduler(**CreateTaskSchedulerParam(task=task, **spec).model_dump())
else:
raise errors.NotFoundError(msg=f'暂不支持的计划类型:{schedule}')

return obj

@classmethod
async def _unpack_fields(
cls,
Expand Down