fix: update task fields reliably

This commit is contained in:
jbwfu
2026-03-04 18:05:21 +08:00
parent ab6e48d1ae
commit 18bc4184f2
+7 -21
View File
@@ -113,27 +113,13 @@ func (ts *TaskService) UpdateTask(id string, name, command, schedule string, tim
if triggerType != "" {
task.TriggerType = triggerType
}
updates := map[string]interface{}{
"name": name,
"command": command,
"tags": tags,
"schedule": schedule,
"timeout": timeout,
"work_dir": workDir,
"clean_config": cleanConfig,
"envs": envs,
"enabled": enabled,
"agent_id": agentID,
"languages": languages,
"retry_count": retryCount,
"retry_interval": retryInterval,
"random_range": randomRange,
"type": task.Type,
"trigger_type": task.TriggerType,
"next_run": task.NextRun,
"config": config,
}
database.DB.Model(&task).Updates(updates)
database.DB.Model(&task).Select(
"Name", "Command", "Tags", "Schedule", "Timeout", "WorkDir",
"CleanConfig", "Envs", "Enabled", "AgentID", "Languages",
"RetryCount", "RetryInterval", "RandomRange", "Type",
"TriggerType", "Config",
).Updates(&task)
return &task
}