Initial commit — cynfo RMM (clean history, no secrets)
This commit is contained in:
@@ -422,6 +422,27 @@ func (d *Database) UpdateTaskStatusDirect(id int, status string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (d *Database) UpdateTask(id int, name, scheduleType, scheduleTime string, weekday, monthday *int,
|
||||
reboot, healthCheck bool, healthCheckTimeout int, webhookURL string, active bool) (*models.Task, error) {
|
||||
|
||||
now := time.Now()
|
||||
nextRun := CalculateNextRun(scheduleType, scheduleTime, weekday, monthday, now)
|
||||
|
||||
_, err := d.db.Exec(`
|
||||
UPDATE tasks SET
|
||||
name = $1, schedule_type = $2, schedule_time = $3,
|
||||
schedule_weekday = $4, schedule_monthday = $5,
|
||||
reboot = $6, health_check = $7, health_check_timeout = $8,
|
||||
webhook_url = $9, active = $10, next_run = $11
|
||||
WHERE id = $12
|
||||
`, name, scheduleType, scheduleTime, weekday, monthday,
|
||||
reboot, healthCheck, healthCheckTimeout, webhookURL, active, nextRun, id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Task aktualisieren: %w", err)
|
||||
}
|
||||
return d.GetTask(id)
|
||||
}
|
||||
|
||||
func (d *Database) DeleteTask(id int) error {
|
||||
res, err := d.db.Exec("DELETE FROM tasks WHERE id = $1", id)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user