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) }