adjusted the condition

pull/1097/head
Rhythm 2022-02-24 17:31:52 +05:30
parent c24def9598
commit b64811a991
1 changed files with 2 additions and 2 deletions

View File

@ -547,14 +547,14 @@ func apiAllServicesStatusHandler(w http.ResponseWriter, r *http.Request) {
var srvs []services.ServiceWithDowntime
m := make(map[int64]downtimes.Downtime)
if t == "" {
dtime:=downtimes.FindDowntime2()
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(timeInstance.After(*(downtimeVar.Start)) || timeInstance.Equal(*(downtimeVar.Start)) ) && (downtimeVar.End == nil || (timeInstance.Before(*(downtimeVar.End)) || timeInstance.Equal(*(downtimeVar.End))) ){
if downtimeVar.End == nil || timeInstance.Before(*(downtimeVar.End)) || timeInstance.Equal(*(downtimeVar.End)) {
m[downtimeVar.ServiceId] = downtimeVar
}
}