|
|
|
@ -50,6 +50,34 @@ func weekHistory(w http.ResponseWriter, req *http.Request) {
|
|
|
|
|
http.Error(w, "Only one `service_name` allowed", http.StatusBadRequest)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
entries := getWeek(keys[0])
|
|
|
|
|
entries := getHistoryDay(keys[0], 7)
|
|
|
|
|
writeJSON(w, entries)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func monthHistory(w http.ResponseWriter, req *http.Request) {
|
|
|
|
|
keys, ok := req.URL.Query()["service_name"]
|
|
|
|
|
if !ok || len(keys) == 0 || len(keys[0]) < 1 {
|
|
|
|
|
http.Error(w, "`service_name` not provided", http.StatusBadRequest)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if len(keys) >= 2 {
|
|
|
|
|
http.Error(w, "Only one `service_name` allowed", http.StatusBadRequest)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
entries := getHistoryDay(keys[0], 31)
|
|
|
|
|
writeJSON(w, entries)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func yearHistory(w http.ResponseWriter, req *http.Request) {
|
|
|
|
|
keys, ok := req.URL.Query()["service_name"]
|
|
|
|
|
if !ok || len(keys) == 0 || len(keys[0]) < 1 {
|
|
|
|
|
http.Error(w, "`service_name` not provided", http.StatusBadRequest)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if len(keys) >= 2 {
|
|
|
|
|
http.Error(w, "Only one `service_name` allowed", http.StatusBadRequest)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
entries := getHistoryDay(keys[0], 366)
|
|
|
|
|
writeJSON(w, entries)
|
|
|
|
|
}
|
|
|
|
|