mirror of https://github.com/statping/statping
changed stuff
parent
a21b72b154
commit
48decee356
|
@ -550,12 +550,14 @@ func apiAllServicesStatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
dtime := downtimes.FindDowntime2()
|
dtime := downtimes.FindDowntime2()
|
||||||
log.Println("FindDowntime2 results")
|
log.Println("FindDowntime2 results")
|
||||||
log.Println(dtime)
|
log.Println(dtime)
|
||||||
/*for i := 0; i < len(dtime); i+=1 {
|
fmt.Println(dtime)
|
||||||
|
for i := 0; i < len(dtime); i+=1 {
|
||||||
downtimeVar := dtime[i]
|
downtimeVar := dtime[i]
|
||||||
serviceVar, _ := services.Find(downtimeVar.ServiceId)
|
serviceVar, _ := services.Find(downtimeVar.ServiceId)
|
||||||
|
if serviceVar.Online ==false {
|
||||||
m[downtimeVar.ServiceId] = downtimeVar
|
m[downtimeVar.ServiceId] = downtimeVar
|
||||||
}*/
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dtime := findAllDowntimes(t)
|
dtime := findAllDowntimes(t)
|
||||||
for i := 0; i < len(dtime); i += 1 {
|
for i := 0; i < len(dtime); i += 1 {
|
||||||
|
|
|
@ -67,9 +67,9 @@ func FindDowntime(timeVar time.Time) []Downtime {
|
||||||
return downtime
|
return downtime
|
||||||
}
|
}
|
||||||
|
|
||||||
func FindDowntime2() interface{} {
|
func FindDowntime2() []Downtime {
|
||||||
var downtime interface{}
|
var downtime []Downtime
|
||||||
db.Raw("SELECT DISTINCT ON (downtimes.service) downtimes.* FROM downtimes ORDER BY service ASC, start DESC;").Scan(&downtime)
|
db.Raw("select d1.* from downtimes d1 left join downtimes d2 on d1.service = d2.service and d2.start > d1.start where d2.service is NULL;").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)
|
//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
|
return downtime
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue