Add titles to config file and sort list by title

This commit is contained in:
bel
2020-03-15 17:05:29 +00:00
parent 9d51626e4b
commit 2f31b4624a
6 changed files with 12 additions and 9 deletions

View File

@@ -16,7 +16,6 @@ func (s *Server) list(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
sort.Strings(jobs)
out := make([]map[string]interface{}, len(jobs))
for i, job := range jobs {
out[i] = make(map[string]interface{})
@@ -46,5 +45,8 @@ func (s *Server) list(w http.ResponseWriter, r *http.Request) {
"status": j.LastStatus,
}
}
sort.Slice(out, func(i, j int) bool {
return out[i]["title"].(string) < out[j]["title"].(string)
})
json.NewEncoder(w).Encode(out)
}