Skip to content

Commit

Permalink
Properly defining filter prefixes for *combimed export
Browse files Browse the repository at this point in the history
  • Loading branch information
danbogos committed Jun 28, 2023
1 parent 3c9f57c commit 6c007c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions engine/cdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,12 @@ func (cdr *CDR) String() string {
// combimedCdrFieldVal groups together CDRs with same CGRID and combines their values matching filter field ID
func (cdr *CDR) combimedCdrFieldVal(cfgCdrFld *config.FCTemplate, groupCDRs []*CDR, filterS *FilterS) (string, error) {
var combimedVal string // Will result as combination of the field values, filters must match
cmbReqMp := cdr.AsMapStorage()[utils.MetaReq]
fltrMp := cdr.AsMapStorage()
for _, grpCDR := range groupCDRs {
if cdr.CGRID != grpCDR.CGRID {
continue // We only care about cdrs with same primary cdr behind
}
fltrMp := grpCDR.AsMapStorage()
fltrMp[utils.MetaCmedReq] = cmbReqMp // so we can relate in filters
fltrMp[utils.MetaCmedReq] = grpCDR.AsMapStorage()[utils.MetaReq] // so we can relate in filters
if pass, err := filterS.Pass(grpCDR.Tenant, cfgCdrFld.Filters, fltrMp); err != nil {
return utils.EmptyString, err
} else if !pass {
Expand Down
4 changes: 2 additions & 2 deletions engine/cdr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ func TestCDRcombimedCdrFieldVal(t *testing.T) {
tpFld := &config.FCTemplate{
Tag: "TestCombiMed",
Type: utils.META_COMBIMED,
Filters: []string{"*string:~*cmedreq.RunID:*default", "*string:~*req.RunID:testRun1"},
Filters: []string{"*string:~*req.RunID:*default", "*string:~*cmedreq.RunID:testRun1"},
Value: config.NewRSRParsersMustCompile("~*req.Cost", true, utils.INFIELD_SEP),
}
cfg, err := config.NewDefaultCGRConfig()
Expand All @@ -1471,7 +1471,7 @@ func TestCDRcombimedCdrFieldVal(t *testing.T) {
tpFld = &config.FCTemplate{
Tag: "TestCombiMedFail",
Type: utils.META_COMBIMED,
Filters: []string{"*string:~*cmedreq.RunID:*notdefault", "*string:~*req.RunID:testRun1"},
Filters: []string{"*string:~*req.RunID:*notdefault", "*string:~*cmedreq.RunID:testRun1"},
Value: config.NewRSRParsersMustCompile("~*req.Cost", true, utils.INFIELD_SEP),
}
cfg, err = config.NewDefaultCGRConfig()
Expand Down

0 comments on commit 6c007c3

Please sign in to comment.