Move jobs raw definition to their own namespace and the cascading fallout
This commit is contained in:
@@ -10,8 +10,6 @@ import (
|
||||
"local/firestormy/scheduler"
|
||||
"local/logb"
|
||||
"net/http"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type upsertRequest struct {
|
||||
@@ -58,7 +56,9 @@ func (u *upsertRequest) toJob() (*scheduler.Job, error) {
|
||||
return nil, err
|
||||
}
|
||||
j.Title = u.Title
|
||||
j.Name = u.ID
|
||||
if u.ID != "" {
|
||||
err = j.Rename(u.ID)
|
||||
}
|
||||
j.Disabled = u.Disabled
|
||||
return j, err
|
||||
}
|
||||
@@ -75,11 +75,7 @@ func (s *Server) upsert(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if job.Name == "" {
|
||||
job.Name = uuid.New().String()
|
||||
if job.Title == "" {
|
||||
job.Title = job.Name
|
||||
}
|
||||
if upsert.ID == "" {
|
||||
if err := scheduler.Schedule.Add(job); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user