diff --git a/engine/attributes.go b/engine/attributes.go index ece735b5e..f660d7276 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -314,11 +314,13 @@ func (alS *AttributeService) V1ProcessEvent(args *AttrArgsProcessEvent, processRuns = *args.ProcessRuns } args.CGREvent = args.CGREvent.Clone() + processedPrf := make(utils.StringSet) eNV := utils.MapStorage{ utils.MetaReq: args.CGREvent.Event, utils.MetaOpts: args.APIOpts, utils.MetaVars: utils.MapStorage{ - utils.ProcessRuns: 0, + utils.ProcessRuns: 0, + utils.ProcessedProfileIDs: processedPrf, }, utils.MetaTenant: tnt, } @@ -344,6 +346,7 @@ func (alS *AttributeService) V1ProcessEvent(args *AttrArgsProcessEvent, tnt = evRply.CGREvent.Tenant lastID = evRply.MatchedProfiles[0] matchedIDs = append(matchedIDs, lastID) + processedPrf.Add(lastID) for _, fldName := range evRply.AlteredFields { alteredFields.Add(fldName) } diff --git a/utils/consts.go b/utils/consts.go index c80244f2a..d694ee3eb 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -880,6 +880,7 @@ const ( RouteID = "RouteID" MetaMonthlyEstimated = "*monthly_estimated" ProcessRuns = "ProcessRuns" + ProcessedProfileIDs = "ProcessedProfileIDs" HashtagSep = "#" MetaRounding = "*rounding" StatsNA = -1.0 diff --git a/utils/stringset.go b/utils/stringset.go index 29bdfb807..753e93dac 100644 --- a/utils/stringset.go +++ b/utils/stringset.go @@ -125,3 +125,28 @@ func JoinStringSet(s ...StringSet) (conc StringSet) { } return } + +// added this to implement DataProvieder interface avoid reflect usage in MapStorage + +// String returns the set as a json string ( the fields are not ordered) +func (s StringSet) String() string { return ToJSON(s.AsSlice()) } + +// FieldAsInterface returns an empty structure if the path exists else ErrNotFound +func (s StringSet) FieldAsInterface(fldPath []string) (interface{}, error) { + if len(fldPath) != 1 { + return nil, ErrNotFound + } + val, has := s[fldPath[0]] + if !has { + return nil, ErrNotFound + } + return val, nil +} + +// FieldAsString returns an empty structure as a json string if the path exists else ErrNotFound +func (s StringSet) FieldAsString(fldPath []string) (_ string, err error) { + if _, err = s.FieldAsInterface(fldPath); err != nil { + return + } + return "{}", nil // noting in it as is a empty structure +}