mirror of https://github.com/statping/statping
changed stuff
parent
48decee356
commit
8b7e17ed89
|
@ -547,15 +547,10 @@ func apiAllServicesStatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
var srvs []services.ServiceWithDowntime
|
var srvs []services.ServiceWithDowntime
|
||||||
m := make(map[int64]downtimes.Downtime)
|
m := make(map[int64]downtimes.Downtime)
|
||||||
if t == "" {
|
if t == "" {
|
||||||
dtime := downtimes.FindDowntime2()
|
for _, v := range services.AllInOrder() {
|
||||||
log.Println("FindDowntime2 results")
|
if v.Online == false {
|
||||||
log.Println(dtime)
|
downtime:= downtimes.FindDowntime3(v.Id)
|
||||||
fmt.Println(dtime)
|
m[v.Id] = downtime
|
||||||
for i := 0; i < len(dtime); i+=1 {
|
|
||||||
downtimeVar := dtime[i]
|
|
||||||
serviceVar, _ := services.Find(downtimeVar.ServiceId)
|
|
||||||
if serviceVar.Online ==false {
|
|
||||||
m[downtimeVar.ServiceId] = downtimeVar
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -67,10 +67,9 @@ func FindDowntime(timeVar time.Time) []Downtime {
|
||||||
return downtime
|
return downtime
|
||||||
}
|
}
|
||||||
|
|
||||||
func FindDowntime2() []Downtime {
|
func FindDowntime3(service int64) Downtime {
|
||||||
var downtime []Downtime
|
var downtime 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.Raw("select * from downtimes where service = ? order by start desc limit 1;",service).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
|
return downtime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue