mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Reverting *req in filter prefixes
This commit is contained in:
@@ -59,7 +59,6 @@ func (alS *AttributeService) Shutdown() (err error) {
|
||||
|
||||
// matchingAttributeProfilesForEvent returns ordered list of matching resources which are active by the time of the call
|
||||
func (alS *AttributeService) attributeProfileForEvent(args *AttrArgsProcessEvent) (matchAttrPrfl *AttributeProfile, err error) {
|
||||
fmt.Println("enter in attributeProfile for Event")
|
||||
var attrIDs []string
|
||||
contextVal := utils.META_DEFAULT
|
||||
if args.Context != nil && *args.Context != "" {
|
||||
@@ -85,9 +84,6 @@ func (alS *AttributeService) attributeProfileForEvent(args *AttrArgsProcessEvent
|
||||
}
|
||||
attrIDs = aPrflIDs.Slice()
|
||||
}
|
||||
fmt.Println("attrIDs :", attrIDs)
|
||||
evNm := config.NewNavigableMap(nil)
|
||||
evNm.Set([]string{utils.MetaReq}, args.Event, false, false)
|
||||
for _, apID := range attrIDs {
|
||||
aPrfl, err := alS.dm.GetAttributeProfile(args.Tenant, apID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
@@ -101,7 +97,7 @@ func (alS *AttributeService) attributeProfileForEvent(args *AttrArgsProcessEvent
|
||||
continue
|
||||
}
|
||||
if pass, err := alS.filterS.Pass(args.Tenant, aPrfl.FilterIDs,
|
||||
evNm); err != nil {
|
||||
config.NewNavigableMap(args.Event)); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
@@ -165,13 +161,11 @@ 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,
|
||||
evNm); err != nil {
|
||||
config.NewNavigableMap(args.Event)); 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:~*req.DistinctMatch:20"},
|
||||
FilterIDs: []string{"*gte:~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: "~*req.Attribute",
|
||||
FieldName: "~Attribute",
|
||||
Values: []string{"AttributeProfile1"},
|
||||
},
|
||||
{
|
||||
Type: utils.MetaGreaterOrEqual,
|
||||
FieldName: "~*req.UsageInterval",
|
||||
FieldName: "~UsageInterval",
|
||||
Values: []string{(1 * time.Second).String()},
|
||||
},
|
||||
{
|
||||
Type: utils.MetaGreaterOrEqual,
|
||||
FieldName: utils.DynamicDataPrefix + utils.MetaReq + utils.NestingSep + utils.Weight,
|
||||
FieldName: utils.DynamicDataPrefix + utils.Weight,
|
||||
Values: []string{"9.0"},
|
||||
},
|
||||
},
|
||||
@@ -197,7 +197,7 @@ func TestAttributeAddFilters(t *testing.T) {
|
||||
Rules: []*FilterRule{
|
||||
{
|
||||
Type: utils.MetaString,
|
||||
FieldName: "~*req.Attribute",
|
||||
FieldName: "~Attribute",
|
||||
Values: []string{"AttributeProfile2"},
|
||||
},
|
||||
},
|
||||
@@ -209,7 +209,7 @@ func TestAttributeAddFilters(t *testing.T) {
|
||||
Rules: []*FilterRule{
|
||||
{
|
||||
Type: utils.MetaPrefix,
|
||||
FieldName: "~*req.Attribute",
|
||||
FieldName: "~Attribute",
|
||||
Values: []string{"AttributeProfilePrefix"},
|
||||
},
|
||||
},
|
||||
@@ -221,7 +221,7 @@ func TestAttributeAddFilters(t *testing.T) {
|
||||
Rules: []*FilterRule{
|
||||
{
|
||||
Type: utils.MetaGreaterOrEqual,
|
||||
FieldName: utils.DynamicDataPrefix + utils.MetaReq + utils.NestingSep + utils.Weight,
|
||||
FieldName: utils.DynamicDataPrefix + utils.Weight,
|
||||
Values: []string{"200.00"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -421,11 +421,9 @@ 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, nM); err != nil {
|
||||
cfgFld.Filters, config.NewNavigableMap(cdr.AsMapStringIface())); err != nil {
|
||||
return []string{}, err
|
||||
} else if !pass {
|
||||
continue
|
||||
@@ -446,11 +444,9 @@ 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, nM); err != nil {
|
||||
cfgFld.Filters, config.NewNavigableMap(cdr.AsMapStringIface())); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -388,10 +388,8 @@ 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, cgrDp); err != nil || !pass {
|
||||
cdre.exportTemplate.Filters, config.NewNavigableMap(cdr.AsMapStringIface())); err != nil || !pass {
|
||||
continue // Not passes filters, ignore this CDR
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +69,6 @@ func (cS *ChargerService) matchingChargerProfilesForEvent(cgrEv *utils.CGREventW
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
evNm := config.NewNavigableMap(nil)
|
||||
evNm.Set([]string{utils.MetaReq}, cgrEv.Event, false, false)
|
||||
matchingCPs := make(map[string]*ChargerProfile)
|
||||
for cpID := range cpIDs {
|
||||
cP, err := cS.dm.GetChargerProfile(cgrEv.Tenant, cpID, true, true, utils.NonTransactional)
|
||||
@@ -85,7 +83,7 @@ func (cS *ChargerService) matchingChargerProfilesForEvent(cgrEv *utils.CGREventW
|
||||
continue
|
||||
}
|
||||
if pass, err := cS.filterS.Pass(cgrEv.Tenant, cP.FilterIDs,
|
||||
evNm); err != nil {
|
||||
config.NewNavigableMap(cgrEv.Event)); 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 + utils.MetaReq + utils.NestingSep + fldName
|
||||
fldName = utils.DynamicDataPrefix + fldName
|
||||
}
|
||||
var dbItemIDs utils.StringMap // list of items matched in DB
|
||||
for _, val := range fldVals {
|
||||
|
||||
@@ -107,7 +107,6 @@ func (fS *FilterS) connRALs(ralSChan chan rpcclient.RpcClientConnection) (err er
|
||||
// receives the event as DataProvider so we can accept undecoded data (ie: HttpRequest)
|
||||
func (fS *FilterS) Pass(tenant string, filterIDs []string,
|
||||
ev config.DataProvider) (pass bool, err error) {
|
||||
fmt.Println("filterIDs: ", filterIDs)
|
||||
var fieldNameDP config.DataProvider
|
||||
var fieldValuesDP []config.DataProvider
|
||||
if len(filterIDs) == 0 {
|
||||
@@ -550,10 +549,8 @@ func (fS *FilterS) getFieldNameDataProvider(initialDP config.DataProvider,
|
||||
//convert ifaceStatValues into a NavigableMap
|
||||
dp = config.NewNavigableMap(ifaceStatValues)
|
||||
*fieldName = utils.DynamicDataPrefix + splitFldName[2]
|
||||
case strings.HasPrefix(*fieldName, utils.DynamicDataPrefix+utils.MetaReq):
|
||||
dp = initialDP
|
||||
default:
|
||||
return nil, utils.ErrPrefixNotFound(fmt.Sprintf(" data provider prefix for <%s>", *fieldName))
|
||||
dp = initialDP
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -216,11 +216,9 @@ 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(),
|
||||
evNm); err != nil {
|
||||
config.NewNavigableMap(ev.Event)); err != nil {
|
||||
return
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -466,8 +466,6 @@ 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 {
|
||||
@@ -484,7 +482,7 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREvent,
|
||||
continue
|
||||
}
|
||||
if pass, err := rS.filterS.Pass(ev.Tenant, rPrf.FilterIDs,
|
||||
evNm); err != nil {
|
||||
config.NewNavigableMap(ev.Event)); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -167,8 +167,6 @@ 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 {
|
||||
@@ -182,7 +180,7 @@ func (sS *StatService) matchingStatQueuesForEvent(args *StatsArgsProcessEvent) (
|
||||
continue
|
||||
}
|
||||
if pass, err := sS.filterS.Pass(args.Tenant, sqPrfl.FilterIDs,
|
||||
evNm); err != nil {
|
||||
config.NewNavigableMap(args.Event)); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -171,8 +171,6 @@ 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 {
|
||||
@@ -186,7 +184,7 @@ func (spS *SupplierService) matchingSupplierProfilesForEvent(ev *utils.CGREvent,
|
||||
continue
|
||||
}
|
||||
if pass, err := spS.filterS.Pass(ev.Tenant, splPrfl.FilterIDs,
|
||||
evNm); err != nil {
|
||||
config.NewNavigableMap(ev.Event)); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -231,8 +231,6 @@ 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 {
|
||||
@@ -246,7 +244,7 @@ func (tS *ThresholdService) matchingThresholdsForEvent(args *ArgsProcessEvent) (
|
||||
continue
|
||||
}
|
||||
if pass, err := tS.filterS.Pass(args.Tenant, tPrfl.FilterIDs,
|
||||
evNm); err != nil {
|
||||
config.NewNavigableMap(args.Event)); err != nil {
|
||||
return nil, err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user