mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Update merge
This commit is contained in:
@@ -162,11 +162,13 @@ func (alS *AttributeService) processEvent(args *AttrArgsProcessEvent) (
|
||||
MatchedProfiles: []string{attrPrf.ID},
|
||||
CGREvent: args.Clone(),
|
||||
blocker: attrPrf.Blocker}
|
||||
evNm := config.NewNavigableMap(nil)
|
||||
evNm.Set([]string{utils.MetaReq}, args.Event, false, false)
|
||||
for _, attribute := range attrPrf.Attributes {
|
||||
//in case that we have filter for attribute send them to FilterS to be processed
|
||||
if len(attribute.FilterIDs) != 0 {
|
||||
if pass, err := alS.filterS.Pass(args.Tenant, attribute.FilterIDs,
|
||||
config.NewNavigableMap(args.Event)); err != nil {
|
||||
evNm); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -132,7 +132,7 @@ var (
|
||||
Tenant: config.CgrConfig().GeneralCfg().DefaultTenant,
|
||||
ID: "AttributeIDMatch",
|
||||
Contexts: []string{utils.MetaSessionS},
|
||||
FilterIDs: []string{"*gte:~DistinctMatch:20"},
|
||||
FilterIDs: []string{"*gte:~*req.DistinctMatch:20"},
|
||||
ActivationInterval: &utils.ActivationInterval{
|
||||
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
|
||||
ExpiryTime: cloneExpTimeAttributes,
|
||||
@@ -175,17 +175,17 @@ func TestAttributeAddFilters(t *testing.T) {
|
||||
Rules: []*FilterRule{
|
||||
{
|
||||
Type: utils.MetaString,
|
||||
FieldName: "~Attribute",
|
||||
FieldName: "~*req.Attribute",
|
||||
Values: []string{"AttributeProfile1"},
|
||||
},
|
||||
{
|
||||
Type: utils.MetaGreaterOrEqual,
|
||||
FieldName: "~UsageInterval",
|
||||
FieldName: "~*req.UsageInterval",
|
||||
Values: []string{(1 * time.Second).String()},
|
||||
},
|
||||
{
|
||||
Type: utils.MetaGreaterOrEqual,
|
||||
FieldName: utils.DynamicDataPrefix + utils.Weight,
|
||||
FieldName: "~*req." + utils.Weight,
|
||||
Values: []string{"9.0"},
|
||||
},
|
||||
},
|
||||
@@ -197,7 +197,7 @@ func TestAttributeAddFilters(t *testing.T) {
|
||||
Rules: []*FilterRule{
|
||||
{
|
||||
Type: utils.MetaString,
|
||||
FieldName: "~Attribute",
|
||||
FieldName: "~*req.Attribute",
|
||||
Values: []string{"AttributeProfile2"},
|
||||
},
|
||||
},
|
||||
@@ -209,7 +209,7 @@ func TestAttributeAddFilters(t *testing.T) {
|
||||
Rules: []*FilterRule{
|
||||
{
|
||||
Type: utils.MetaPrefix,
|
||||
FieldName: "~Attribute",
|
||||
FieldName: "~*req.Attribute",
|
||||
Values: []string{"AttributeProfilePrefix"},
|
||||
},
|
||||
},
|
||||
@@ -221,7 +221,7 @@ func TestAttributeAddFilters(t *testing.T) {
|
||||
Rules: []*FilterRule{
|
||||
{
|
||||
Type: utils.MetaGreaterOrEqual,
|
||||
FieldName: utils.DynamicDataPrefix + utils.Weight,
|
||||
FieldName: "~*req." + utils.Weight,
|
||||
Values: []string{"200.00"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -421,9 +421,11 @@ func (cdr *CDR) formatField(cfgFld *config.FCTemplate, httpSkipTlsCheck bool,
|
||||
// ExportRecord is a []string to keep it compatible with encoding/csv Writer
|
||||
func (cdr *CDR) AsExportRecord(exportFields []*config.FCTemplate,
|
||||
httpSkipTlsCheck bool, groupedCDRs []*CDR, filterS *FilterS) (expRecord []string, err error) {
|
||||
nM := config.NewNavigableMap(nil)
|
||||
nM.Set([]string{utils.MetaReq}, cdr.AsMapStringIface(), false, false)
|
||||
for _, cfgFld := range exportFields {
|
||||
if pass, err := filterS.Pass(cdr.Tenant,
|
||||
cfgFld.Filters, config.NewNavigableMap(cdr.AsMapStringIface())); err != nil {
|
||||
cfgFld.Filters, nM); err != nil {
|
||||
return []string{}, err
|
||||
} else if !pass {
|
||||
continue
|
||||
@@ -444,9 +446,11 @@ func (cdr *CDR) AsExportRecord(exportFields []*config.FCTemplate,
|
||||
func (cdr *CDR) AsExportMap(exportFields []*config.FCTemplate, httpSkipTlsCheck bool,
|
||||
groupedCDRs []*CDR, filterS *FilterS) (expMap map[string]string, err error) {
|
||||
expMap = make(map[string]string)
|
||||
nM := config.NewNavigableMap(nil)
|
||||
nM.Set([]string{utils.MetaReq}, cdr.AsMapStringIface(), false, false)
|
||||
for _, cfgFld := range exportFields {
|
||||
if pass, err := filterS.Pass(cdr.Tenant,
|
||||
cfgFld.Filters, config.NewNavigableMap(cdr.AsMapStringIface())); err != nil {
|
||||
cfgFld.Filters, nM); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -388,8 +388,10 @@ func (cdre *CDRExporter) processCDRs() (err error) {
|
||||
if cdre.exportTemplate.Tenant == "" {
|
||||
cdre.exportTemplate.Tenant = config.CgrConfig().GeneralCfg().DefaultTenant
|
||||
}
|
||||
cgrDp := config.NewNavigableMap(nil)
|
||||
cgrDp.Set([]string{utils.MetaReq}, cdr.AsMapStringIface(), false, false)
|
||||
if pass, err := cdre.filterS.Pass(cdre.exportTemplate.Tenant,
|
||||
cdre.exportTemplate.Filters, config.NewNavigableMap(cdr.AsMapStringIface())); err != nil || !pass {
|
||||
cdre.exportTemplate.Filters, cgrDp); err != nil || !pass {
|
||||
continue // Not passes filters, ignore this CDR
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ func (cS *ChargerService) matchingChargerProfilesForEvent(cgrEv *utils.CGREventW
|
||||
return nil, err
|
||||
}
|
||||
matchingCPs := make(map[string]*ChargerProfile)
|
||||
evNm := config.NewNavigableMap(nil)
|
||||
evNm.Set([]string{utils.MetaReq}, cgrEv.Event, false, false)
|
||||
for cpID := range cpIDs {
|
||||
cP, err := cS.dm.GetChargerProfile(cgrEv.Tenant, cpID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
@@ -83,7 +85,7 @@ func (cS *ChargerService) matchingChargerProfilesForEvent(cgrEv *utils.CGREventW
|
||||
continue
|
||||
}
|
||||
if pass, err := cS.filterS.Pass(cgrEv.Tenant, cP.FilterIDs,
|
||||
config.NewNavigableMap(cgrEv.Event)); err != nil {
|
||||
evNm); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -79,7 +79,7 @@ func MatchingItemIDsForEvent(ev map[string]interface{}, stringFldIDs, prefixFldI
|
||||
fldVals = utils.SplitPrefix(fldVal, 1) // all prefixes till last digit
|
||||
}
|
||||
if fldName != utils.META_ANY {
|
||||
fldName = utils.DynamicDataPrefix + fldName
|
||||
fldName = utils.DynamicDataPrefix + utils.MetaReq + utils.NestingSep + fldName
|
||||
}
|
||||
var dbItemIDs utils.StringMap // list of items matched in DB
|
||||
for _, val := range fldVals {
|
||||
|
||||
@@ -216,9 +216,11 @@ func (sq *StatQueue) addStatEvent(ev *utils.CGREvent, filterS *FilterS) (err err
|
||||
ExpiryTime *time.Time
|
||||
}{ev.ID, expTime})
|
||||
var pass bool
|
||||
evNm := config.NewNavigableMap(nil)
|
||||
evNm.Set([]string{utils.MetaReq}, ev.Event, false, false)
|
||||
for metricID, metric := range sq.SQMetrics {
|
||||
if pass, err = filterS.Pass(ev.Tenant, metric.GetFilterIDs(),
|
||||
config.NewNavigableMap(ev.Event)); err != nil {
|
||||
evNm); err != nil {
|
||||
return
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -466,6 +466,8 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREvent,
|
||||
}
|
||||
return
|
||||
}
|
||||
evNm := config.NewNavigableMap(nil)
|
||||
evNm.Set([]string{utils.MetaReq}, ev.Event, false, false)
|
||||
lockIDs := utils.PrefixSliceItems(rs.IDs(), utils.ResourcesPrefix)
|
||||
guardian.Guardian.Guard(func() (gIface interface{}, gErr error) {
|
||||
for resName := range rIDs {
|
||||
@@ -482,7 +484,7 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREvent,
|
||||
continue
|
||||
}
|
||||
if pass, err := rS.filterS.Pass(ev.Tenant, rPrf.FilterIDs,
|
||||
config.NewNavigableMap(ev.Event)); err != nil {
|
||||
evNm); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -167,6 +167,8 @@ func (sS *StatService) matchingStatQueuesForEvent(args *StatsArgsProcessEvent) (
|
||||
}
|
||||
sqIDs = mapIDs.Slice()
|
||||
}
|
||||
evNm := config.NewNavigableMap(nil)
|
||||
evNm.Set([]string{utils.MetaReq}, args.Event, false, false)
|
||||
for _, sqID := range sqIDs {
|
||||
sqPrfl, err := sS.dm.GetStatQueueProfile(args.Tenant, sqID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
@@ -180,7 +182,7 @@ func (sS *StatService) matchingStatQueuesForEvent(args *StatsArgsProcessEvent) (
|
||||
continue
|
||||
}
|
||||
if pass, err := sS.filterS.Pass(args.Tenant, sqPrfl.FilterIDs,
|
||||
config.NewNavigableMap(args.Event)); err != nil {
|
||||
evNm); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -171,6 +171,8 @@ func (spS *SupplierService) matchingSupplierProfilesForEvent(ev *utils.CGREvent,
|
||||
if singleResult {
|
||||
matchingSLP = make([]*SupplierProfile, 1)
|
||||
}
|
||||
evNm := config.NewNavigableMap(nil)
|
||||
evNm.Set([]string{utils.MetaReq}, ev.Event, false, false)
|
||||
for lpID := range sPrflIDs {
|
||||
splPrfl, err := spS.dm.GetSupplierProfile(ev.Tenant, lpID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
@@ -184,7 +186,7 @@ func (spS *SupplierService) matchingSupplierProfilesForEvent(ev *utils.CGREvent,
|
||||
continue
|
||||
}
|
||||
if pass, err := spS.filterS.Pass(ev.Tenant, splPrfl.FilterIDs,
|
||||
config.NewNavigableMap(ev.Event)); err != nil {
|
||||
evNm); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -231,6 +231,8 @@ func (tS *ThresholdService) matchingThresholdsForEvent(args *ArgsProcessEvent) (
|
||||
}
|
||||
tIDs = tIDsMap.Slice()
|
||||
}
|
||||
evNm := config.NewNavigableMap(nil)
|
||||
evNm.Set([]string{utils.MetaReq}, args.Event, false, false)
|
||||
for _, tID := range tIDs {
|
||||
tPrfl, err := tS.dm.GetThresholdProfile(args.Tenant, tID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
@@ -244,7 +246,7 @@ func (tS *ThresholdService) matchingThresholdsForEvent(args *ArgsProcessEvent) (
|
||||
continue
|
||||
}
|
||||
if pass, err := tS.filterS.Pass(args.Tenant, tPrfl.FilterIDs,
|
||||
config.NewNavigableMap(args.Event)); err != nil {
|
||||
evNm); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user