updated logic

pull/1097/head
Rhythm 2022-02-25 09:22:36 +05:30
parent b64811a991
commit a8e8d2da06
2 changed files with 5 additions and 9 deletions

View File

@ -547,14 +547,11 @@ func apiAllServicesStatusHandler(w http.ResponseWriter, r *http.Request) {
var srvs []services.ServiceWithDowntime
m := make(map[int64]downtimes.Downtime)
if t == "" {
timeNow := time.Now()
dtime := downtimes.FindDowntime2()
for i := 0; i < len(dtime); i++ {
downtimeVar := dtime[i]
serviceVar, _ := services.Find(downtimeVar.ServiceId)
checkInterval := time.Duration(serviceVar.Interval)
timeInstance := timeNow.Add(-time.Second * checkInterval)
if downtimeVar.End == nil || timeInstance.Before(*(downtimeVar.End)) || timeInstance.Equal(*(downtimeVar.End)) {
if serviceVar.Online == false {
m[downtimeVar.ServiceId] = downtimeVar
}
}
@ -565,7 +562,6 @@ func apiAllServicesStatusHandler(w http.ResponseWriter, r *http.Request) {
}
}
for _, v := range services.AllInOrder() {
var serviceDowntimeVar services.ServiceWithDowntime
serviceDowntimeVar.Service = v