Files
archie/internal/webui/tasks_debug.go
T
sam 0a37b551f5
Quality / check (push) Successful in 3m47s
deploy / gate (push) Successful in 4m32s
deploy / archied-image (push) Successful in 2m51s
deploy / agent-image (push) Successful in 10s
deploy / dist-zip (push) Skipped
refactor(webui): extract the tasks resource module (#1778)
2026-11-03 08:06:56 +11:00

36 lines
992 B
Go

package webui
import (
"net/http"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/events"
)
// taskDebugView is GET /api/tasks/{id}/debug: the raw task record and all of
// its events.
type taskDebugView struct {
TaskID int64 `json:"task_id"`
Attempt int `json:"attempt"`
Task task.Task `json:"task"`
Events []events.Event `json:"events"`
}
// handleTaskDebug serves the task's raw record together with its whole event
// list, for whichever attempt the request names.
func (a *tasksAPI) handleTaskDebug(w http.ResponseWriter, r *http.Request) {
t, attempt, ok := a.taskAttemptTarget(w, r)
if !ok {
return
}
evs, err := a.store.TaskEvents(r.Context(), t.ID)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if evs == nil {
evs = []events.Event{}
}
writeJSON(w, taskDebugView{TaskID: t.ID, Attempt: attempt, Task: *t, Events: evs})
}