Add scheduled tasks with a Project tab section and lead tools

This commit is contained in:
Ian Gulliver
2026-10-21 15:15:20 -07:00
parent 4b4763779d
commit f445e1cac3
21 changed files with 1689 additions and 347 deletions
+46
View File
@@ -0,0 +1,46 @@
package server
import (
"net/http"
"g.fc.run/ai/byre/internal/api"
)
func (s *Server) ListSchedules(w http.ResponseWriter, r *http.Request, projectID string) {
list, err := s.store.ListSchedules(r.Context(), projectID)
if err != nil {
writeStoreError(w, err)
return
}
writeJSON(w, http.StatusOK, list)
}
func (s *Server) CreateSchedule(w http.ResponseWriter, r *http.Request, projectID string) {
s.saveSchedule(w, r, projectID, "", http.StatusCreated)
}
func (s *Server) UpdateSchedule(w http.ResponseWriter, r *http.Request, scheduleID string) {
s.saveSchedule(w, r, "", scheduleID, http.StatusOK)
}
func (s *Server) saveSchedule(w http.ResponseWriter, r *http.Request, projectID, scheduleID string, status int) {
req := api.ScheduleSave{}
if !readJSON(w, r, &req) {
return
}
sc, err := s.agents.SaveSchedule(r.Context(), projectID, scheduleID, req, actor(r), actor(r))
if err != nil {
writeAgentError(w, err)
return
}
writeJSON(w, status, sc)
}
func (s *Server) DeleteSchedule(w http.ResponseWriter, r *http.Request, scheduleID string) {
err := s.agents.DeleteSchedule(r.Context(), scheduleID, actor(r))
if err != nil {
writeAgentError(w, err)
return
}
w.WriteHeader(http.StatusNoContent)
}