blob: d92754502f3941bfc62a879dd8c0c1203be6a9e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package api
import (
"database/sql"
"net/http"
"github.com/thepeterstone/claudomator/internal/deployment"
)
// handleGetDeploymentStatus returns whether the currently-deployed server
// includes the commits that were produced by this task's latest execution.
// GET /api/tasks/{id}/deployment-status
func (s *Server) handleGetDeploymentStatus(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("id")
tk, err := s.store.GetTask(id)
if err != nil {
writeJSON(w, http.StatusNotFound, map[string]string{"error": "task not found"})
return
}
exec, err := s.store.GetLatestExecution(tk.ID)
if err != nil {
if err == sql.ErrNoRows {
// No execution yet — return status with no fix commits.
status := deployment.Check(nil, tk.Agent.ProjectDir)
writeJSON(w, http.StatusOK, status)
return
}
writeJSON(w, http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
}
status := deployment.Check(exec.Commits, tk.Agent.ProjectDir)
writeJSON(w, http.StatusOK, status)
}
|