diff --git a/apier/v1/trends_it_test.go b/apier/v1/trends_it_test.go index 8dd617586..775420db0 100644 --- a/apier/v1/trends_it_test.go +++ b/apier/v1/trends_it_test.go @@ -187,6 +187,8 @@ func testTrendSGetTrendProfiles(t *testing.T) { trendProfile2.TrendProfile, } var tResult []*engine.TrendProfile + + //get all trend profiles from every tenant when no tenant is specified if err := trendRPC.Call(context.Background(), utils.APIerSv1GetTrendProfiles, engine.TrendProfilesAPI{}, &tResult); err != nil { t.Error(err) } else if diff := cmp.Diff(expRes, tResult, cmpopts.SortSlices(func(a, b *engine.TrendProfile) bool { return a.ID < b.ID })); diff != utils.EmptyString { @@ -197,6 +199,8 @@ func testTrendSGetTrendProfiles(t *testing.T) { trendProfile.TrendProfile, trendProfile2.TrendProfile, } + + //get all trend profiles of a tenant when ids length is 0 if err := trendRPC.Call(context.Background(), utils.APIerSv1GetTrendProfiles, engine.TrendProfilesAPI{Tenant: "cgrates.org"}, &tResult); err != nil { t.Error(err) } else if diff := cmp.Diff(expRes, tResult, cmpopts.SortSlices(func(a, b *engine.TrendProfile) bool { return a.ID < b.ID })); diff != utils.EmptyString { @@ -206,6 +210,8 @@ func testTrendSGetTrendProfiles(t *testing.T) { expRes = []*engine.TrendProfile{ trendProfile2.TrendProfile, } + + //get trend profiles by their ids for a tenant if err := trendRPC.Call(context.Background(), utils.APIerSv1GetTrendProfiles, engine.TrendProfilesAPI{Tenant: "cgrates.org", TpIDs: []string{"Trend1"}}, &tResult); err != nil { t.Error(err) } else if diff := cmp.Diff(expRes, tResult, cmpopts.SortSlices(func(a, b *engine.TrendProfile) bool { return a.ID < b.ID })); diff != utils.EmptyString { diff --git a/data/conf/samples/ers_internal/cgrates.json b/data/conf/samples/ers_internal/cgrates.json index 22f5934ba..a047db370 100644 --- a/data/conf/samples/ers_internal/cgrates.json +++ b/data/conf/samples/ers_internal/cgrates.json @@ -395,6 +395,7 @@ {"tag": "DialogId", "path": "*cgreq.DialogId", "type": "*variable", "value": "~*req.11"}, {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "true"}, {"tag": "Partial", "path": "*opts.*partial", "type": "*constant", "value": "false","filters": ["*prefix:~*vars.*fileName:missed_calls"]}, + {"tag": "LineNumber", "path": "*opts.*line", "type": "*constant", "value": "1","filters": ["*string:~*vars.*fileLineNumber:1"]}, {"tag": "Invite", "path": "*opts.invite", "type": "*constant", "value": "true", "filters":["*string:~*req.0:INVITE"]}, {"tag": "Bye", "path": "*opts.bye", "type": "*constant", "value": "true", "filters":["*string:~*req.0:BYE"]}, {"tag": "Order", "path": "*opts.order", "type": "*constant", "value": "0", "filters":["*string:~*req.0:INVITE"]}, diff --git a/ers/filecsv.go b/ers/filecsv.go index ec5602f59..9d26c642b 100644 --- a/ers/filecsv.go +++ b/ers/filecsv.go @@ -136,6 +136,7 @@ func (rdr *CSVFileER) processFile(fName string) (err error) { if rdr.Config().Opts.CSV.LazyQuotes != nil { csvReader.LazyQuotes = *rdr.Config().Opts.CSV.LazyQuotes } + var indxAls map[string]int rowNr := 0 // This counts the rows in the file, not really number of CDRs evsPosted := 0 @@ -165,7 +166,7 @@ func (rdr *CSVFileER) processFile(fName string) (err error) { continue } rowNr++ // increment the rowNr after checking if it's not the end of file - + reqVars.Map[utils.MetaFileLineNumber] = utils.NewLeafNode(rowNr) agReq := agents.NewAgentRequest( config.NewSliceDP(record, indxAls), reqVars, nil, nil, nil, rdr.Config().Tenant, diff --git a/ers/filefwv.go b/ers/filefwv.go index bb9affca9..08d8dcc12 100644 --- a/ers/filefwv.go +++ b/ers/filefwv.go @@ -185,6 +185,7 @@ func (rdr *FWVFileER) processFile(fName string) (err error) { continue } rowNr++ // increment the rowNr after checking if it's not the end of file + reqVars.Map[utils.MetaFileLineNumber] = utils.NewLeafNode(rowNr) record := string(buf) agReq := agents.NewAgentRequest( config.NewFWVProvider(record), diff --git a/ers/filexml.go b/ers/filexml.go index b5f0a1a4a..b1613dd65 100644 --- a/ers/filexml.go +++ b/ers/filexml.go @@ -162,6 +162,7 @@ func (rdr *XMLFileER) processFile(fName string) error { reqVars := &utils.DataNode{Type: utils.NMMapType, Map: map[string]*utils.DataNode{utils.MetaFileName: utils.NewLeafNode(fName), utils.MetaReaderID: utils.NewLeafNode(rdr.cgrCfg.ERsCfg().Readers[rdr.cfgIdx].ID)}} for _, xmlElmt := range xmlElmts { rowNr++ // increment the rowNr after checking if it's not the end of file + reqVars.Map[utils.MetaFileLineNumber] = utils.NewLeafNode(reqVars) agReq := agents.NewAgentRequest( config.NewXMLProvider(xmlElmt, xmlRootPath), reqVars, nil, nil, nil, rdr.Config().Tenant, diff --git a/utils/consts.go b/utils/consts.go index 6cc9987ec..fcd088e1f 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -825,6 +825,7 @@ const ( MetaGroup = "*group" InternalRPCSet = "InternalRPCSet" MetaFileName = "*fileName" + MetaFileLineNumber = "*fileLineNumber" MetaReaderID = "*readerID" MetaRadauth = "*radauth" UserPassword = "UserPassword"