diff --git a/handlers/services.go b/handlers/services.go index 64f3a08a..0b2829d7 100644 --- a/handlers/services.go +++ b/handlers/services.go @@ -548,14 +548,14 @@ func apiAllServicesStatusHandler(w http.ResponseWriter, r *http.Request) { m := make(map[int64]downtimes.Downtime) if t == "" { dtime := downtimes.FindDowntime2() - log.Println(len(dtime)) + log.Println("FindDowntime2 results") log.Println(dtime) - for i := 0; i < len(dtime); i+=1 { + /*for i := 0; i < len(dtime); i+=1 { downtimeVar := dtime[i] - /*serviceVar, _ := services.Find(downtimeVar.ServiceId) - */ + serviceVar, _ := services.Find(downtimeVar.ServiceId) + m[downtimeVar.ServiceId] = downtimeVar - } + }*/ } else { dtime := findAllDowntimes(t) for i := 0; i < len(dtime); i += 1 { diff --git a/types/downtimes/database.go b/types/downtimes/database.go index 86ad1d76..62a7a600 100644 --- a/types/downtimes/database.go +++ b/types/downtimes/database.go @@ -67,8 +67,8 @@ func FindDowntime(timeVar time.Time) []Downtime { return downtime } -func FindDowntime2() []Downtime { - var downtime []Downtime +func FindDowntime2() interface{} { + var downtime interface{} db.Raw("SELECT DISTINCT ON (downtimes.service) downtimes.* FROM downtimes ORDER BY service ASC, start DESC;").Scan(&downtime) //db.Select("downtimes.*").Joins("left join downtimes as d2 on d2.service = downtimes.service AND downtimes.start < d2.start").Where("d2.end = ?",nil).Find(&downtime) return downtime