diff --git a/server/get.go b/server/get.go index 652a3af..b776ac2 100755 --- a/server/get.go +++ b/server/get.go @@ -26,5 +26,5 @@ func (s *Server) get(w http.ResponseWriter, r *http.Request) { return } - json.NewEncoder(w).Encode(toMap(j)) + json.NewEncoder(w).Encode(toMap(j, true)) } diff --git a/server/job.go b/server/job.go index 35eed43..f3ced64 100755 --- a/server/job.go +++ b/server/job.go @@ -7,7 +7,7 @@ import ( "time" ) -func toMap(j *scheduler.Job) map[string]interface{} { +func toMap(j *scheduler.Job, output bool) map[string]interface{} { tz, err := time.LoadLocation("America/Denver") if err != nil { panic(err) @@ -23,8 +23,10 @@ func toMap(j *scheduler.Job) map[string]interface{} { out["last"] = map[string]interface{}{ "run": j.LastRun.In(tz).Format(`2006-01-02 15:04:05 MST`), "runtime": j.LastRuntime.String(), - //"output": j.LastOutput, - "status": j.LastStatus, + "status": j.LastStatus, + } + if output { + out["last"].(map[string]interface{})["output"] = j.LastOutput } return out } diff --git a/server/list.go b/server/list.go index 0348451..107a44a 100755 --- a/server/list.go +++ b/server/list.go @@ -31,7 +31,7 @@ func (s *Server) list(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - out[i] = toMap(j) + out[i] = toMap(j, false) } sort.Slice(out, func(i, j int) bool { return out[i]["title"].(string) < out[j]["title"].(string)