mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added any_context option for AttributeS
This commit is contained in:
committed by
Dan Christian Bogos
parent
73de017591
commit
eae23e1f8e
@@ -32,6 +32,7 @@ type AttributeSCfg struct {
|
||||
SuffixIndexedFields *[]string
|
||||
ProcessRuns int
|
||||
NestedFields bool
|
||||
AnyContext bool
|
||||
}
|
||||
|
||||
func (alS *AttributeSCfg) loadFromJSONCfg(jsnCfg *AttributeSJsonCfg) (err error) {
|
||||
@@ -101,6 +102,9 @@ func (alS *AttributeSCfg) loadFromJSONCfg(jsnCfg *AttributeSJsonCfg) (err error)
|
||||
if jsnCfg.Nested_fields != nil {
|
||||
alS.NestedFields = *jsnCfg.Nested_fields
|
||||
}
|
||||
if jsnCfg.Any_context != nil {
|
||||
alS.AnyContext = *jsnCfg.Any_context
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -684,6 +684,7 @@ const CGRATES_CFG_JSON = `
|
||||
"suffix_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level)
|
||||
"process_runs": 1, // number of run loops when processing event
|
||||
"any_context": true, // if we match the *any context
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -401,6 +401,7 @@ type AttributeSJsonCfg struct {
|
||||
Suffix_indexed_fields *[]string
|
||||
Nested_fields *bool // applies when indexed fields is not defined
|
||||
Process_runs *int
|
||||
Any_context *bool
|
||||
}
|
||||
|
||||
// ChargerSJsonCfg service config section
|
||||
|
||||
@@ -71,11 +71,14 @@ func (alS *AttributeService) attributeProfileForEvent(tnt string, ctx *string, a
|
||||
alS.cgrcfg.AttributeSCfg().IndexedSelects,
|
||||
alS.cgrcfg.AttributeSCfg().NestedFields,
|
||||
)
|
||||
if err != nil {
|
||||
if err != utils.ErrNotFound {
|
||||
return nil, err
|
||||
}
|
||||
if aPrflIDs, err = MatchingItemIDsForEvent(evNm,
|
||||
if err != nil &&
|
||||
err != utils.ErrNotFound {
|
||||
return nil, err
|
||||
}
|
||||
if err == utils.ErrNotFound ||
|
||||
alS.cgrcfg.AttributeSCfg().AnyContext {
|
||||
var aPrflAnyIDs utils.StringSet
|
||||
if aPrflAnyIDs, err = MatchingItemIDsForEvent(evNm,
|
||||
alS.cgrcfg.AttributeSCfg().StringIndexedFields,
|
||||
alS.cgrcfg.AttributeSCfg().PrefixIndexedFields,
|
||||
alS.cgrcfg.AttributeSCfg().SuffixIndexedFields,
|
||||
@@ -85,6 +88,11 @@ func (alS *AttributeService) attributeProfileForEvent(tnt string, ctx *string, a
|
||||
alS.cgrcfg.AttributeSCfg().NestedFields); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if aPrflIDs.Size() == 0 {
|
||||
aPrflIDs = aPrflAnyIDs
|
||||
} else {
|
||||
aPrflIDs = utils.JoinStringSet(aPrflIDs, aPrflAnyIDs)
|
||||
}
|
||||
}
|
||||
attrIDs = aPrflIDs.AsSlice()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user