feat: Task Health Check + customer_number in webhook payload
- Task model: CustomerNumber field (K-Nummer aus customers.number)
- DB: taskSelectCols joined c.number, scanTask scans CustomerNumber
- Hub: WaitForAgentOnline() polls until agent reconnects or timeout
- Scheduler: executeUpdateWithHealthCheck() waits for agent reconnect after update
- health_check: {agent_online: bool, checked_at: RFC3339} in result
- Status: completed_with_warning wenn Update OK aber Agent offline bleibt
- Frontend: Task-Tabelle zeigt Status-Badge (lauft/fehler/warnung/abgebr.)
This commit is contained in:
+10
-3
@@ -126,14 +126,14 @@ func scanTask(scan func(dest ...interface{}) error) (*models.Task, error) {
|
||||
var startedAt, finishedAt, lastRun, nextRun sql.NullTime
|
||||
var resultJSON sql.NullString
|
||||
var webhookURL, webhookResponse, createdBy sql.NullString
|
||||
var agentName, customerName sql.NullString
|
||||
var agentName, customerName, customerNumber sql.NullString
|
||||
var name, scheduleType, scheduleTime sql.NullString
|
||||
var scheduleWeekday, scheduleMonthday sql.NullInt32
|
||||
var reboot, healthCheck, active sql.NullBool
|
||||
var healthCheckTimeout, runCount sql.NullInt32
|
||||
|
||||
err := scan(
|
||||
&t.ID, &t.AgentID, &agentName, &customerName,
|
||||
&t.ID, &t.AgentID, &agentName, &customerName, &customerNumber,
|
||||
&name, &t.Action, &t.Status, &scheduledAt, &startedAt, &finishedAt,
|
||||
&resultJSON, &webhookURL, &t.WebhookSent, &webhookResponse,
|
||||
&createdBy, &createdAt,
|
||||
@@ -146,6 +146,7 @@ func scanTask(scan func(dest ...interface{}) error) (*models.Task, error) {
|
||||
|
||||
t.AgentName = agentName.String
|
||||
t.CustomerName = customerName.String
|
||||
t.CustomerNumber = customerNumber.String
|
||||
t.Name = name.String
|
||||
t.ScheduleType = scheduleType.String
|
||||
if t.ScheduleType == "" {
|
||||
@@ -208,7 +209,7 @@ func scanTask(scan func(dest ...interface{}) error) (*models.Task, error) {
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
const taskSelectCols = `t.id, t.agent_id, COALESCE(a.name, ''), COALESCE(c.name, ''),
|
||||
const taskSelectCols = `t.id, t.agent_id, COALESCE(a.name, ''), COALESCE(c.name, ''), COALESCE(c.number, ''),
|
||||
t.name, t.action, t.status, t.scheduled_at, t.started_at, t.finished_at,
|
||||
t.result, t.webhook_url, t.webhook_sent, t.webhook_response,
|
||||
t.created_by, t.created_at,
|
||||
@@ -415,6 +416,12 @@ func (d *Database) CancelTask(id int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateTaskStatusDirect sets only the status field (for post-completion overrides).
|
||||
func (d *Database) UpdateTaskStatusDirect(id int, status string) error {
|
||||
_, err := d.db.Exec("UPDATE tasks SET status = $1 WHERE id = $2", status, id)
|
||||
return err
|
||||
}
|
||||
|
||||
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