mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
started Destination Id Archive
This commit is contained in:
@@ -229,3 +229,36 @@ func (tcc *TCCMetric) GetValue() float64 {
|
||||
}
|
||||
return utils.Round(tcc.sum, globalRoundingDecimals, utils.ROUNDING_MIDDLE)
|
||||
}
|
||||
|
||||
// DIA - Destination ID Archive
|
||||
//
|
||||
type DIAMetric struct {
|
||||
destinations map[string]int64
|
||||
}
|
||||
|
||||
func (dia *DIAMetric) AddCdr(cdr *QCdr) {
|
||||
if dia.destinations == nil {
|
||||
dia.destinations = make(map[string]int64)
|
||||
}
|
||||
if count, exists := dia.destinations[cdr.Dest]; exists {
|
||||
dia.destinations[cdr.Dest] = count + 1
|
||||
}
|
||||
}
|
||||
|
||||
func (dia *DIAMetric) RemoveCdr(cdr *QCdr) {
|
||||
if dia.destinations == nil {
|
||||
dia.destinations = make(map[string]int64)
|
||||
}
|
||||
if count, exists := dia.destinations[cdr.Dest]; exists && count > 1 {
|
||||
dia.destinations[cdr.Dest] = count - 1
|
||||
} else {
|
||||
dia.destinations[cdr.Dest] = 0
|
||||
}
|
||||
}
|
||||
|
||||
func (dia *DIAMetric) GetValue() float64 {
|
||||
if len(dia.destinations) == 0 {
|
||||
return STATS_NA
|
||||
}
|
||||
return len(dia.destinations)
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ type QCdr struct {
|
||||
Pdd time.Duration
|
||||
Usage time.Duration
|
||||
Cost float64
|
||||
Dest string
|
||||
}
|
||||
|
||||
func NewStatsQueue(conf *CdrStats) *StatsQueue {
|
||||
@@ -164,6 +165,7 @@ func (sq *StatsQueue) simplifyCdr(cdr *StoredCdr) *QCdr {
|
||||
Pdd: cdr.Pdd,
|
||||
Usage: cdr.Usage,
|
||||
Cost: cdr.Cost,
|
||||
Dest: cdr.Destination,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user