diff --git a/apier/cdrstatsv1.go b/apier/cdrstatsv1.go index 3a44d9fbb..928480b4e 100644 --- a/apier/cdrstatsv1.go +++ b/apier/cdrstatsv1.go @@ -20,6 +20,7 @@ package apier import ( "fmt" + "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" ) diff --git a/engine/stats_metrics.go b/engine/stats_metrics.go index cf6a0dc86..c05ea1f86 100644 --- a/engine/stats_metrics.go +++ b/engine/stats_metrics.go @@ -64,6 +64,9 @@ func (asr *ASRMetric) RemoveCdr(cdr *QCdr) { } func (asr *ASRMetric) GetValue() float64 { + if asr.total == 0 { + return 0 + } return asr.answered / asr.total * 100 } @@ -89,6 +92,9 @@ func (acd *ACDMetric) RemoveCdr(cdr *QCdr) { } func (acd *ACDMetric) GetValue() float64 { + if acd.count == 0 { + return 0 + } return acd.sum.Seconds() / acd.count } @@ -114,5 +120,8 @@ func (acc *ACCMetric) RemoveCdr(cdr *QCdr) { } func (acc *ACCMetric) GetValue() float64 { + if acc.count == 0 { + return 0 + } return acc.sum / acc.count }