mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Adding supplier in CdrStats filters
This commit is contained in:
@@ -320,6 +320,7 @@ CREATE TABLE tp_cdr_stats (
|
||||
`subject` varchar(64) NOT NULL,
|
||||
`destination_prefix` varchar(64) NOT NULL,
|
||||
`usage_interval` varchar(64) NOT NULL,
|
||||
`supplier` varchar(64) NOT NULL,
|
||||
`mediation_runids` varchar(64) NOT NULL,
|
||||
`rated_account` varchar(64) NOT NULL,
|
||||
`rated_subject` varchar(64) NOT NULL,
|
||||
|
||||
@@ -315,6 +315,7 @@ CREATE TABLE tp_cdr_stats (
|
||||
subject VARCHAR(64) NOT NULL,
|
||||
destination_prefix VARCHAR(64) NOT NULL,
|
||||
usage_interval VARCHAR(64) NOT NULL,
|
||||
supplier VARCHAR(64) NOT NULL,
|
||||
mediation_runids VARCHAR(64) NOT NULL,
|
||||
rated_account VARCHAR(64) NOT NULL,
|
||||
rated_subject VARCHAR(64) NOT NULL,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#Id,QueueLength,TimeWindow,Metrics,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers
|
||||
CDRST3,5,60m,ASR,2014-07-29T15:00:00Z;2014-07-29T16:00:00Z,*voice,87.139.12.167,FS_JSON,rated,*out,cgrates.org,call,dan,dan,+49,5m;10m,default,rif,rif,0;2,CDRST3_WARN_ASR
|
||||
CDRST3,,,ACD,,,,,,,,,,,,,,,,,CDRST3_WARN_ACD
|
||||
CDRST3,,,ACC,,,,,,,,,,,,,,,,,CDRST3_WARN_ACC
|
||||
CDRST4,10,0,ASR,,,,,,,cgrates.org,call,,,,,,,,,CDRST4_WARN_ASR
|
||||
CDRST4,,,ACD,,,,,,,,,,,,,,,,,CDRST4_WARN_ACD
|
||||
#Id,QueueLength,TimeWindow,Metrics,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,Supplier,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers
|
||||
CDRST3,5,60m,ASR,2014-07-29T15:00:00Z;2014-07-29T16:00:00Z,*voice,87.139.12.167,FS_JSON,rated,*out,cgrates.org,call,dan,dan,+49,5m;10m,,default,rif,rif,0;2,CDRST3_WARN_ASR
|
||||
CDRST3,,,ACD,,,,,,,,,,,,,,,,,,CDRST3_WARN_ACD
|
||||
CDRST3,,,ACC,,,,,,,,,,,,,,,,,,CDRST3_WARN_ACC
|
||||
CDRST4,10,0,ASR,,,,,,,cgrates.org,call,,,,,,,,,,CDRST4_WARN_ASR
|
||||
CDRST4,,,ACD,,,,,,,,,,,,,,,,,,CDRST4_WARN_ACD
|
||||
|
@@ -1,12 +1,12 @@
|
||||
#Id,QueueLength,TimeWindow,Metric,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers
|
||||
CDRST1,10,0,ASR,,,,,,,cgrates.org,,,,,,default,,,,CDRST1_WARN
|
||||
CDRST1,,,ACD,,,,,,,,,,,,,,,,,
|
||||
#Id,QueueLength,TimeWindow,Metric,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,Supplier,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers
|
||||
CDRST1,10,0,ASR,,,,,,,cgrates.org,,,,,,,default,,,,CDRST1_WARN
|
||||
CDRST1,,,ACD,,,,,,,,,,,,,,,,,,
|
||||
CDRST1,,,ACC,,,,,,,,,,,,,,,,,
|
||||
CDRST_1001,10,10m,ASR,,,,,,,cgrates.org,,,1001,,,default,,,,CDRST1001_WARN
|
||||
CDRST_1001,,,ACD,,,,,,,,,,,,,,,,,
|
||||
CDRST_1001,10,10m,ASR,,,,,,,cgrates.org,,,1001,,,,default,,,,CDRST1001_WARN
|
||||
CDRST_1001,,,ACD,,,,,,,,,,,,,,,,,,
|
||||
CDRST_1001,,,ACC,,,,,,,,,,,,,,,,,
|
||||
CDRST_1002,10,10m,ASR,,,,,,,cgrates.org,,,1002,,,default,,,,CDRST1001_WARN
|
||||
CDRST_1002,,,ACD,,,,,,,,,,,,,,,,,
|
||||
CDRST_1002,10,10m,ASR,,,,,,,cgrates.org,,,1002,,,,default,,,,CDRST1001_WARN
|
||||
CDRST_1002,,,ACD,,,,,,,,,,,,,,,,,,
|
||||
CDRST_1002,,,ACC,,,,,,,,,,,,,,,,,
|
||||
CDRST_1003,,,ASR,,,,,,,cgrates.org,,,,1003,,default,,,,CDRST3_WARN
|
||||
CDRST_1003,,,ACD,,,,,,,,,,,,,,,,,
|
||||
CDRST_1003,,,ASR,,,,,,,cgrates.org,,,,1003,,,default,,,,CDRST3_WARN
|
||||
CDRST_1003,,,ACD,,,,,,,,,,,,,,,,,,
|
||||
|
||||
|
@@ -68,6 +68,7 @@ type CdrStats struct {
|
||||
Subject []string // CDRFieldFilter on Subjects
|
||||
DestinationPrefix []string // CDRFieldFilter on DestinationPrefixes
|
||||
UsageInterval []time.Duration // CDRFieldFilter on UsageInterval, 2 or less items (>= Usage, <Usage)
|
||||
Supplier []string // CDRFieldFilter on Suppliers
|
||||
MediationRunIds []string // CDRFieldFilter on MediationRunIds
|
||||
RatedAccount []string // CDRFieldFilter on RatedAccounts
|
||||
RatedSubject []string // CDRFieldFilter on RatedSubjects
|
||||
@@ -134,6 +135,9 @@ func (cs *CdrStats) AcceptCdr(cdr *StoredCdr) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if len(cs.Supplier) > 0 && !utils.IsSliceMember(cs.Supplier, cdr.Supplier) {
|
||||
return false
|
||||
}
|
||||
if len(cs.MediationRunIds) > 0 && !utils.IsSliceMember(cs.MediationRunIds, cdr.MediationRunId) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -973,39 +973,40 @@ func (csvr *CSVReader) LoadCdrStats() (err error) {
|
||||
defer fp.Close()
|
||||
}
|
||||
for record, err := csvReader.Read(); err == nil; record, err = csvReader.Read() {
|
||||
tag := record[0]
|
||||
tag := record[CDRSTATIDX_TAG]
|
||||
var cs *CdrStats
|
||||
var exists bool
|
||||
if cs, exists = csvr.cdrStats[tag]; !exists {
|
||||
cs = &CdrStats{Id: tag}
|
||||
}
|
||||
triggerTag := record[20]
|
||||
triggerTag := record[CDRSTATIDX_ATRIGGER]
|
||||
triggers, exists := csvr.actionsTriggers[triggerTag]
|
||||
if triggerTag != "" && !exists {
|
||||
// only return error if there was something there for the tag
|
||||
return fmt.Errorf("Could not get action triggers for cdr stats id %s: %s", cs.Id, triggerTag)
|
||||
}
|
||||
tpCs := &utils.TPCdrStat{
|
||||
QueueLength: record[1],
|
||||
TimeWindow: record[2],
|
||||
Metrics: record[3],
|
||||
SetupInterval: record[4],
|
||||
TOR: record[5],
|
||||
CdrHost: record[6],
|
||||
CdrSource: record[7],
|
||||
ReqType: record[8],
|
||||
Direction: record[9],
|
||||
Tenant: record[10],
|
||||
Category: record[11],
|
||||
Account: record[12],
|
||||
Subject: record[13],
|
||||
DestinationPrefix: record[14],
|
||||
UsageInterval: record[15],
|
||||
MediationRunIds: record[16],
|
||||
RatedAccount: record[17],
|
||||
RatedSubject: record[18],
|
||||
CostInterval: record[19],
|
||||
ActionTriggers: record[20],
|
||||
QueueLength: record[CDRSTATIDX_QLENGHT],
|
||||
TimeWindow: record[CDRSTATIDX_TIMEWINDOW],
|
||||
Metrics: record[CDRSTATIDX_METRICS],
|
||||
SetupInterval: record[CDRSTATIDX_SETUPTIME],
|
||||
TOR: record[CDRSTATIDX_TOR],
|
||||
CdrHost: record[CDRSTATIDX_CDRHOST],
|
||||
CdrSource: record[CDRSTATIDX_CDRSRC],
|
||||
ReqType: record[CDRSTATIDX_REQTYPE],
|
||||
Direction: record[CDRSTATIDX_DIRECTION],
|
||||
Tenant: record[CDRSTATIDX_TENANT],
|
||||
Category: record[CDRSTATIDX_CATEGORY],
|
||||
Account: record[CDRSTATIDX_ACCOUNT],
|
||||
Subject: record[CDRSTATIDX_SUBJECT],
|
||||
DestinationPrefix: record[CDRSTATIDX_DSTPREFIX],
|
||||
UsageInterval: record[CDRSTATIDX_USAGE],
|
||||
Supplier: record[CDRSTATIDX_SUPPLIER],
|
||||
MediationRunIds: record[CDRSTATIDX_MEDRUN],
|
||||
RatedAccount: record[CDRSTATIDX_RTACCOUNT],
|
||||
RatedSubject: record[CDRSTATIDX_RTSUBJECT],
|
||||
CostInterval: record[CDRSTATIDX_COST],
|
||||
ActionTriggers: record[CDRSTATIDX_ATRIGGER],
|
||||
}
|
||||
UpdateCdrStats(cs, triggers, tpCs)
|
||||
csvr.cdrStats[tag] = cs
|
||||
|
||||
@@ -194,12 +194,12 @@ vdf,emptyY,*out,TOPUP_EMPTY_AT,
|
||||
*out,cgrates.org,call,dan,*any,extra1,,,,,,rif2,rif2,,,,,
|
||||
`
|
||||
cdrStats = `
|
||||
#Id,QueueLength,TimeWindow,Metrics,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers
|
||||
CDRST1,5,60m,ASR,2014-07-29T15:00:00Z;2014-07-29T16:00:00Z,*voice,87.139.12.167,FS_JSON,*rated,*out,cgrates.org,call,dan,dan,49,5m;10m,default,rif,rif,0;2,STANDARD_TRIGGERS
|
||||
CDRST1,,,ACD,,,,,,,,,,,,,,,,,STANDARD_TRIGGER
|
||||
CDRST1,,,ACC,,,,,,,,,,,,,,,,,
|
||||
CDRST2,10,10m,ASR,,,,,,,cgrates.org,call,,,,,,,,,
|
||||
CDRST2,,,ACD,,,,,,,,,,,,,,,,,
|
||||
#Id,QueueLength,TimeWindow,Metrics,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,Supplier,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers
|
||||
CDRST1,5,60m,ASR,2014-07-29T15:00:00Z;2014-07-29T16:00:00Z,*voice,87.139.12.167,FS_JSON,*rated,*out,cgrates.org,call,dan,dan,49,5m;10m,suppl1,default,rif,rif,0;2,STANDARD_TRIGGERS
|
||||
CDRST1,,,ACD,,,,,,,,,,,,,,,,,,STANDARD_TRIGGER
|
||||
CDRST1,,,ACC,,,,,,,,,,,,,,,,,,
|
||||
CDRST2,10,10m,ASR,,,,,,,cgrates.org,call,,,,,,,,,,
|
||||
CDRST2,,,ACD,,,,,,,,,,,,,,,,,,
|
||||
`
|
||||
)
|
||||
|
||||
|
||||
@@ -76,6 +76,32 @@ const (
|
||||
ATRIGCSVIDX_WEIGHT
|
||||
)
|
||||
|
||||
// utils.CDR_STATS_CSV
|
||||
const (
|
||||
CDRSTATIDX_TAG = iota
|
||||
CDRSTATIDX_QLENGHT
|
||||
CDRSTATIDX_TIMEWINDOW
|
||||
CDRSTATIDX_METRICS
|
||||
CDRSTATIDX_SETUPTIME
|
||||
CDRSTATIDX_TOR
|
||||
CDRSTATIDX_CDRHOST
|
||||
CDRSTATIDX_CDRSRC
|
||||
CDRSTATIDX_REQTYPE
|
||||
CDRSTATIDX_DIRECTION
|
||||
CDRSTATIDX_TENANT
|
||||
CDRSTATIDX_CATEGORY
|
||||
CDRSTATIDX_ACCOUNT
|
||||
CDRSTATIDX_SUBJECT
|
||||
CDRSTATIDX_DSTPREFIX
|
||||
CDRSTATIDX_USAGE
|
||||
CDRSTATIDX_SUPPLIER
|
||||
CDRSTATIDX_MEDRUN
|
||||
CDRSTATIDX_RTACCOUNT
|
||||
CDRSTATIDX_RTSUBJECT
|
||||
CDRSTATIDX_COST
|
||||
CDRSTATIDX_ATRIGGER
|
||||
)
|
||||
|
||||
type TPLoader interface {
|
||||
LoadDestinations() error
|
||||
LoadRates() error
|
||||
@@ -398,7 +424,7 @@ var FileValidators = map[string]*FileLineRegexValidator{
|
||||
"Direction(*out),Tenant[0-9A-Za-z_],Category([0-9A-Za-z_]),Account[0-9A-Za-z_],Subject([0-9A-Za-z_]|*any),RunId([0-9A-Za-z_]),RunFilter([^~]*[0-9A-Za-z_/]),ReqTypeField([^~]*[0-9A-Za-z_/]|*default),DirectionField([^~]*[0-9A-Za-z_/]|*default),TenantField([^~]*[0-9A-Za-z_/]|*default),TorField([^~]*[0-9A-Za-z_/]|*default),AccountField([^~]*[0-9A-Za-z_/]|*default),SubjectField([^~]*[0-9A-Za-z_/]|*default),DestinationField([^~]*[0-9A-Za-z_/]|*default),SetupTimeField([^~]*[0-9A-Za-z_/]|*default),AnswerTimeField([^~]*[0-9A-Za-z_/]|*default),UsageField([^~]*[0-9A-Za-z_/]|*default),SupplierField([^~]*[0-9A-Za-z_/]|*default)"},
|
||||
utils.CDR_STATS_CSV: &FileLineRegexValidator{utils.CDR_STATS_NRCOLS,
|
||||
regexp.MustCompile(`.+`), //ToDo: Fix me with proper rules
|
||||
"Id,QueueLength,TimeWindow,Metric,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers(*?[0-9A-Za-z_]),Strategy(*[0-9A-Za-z_]),RatingSubject(*?[0-9A-Za-z_])"},
|
||||
"Id,QueueLength,TimeWindow,Metric,SetupInterval,TOR,CdrHost,CdrSource,ReqType,Direction,Tenant,Category,Account,Subject,DestinationPrefix,UsageInterval,Supplier,MediationRunIds,RatedAccount,RatedSubject,CostInterval,Triggers(*?[0-9A-Za-z_]),Strategy(*[0-9A-Za-z_]),RatingSubject(*?[0-9A-Za-z_])"},
|
||||
}
|
||||
|
||||
func NewTPCSVFileParser(dirPath, fileName string) (*TPCSVFileParser, error) {
|
||||
|
||||
@@ -275,6 +275,7 @@ type TpCdrStat struct {
|
||||
Subject string
|
||||
DestinationPrefix string
|
||||
UsageInterval string
|
||||
Supplier string
|
||||
MediationRunids string
|
||||
RatedAccount string
|
||||
RatedSubject string
|
||||
|
||||
@@ -162,6 +162,7 @@ func TestGetSessionRuns(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetLCR(t *testing.T) {
|
||||
rsponder.Stats = NewStats(dataStorage) // Load stats instance
|
||||
dstDe := &Destination{Id: "GERMANY", Prefixes: []string{"+49"}}
|
||||
if err := dataStorage.SetDestination(dstDe); err != nil {
|
||||
t.Error(err)
|
||||
@@ -279,28 +280,34 @@ func TestGetLCR(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
danStatsId := "dan_stats"
|
||||
rsponder.Stats.AddQueue(&CdrStats{Id: danStatsId}, nil)
|
||||
danRpfl := &RatingProfile{Id: "*out:tenant12:call:dan12",
|
||||
RatingPlanActivations: RatingPlanActivations{&RatingPlanActivation{
|
||||
ActivationTime: time.Date(2015, 01, 01, 8, 0, 0, 0, time.UTC),
|
||||
RatingPlanId: rp1.Id,
|
||||
FallbackKeys: []string{},
|
||||
CdrStatQueueIds: []string{},
|
||||
CdrStatQueueIds: []string{danStatsId},
|
||||
}},
|
||||
}
|
||||
rifStatsId := "rif_stats"
|
||||
rsponder.Stats.AddQueue(&CdrStats{Id: rifStatsId}, nil)
|
||||
rifRpfl := &RatingProfile{Id: "*out:tenant12:call:rif12",
|
||||
RatingPlanActivations: RatingPlanActivations{&RatingPlanActivation{
|
||||
ActivationTime: time.Date(2015, 01, 01, 8, 0, 0, 0, time.UTC),
|
||||
RatingPlanId: rp2.Id,
|
||||
FallbackKeys: []string{},
|
||||
CdrStatQueueIds: []string{},
|
||||
CdrStatQueueIds: []string{rifStatsId},
|
||||
}},
|
||||
}
|
||||
ivoStatsId := "ivo_stats"
|
||||
rsponder.Stats.AddQueue(&CdrStats{Id: ivoStatsId}, nil)
|
||||
ivoRpfl := &RatingProfile{Id: "*out:tenant12:call:ivo12",
|
||||
RatingPlanActivations: RatingPlanActivations{&RatingPlanActivation{
|
||||
ActivationTime: time.Date(2015, 01, 01, 8, 0, 0, 0, time.UTC),
|
||||
RatingPlanId: rp3.Id,
|
||||
FallbackKeys: []string{},
|
||||
CdrStatQueueIds: []string{},
|
||||
CdrStatQueueIds: []string{ivoStatsId},
|
||||
}},
|
||||
}
|
||||
for _, rpfl := range []*RatingProfile{danRpfl, rifRpfl, ivoRpfl} {
|
||||
|
||||
@@ -407,6 +407,7 @@ func (self *SQLStorage) SetTPCdrStats(tpid string, css map[string][]*utils.TPCdr
|
||||
Subject: cs.Subject,
|
||||
DestinationPrefix: cs.DestinationPrefix,
|
||||
UsageInterval: cs.UsageInterval,
|
||||
Supplier: cs.Supplier,
|
||||
MediationRunids: cs.MediationRunIds,
|
||||
RatedAccount: cs.RatedAccount,
|
||||
RatedSubject: cs.RatedSubject,
|
||||
@@ -1426,6 +1427,7 @@ func (self *SQLStorage) GetTpCdrStats(tpid, tag string) (map[string][]*utils.TPC
|
||||
Subject: tpCs.Subject,
|
||||
DestinationPrefix: tpCs.DestinationPrefix,
|
||||
UsageInterval: tpCs.UsageInterval,
|
||||
Supplier: tpCs.Supplier,
|
||||
MediationRunIds: tpCs.MediationRunids,
|
||||
RatedAccount: tpCs.RatedAccount,
|
||||
RatedSubject: tpCs.RatedSubject,
|
||||
|
||||
@@ -688,37 +688,38 @@ func (self *TPCSVImporter) importCdrStats(fn string) error {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if len(record[1]) == 0 {
|
||||
record[1] = "0" // Empty value will be translated to 0 as QueueLength
|
||||
if len(record[CDRSTATIDX_QLENGHT]) == 0 {
|
||||
record[CDRSTATIDX_QLENGHT] = "0"
|
||||
}
|
||||
if _, err = strconv.Atoi(record[1]); err != nil {
|
||||
if _, err = strconv.Atoi(record[CDRSTATIDX_QLENGHT]); err != nil {
|
||||
log.Printf("Ignoring line %d, warning: <%s>", lineNr, err.Error())
|
||||
continue
|
||||
}
|
||||
if _, hasIt := css[record[0]]; !hasIt {
|
||||
css[record[0]] = make([]*utils.TPCdrStat, 0)
|
||||
if _, hasIt := css[record[CDRSTATIDX_TAG]]; !hasIt {
|
||||
css[record[CDRSTATIDX_TAG]] = make([]*utils.TPCdrStat, 0)
|
||||
}
|
||||
css[record[0]] = append(css[record[0]], &utils.TPCdrStat{
|
||||
QueueLength: record[1],
|
||||
TimeWindow: ValueOrDefault(record[2], "0"),
|
||||
Metrics: record[3],
|
||||
SetupInterval: record[4],
|
||||
TOR: record[5],
|
||||
CdrHost: record[6],
|
||||
CdrSource: record[7],
|
||||
ReqType: record[8],
|
||||
Direction: record[9],
|
||||
Tenant: record[10],
|
||||
Category: record[11],
|
||||
Account: record[12],
|
||||
Subject: record[13],
|
||||
DestinationPrefix: record[14],
|
||||
UsageInterval: record[15],
|
||||
MediationRunIds: record[16],
|
||||
RatedAccount: record[17],
|
||||
RatedSubject: record[18],
|
||||
CostInterval: record[19],
|
||||
ActionTriggers: record[20],
|
||||
QueueLength: record[CDRSTATIDX_QLENGHT],
|
||||
TimeWindow: ValueOrDefault(record[CDRSTATIDX_TIMEWINDOW], "0"),
|
||||
Metrics: record[CDRSTATIDX_METRICS],
|
||||
SetupInterval: record[CDRSTATIDX_SETUPTIME],
|
||||
TOR: record[CDRSTATIDX_TOR],
|
||||
CdrHost: record[CDRSTATIDX_CDRHOST],
|
||||
CdrSource: record[CDRSTATIDX_CDRSRC],
|
||||
ReqType: record[CDRSTATIDX_REQTYPE],
|
||||
Direction: record[CDRSTATIDX_DIRECTION],
|
||||
Tenant: record[CDRSTATIDX_TENANT],
|
||||
Category: record[CDRSTATIDX_CATEGORY],
|
||||
Account: record[CDRSTATIDX_ACCOUNT],
|
||||
Subject: record[CDRSTATIDX_SUBJECT],
|
||||
DestinationPrefix: record[CDRSTATIDX_DSTPREFIX],
|
||||
UsageInterval: record[CDRSTATIDX_USAGE],
|
||||
Supplier: record[CDRSTATIDX_SUPPLIER],
|
||||
MediationRunIds: record[CDRSTATIDX_MEDRUN],
|
||||
RatedAccount: record[CDRSTATIDX_RTACCOUNT],
|
||||
RatedSubject: record[CDRSTATIDX_RTSUBJECT],
|
||||
CostInterval: record[CDRSTATIDX_COST],
|
||||
ActionTriggers: record[CDRSTATIDX_ATRIGGER],
|
||||
})
|
||||
}
|
||||
if err := self.StorDb.SetTPCdrStats(self.TPid, css); err != nil {
|
||||
|
||||
@@ -395,8 +395,8 @@ func (self *TPCdrStats) AsExportSlice() [][]string {
|
||||
retSlice := make([][]string, len(self.CdrStats))
|
||||
for idx, cdrStat := range self.CdrStats {
|
||||
retSlice[idx] = []string{self.CdrStatsId, cdrStat.QueueLength, cdrStat.TimeWindow, cdrStat.Metrics, cdrStat.SetupInterval, cdrStat.TOR, cdrStat.CdrHost, cdrStat.CdrSource,
|
||||
cdrStat.ReqType, cdrStat.Direction, cdrStat.Tenant, cdrStat.Category, cdrStat.Account, cdrStat.Subject, cdrStat.DestinationPrefix, cdrStat.UsageInterval, cdrStat.MediationRunIds,
|
||||
cdrStat.RatedAccount, cdrStat.RatedSubject, cdrStat.CostInterval, cdrStat.ActionTriggers}
|
||||
cdrStat.ReqType, cdrStat.Direction, cdrStat.Tenant, cdrStat.Category, cdrStat.Account, cdrStat.Subject, cdrStat.DestinationPrefix, cdrStat.UsageInterval, cdrStat.Supplier,
|
||||
cdrStat.MediationRunIds, cdrStat.RatedAccount, cdrStat.RatedSubject, cdrStat.CostInterval, cdrStat.ActionTriggers}
|
||||
}
|
||||
return retSlice
|
||||
}
|
||||
@@ -417,6 +417,7 @@ type TPCdrStat struct {
|
||||
Subject string
|
||||
DestinationPrefix string
|
||||
UsageInterval string
|
||||
Supplier string
|
||||
MediationRunIds string
|
||||
RatedAccount string
|
||||
RatedSubject string
|
||||
|
||||
@@ -289,6 +289,7 @@ func TestTPCdrStatsAsExportSlice(t *testing.T) {
|
||||
Subject: "dan",
|
||||
DestinationPrefix: "49",
|
||||
UsageInterval: "5m;10m",
|
||||
Supplier: "supplier1",
|
||||
MediationRunIds: "default",
|
||||
RatedAccount: "rif",
|
||||
RatedSubject: "rif",
|
||||
@@ -310,6 +311,7 @@ func TestTPCdrStatsAsExportSlice(t *testing.T) {
|
||||
Subject: "dan",
|
||||
DestinationPrefix: "49",
|
||||
UsageInterval: "5m;10m",
|
||||
Supplier: "supplier1",
|
||||
MediationRunIds: "default",
|
||||
RatedAccount: "dan",
|
||||
RatedSubject: "dan",
|
||||
@@ -318,10 +320,10 @@ func TestTPCdrStatsAsExportSlice(t *testing.T) {
|
||||
},
|
||||
}
|
||||
expectedSlc := [][]string{
|
||||
[]string{"CDRST1", "5", "60m", "ASR;ACD", "2014-07-29T15:00:00Z;2014-07-29T16:00:00Z", "*voice", "87.139.12.167", "FS_JSON", META_RATED, "*out", "cgrates.org", "call", "dan", "dan", "49", "5m;10m",
|
||||
"default", "rif", "rif", "0;2", "STANDARD_TRIGGERS"},
|
||||
[]string{"CDRST1", "5", "60m", "ASR", "2014-07-29T15:00:00Z;2014-07-29T16:00:00Z", "*voice", "87.139.12.167", "FS_JSON", META_RATED, "*out", "cgrates.org", "call", "dan", "dan", "49", "5m;10m",
|
||||
"default", "dan", "dan", "0;2", "STANDARD_TRIGGERS"},
|
||||
[]string{"CDRST1", "5", "60m", "ASR;ACD", "2014-07-29T15:00:00Z;2014-07-29T16:00:00Z", "*voice", "87.139.12.167", "FS_JSON", META_RATED, "*out", "cgrates.org", "call",
|
||||
"dan", "dan", "49", "5m;10m", "supplier1", "default", "rif", "rif", "0;2", "STANDARD_TRIGGERS"},
|
||||
[]string{"CDRST1", "5", "60m", "ASR", "2014-07-29T15:00:00Z;2014-07-29T16:00:00Z", "*voice", "87.139.12.167", "FS_JSON", META_RATED, "*out", "cgrates.org", "call",
|
||||
"dan", "dan", "49", "5m;10m", "supplier1", "default", "dan", "dan", "0;2", "STANDARD_TRIGGERS"},
|
||||
}
|
||||
if slc := cdrStats.AsExportSlice(); !reflect.DeepEqual(expectedSlc, slc) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", expectedSlc, slc)
|
||||
|
||||
@@ -71,7 +71,7 @@ const (
|
||||
ACTION_TRIGGERS_NRCOLS = 19
|
||||
ACCOUNT_ACTIONS_NRCOLS = 5
|
||||
DERIVED_CHARGERS_NRCOLS = 18
|
||||
CDR_STATS_NRCOLS = 21
|
||||
CDR_STATS_NRCOLS = 22
|
||||
ROUNDING_UP = "*up"
|
||||
ROUNDING_MIDDLE = "*middle"
|
||||
ROUNDING_DOWN = "*down"
|
||||
|
||||
Reference in New Issue
Block a user