Added any_context option for AttributeS

This commit is contained in:
Trial97
2021-05-12 11:58:40 +03:00
committed by Dan Christian Bogos
parent c28ac62968
commit ccdeea7b9b
3 changed files with 19 additions and 5 deletions

View File

@@ -73,11 +73,14 @@ func (alS *AttributeService) attributeProfileForEvent(apiCtx *context.Context, t
alS.cgrcfg.AttributeSCfg().IndexedSelects,
alS.cgrcfg.AttributeSCfg().NestedFields,
)
if err != nil {
if err != utils.ErrNotFound {
return nil, err
}
if aPrflIDs, err = MatchingItemIDsForEvent(apiCtx, 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,
@@ -87,6 +90,11 @@ func (alS *AttributeService) attributeProfileForEvent(apiCtx *context.Context, t
alS.cgrcfg.AttributeSCfg().NestedFields); err != nil {
return nil, err
}
if aPrflIDs.Size() == 0 {
aPrflIDs = aPrflAnyIDs
} else {
aPrflIDs = utils.JoinStringSet(aPrflIDs, aPrflAnyIDs)
}
}
attrIDs = aPrflIDs.AsSlice()
}