mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 13:19:53 +05:00
CDR export with path instead of Tag
This commit is contained in:
committed by
Dan Christian Bogos
parent
0fcafbb526
commit
ca7ed53b67
@@ -282,15 +282,15 @@
|
||||
{"tag": "Partial", "path": "*cgreq.Partial", "type": "*constant", "value": "true", "filters":["*string:~*req.10:partial"]},
|
||||
],
|
||||
"cache_dump_fields": [
|
||||
{"tag": "OriginID", "path":"*exp", "type": "*composed", "value": "~*req.OriginID"},
|
||||
{"tag": "OrderID", "path":"*exp", "type": "*composed", "value": "~*req.OrderID"},
|
||||
{"tag": "RequestType", "path":"*exp", "type": "*composed", "value": "~*req.RequestType"},
|
||||
{"tag": "Account", "path":"*exp", "type": "*composed", "value": "~*req.Account"},
|
||||
{"tag": "Destination", "path":"*exp", "type": "*composed", "value": "~*req.Destination"},
|
||||
{"tag": "SetupTime", "path":"*exp", "type": "*composed", "value": "~*req.SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "AnswerTime", "path":"*exp", "type": "*composed", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "Usage", "path":"*exp", "type": "*composed", "value": "~*req.Usage"},
|
||||
{"tag": "Cost", "path":"*exp", "type": "*composed", "value": "~*req.Cost","rounding_decimals":5},
|
||||
{"tag": "OriginID", "path":"*exp.OriginID", "type": "*composed", "value": "~*req.OriginID"},
|
||||
{"tag": "OrderID", "path":"*exp.OrderID", "type": "*composed", "value": "~*req.OrderID"},
|
||||
{"tag": "RequestType", "path":"*exp.RequestType", "type": "*composed", "value": "~*req.RequestType"},
|
||||
{"tag": "Account", "path":"*exp.Account", "type": "*composed", "value": "~*req.Account"},
|
||||
{"tag": "Destination", "path":"*exp.Destination", "type": "*composed", "value": "~*req.Destination"},
|
||||
{"tag": "SetupTime", "path":"*exp.SetupTime", "type": "*composed", "value": "~*req.SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "AnswerTime", "path":"*exp.AnswerTime", "type": "*composed", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "Usage", "path":"*exp.Usage", "type": "*composed", "value": "~*req.Usage"},
|
||||
{"tag": "Cost", "path":"*exp.Cost", "type": "*composed", "value": "~*req.Cost","rounding_decimals":5},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -283,15 +283,15 @@
|
||||
{"tag": "Partial", "path": "*cgreq.Partial", "type": "*constant", "value": "true", "filters":["*string:~*req.10:partial"]},
|
||||
],
|
||||
"cache_dump_fields": [
|
||||
{"tag": "OriginID", "path":"*exp", "type": "*composed", "value": "~*req.OriginID"},
|
||||
{"tag": "OrderID", "path":"*exp", "type": "*composed", "value": "~*req.OrderID"},
|
||||
{"tag": "RequestType", "path":"*exp", "type": "*composed", "value": "~*req.RequestType"},
|
||||
{"tag": "Account", "path":"*exp", "type": "*composed", "value": "~*req.Account"},
|
||||
{"tag": "Destination", "path":"*exp", "type": "*composed", "value": "~*req.Destination"},
|
||||
{"tag": "SetupTime", "path":"*exp", "type": "*composed", "value": "~*req.SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "AnswerTime", "path":"*exp", "type": "*composed", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "Usage", "path":"*exp", "type": "*composed", "value": "~*req.Usage"},
|
||||
{"tag": "Cost", "path":"*exp", "type": "*composed", "value": "~*req.Cost","rounding_decimals":5},
|
||||
{"tag": "OriginID", "path":"*exp.OriginID", "type": "*composed", "value": "~*req.OriginID"},
|
||||
{"tag": "OrderID", "path":"*exp.OrderID", "type": "*composed", "value": "~*req.OrderID"},
|
||||
{"tag": "RequestType", "path":"*exp.RequestType", "type": "*composed", "value": "~*req.RequestType"},
|
||||
{"tag": "Account", "path":"*exp.Account", "type": "*composed", "value": "~*req.Account"},
|
||||
{"tag": "Destination", "path":"*exp.Destination", "type": "*composed", "value": "~*req.Destination"},
|
||||
{"tag": "SetupTime", "path":"*exp.SetupTime", "type": "*composed", "value": "~*req.SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "AnswerTime", "path":"*exp.AnswerTime", "type": "*composed", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "Usage", "path":"*exp.Usage", "type": "*composed", "value": "~*req.Usage"},
|
||||
{"tag": "Cost", "path":"*exp.Cost", "type": "*composed", "value": "~*req.Cost","rounding_decimals":5},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -280,15 +280,15 @@
|
||||
{"tag": "Partial", "path": "*cgreq.Partial", "type": "*constant", "value": "true", "filters":["*string:~*req.10:partial"]},
|
||||
],
|
||||
"cache_dump_fields": [
|
||||
{"tag": "OriginID", "path":"*exp", "type": "*composed", "value": "~*req.OriginID"},
|
||||
{"tag": "OrderID", "path":"*exp", "type": "*composed", "value": "~*req.OrderID"},
|
||||
{"tag": "RequestType", "path":"*exp", "type": "*composed", "value": "~*req.RequestType"},
|
||||
{"tag": "Account", "path":"*exp", "type": "*composed", "value": "~*req.Account"},
|
||||
{"tag": "Destination", "path":"*exp", "type": "*composed", "value": "~*req.Destination"},
|
||||
{"tag": "SetupTime", "path":"*exp", "type": "*composed", "value": "~*req.SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "AnswerTime", "path":"*exp", "type": "*composed", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "Usage", "path":"*exp", "type": "*composed", "value": "~*req.Usage"},
|
||||
{"tag": "Cost", "path":"*exp", "type": "*composed", "value": "~*req.Cost","rounding_decimals":5},
|
||||
{"tag": "OriginID", "path":"*exp.OriginID", "type": "*composed", "value": "~*req.OriginID"},
|
||||
{"tag": "OrderID", "path":"*exp.OrderID", "type": "*composed", "value": "~*req.OrderID"},
|
||||
{"tag": "RequestType", "path":"*exp.RequestType", "type": "*composed", "value": "~*req.RequestType"},
|
||||
{"tag": "Account", "path":"*exp.Account", "type": "*composed", "value": "~*req.Account"},
|
||||
{"tag": "Destination", "path":"*exp.Destination", "type": "*composed", "value": "~*req.Destination"},
|
||||
{"tag": "SetupTime", "path":"*exp.SetupTime", "type": "*composed", "value": "~*req.SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "AnswerTime", "path":"*exp.AnswerTime", "type": "*composed", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "Usage", "path":"*exp.Usage", "type": "*composed", "value": "~*req.Usage"},
|
||||
{"tag": "Cost", "path":"*exp.Cost", "type": "*composed", "value": "~*req.Cost","rounding_decimals":5},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -277,15 +277,15 @@
|
||||
{"tag": "Partial", "path": "*cgreq.Partial", "type": "*constant", "value": "true", "filters":["*string:~*req.10:partial"]},
|
||||
],
|
||||
"cache_dump_fields": [
|
||||
{"tag": "OriginID", "path":"*exp", "type": "*composed", "value": "~*req.OriginID"},
|
||||
{"tag": "OrderID", "path":"*exp", "type": "*composed", "value": "~*req.OrderID"},
|
||||
{"tag": "RequestType", "path":"*exp", "type": "*composed", "value": "~*req.RequestType"},
|
||||
{"tag": "Account", "path":"*exp", "type": "*composed", "value": "~*req.Account"},
|
||||
{"tag": "Destination", "path":"*exp", "type": "*composed", "value": "~*req.Destination"},
|
||||
{"tag": "SetupTime", "path":"*exp", "type": "*composed", "value": "~*req.SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "AnswerTime", "path":"*exp", "type": "*composed", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "Usage", "path":"*exp", "type": "*composed", "value": "~*req.Usage"},
|
||||
{"tag": "Cost", "path":"*exp", "type": "*composed", "value": "~*req.Cost","rounding_decimals":5},
|
||||
{"tag": "OriginID", "path":"*exp.OriginID", "type": "*composed", "value": "~*req.OriginID"},
|
||||
{"tag": "OrderID", "path":"*exp.OrderID", "type": "*composed", "value": "~*req.OrderID"},
|
||||
{"tag": "RequestType", "path":"*exp.RequestType", "type": "*composed", "value": "~*req.RequestType"},
|
||||
{"tag": "Account", "path":"*exp.Account", "type": "*composed", "value": "~*req.Account"},
|
||||
{"tag": "Destination", "path":"*exp.Destination", "type": "*composed", "value": "~*req.Destination"},
|
||||
{"tag": "SetupTime", "path":"*exp.SetupTime", "type": "*composed", "value": "~*req.SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "AnswerTime", "path":"*exp.AnswerTime", "type": "*composed", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
|
||||
{"tag": "Usage", "path":"*exp.Usage", "type": "*composed", "value": "~*req.Usage"},
|
||||
{"tag": "Cost", "path":"*exp.Cost", "type": "*composed", "value": "~*req.Cost","rounding_decimals":5},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -313,21 +313,21 @@ func (cdr *CDR) combimedCdrFieldVal(cfgCdrFld *config.FCTemplate, groupCDRs []*C
|
||||
func (cdr *CDR) exportFieldValue(cfgCdrFld *config.FCTemplate, filterS *FilterS) (retVal string, err error) {
|
||||
for _, rsrFld := range cfgCdrFld.Value {
|
||||
var cdrVal string
|
||||
switch cfgCdrFld.Tag {
|
||||
case utils.COST, utils.MetaExp + utils.NestingSep + utils.COST:
|
||||
switch cfgCdrFld.Path {
|
||||
case utils.MetaExp + utils.NestingSep + utils.COST:
|
||||
cdrVal = cdr.FormatCost(cfgCdrFld.CostShiftDigits,
|
||||
cfgCdrFld.RoundingDecimals)
|
||||
case utils.SetupTime, utils.MetaExp + utils.NestingSep + utils.SetupTime:
|
||||
case utils.MetaExp + utils.NestingSep + utils.SetupTime:
|
||||
if cfgCdrFld.Layout == "" {
|
||||
cfgCdrFld.Layout = time.RFC3339
|
||||
}
|
||||
cdrVal = cdr.SetupTime.Format(cfgCdrFld.Layout)
|
||||
case utils.AnswerTime, utils.MetaExp + utils.NestingSep + utils.AnswerTime: // Format time based on layout
|
||||
case utils.MetaExp + utils.NestingSep + utils.AnswerTime: // Format time based on layout
|
||||
if cfgCdrFld.Layout == "" {
|
||||
cfgCdrFld.Layout = time.RFC3339
|
||||
}
|
||||
cdrVal = cdr.AnswerTime.Format(cfgCdrFld.Layout)
|
||||
case utils.Destination, utils.MetaExp + utils.NestingSep + utils.Destination:
|
||||
case utils.MetaExp + utils.NestingSep + utils.Destination:
|
||||
cdrVal, err = cdr.FieldAsString(rsrFld)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -413,7 +413,7 @@ func (cdr *CDR) AsExportRecord(exportFields []*config.FCTemplate,
|
||||
utils.MetaEC: cdr.CostDetails,
|
||||
})
|
||||
for _, cfgFld := range exportFields {
|
||||
if !strings.HasPrefix(cfgFld.Path, utils.MetaExp) {
|
||||
if !strings.HasPrefix(cfgFld.Path, utils.MetaExp+utils.NestingSep) {
|
||||
continue
|
||||
}
|
||||
if pass, err := filterS.Pass(cdr.Tenant,
|
||||
|
||||
@@ -1138,7 +1138,7 @@ func TestCDRexportFieldValue(t *testing.T) {
|
||||
ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"},
|
||||
}
|
||||
|
||||
cfgCdrFld := &config.FCTemplate{Tag: "SetupTime", Type: utils.META_COMPOSED,
|
||||
cfgCdrFld := &config.FCTemplate{Path: "*exp.SetupTime", Type: utils.META_COMPOSED,
|
||||
Value: config.NewRSRParsersMustCompile("~SetupTime", true, utils.INFIELD_SEP)}
|
||||
|
||||
eVal := "2013-11-07T08:42:20Z"
|
||||
|
||||
Reference in New Issue
Block a user