From 048a499e7b4ee55f9a979afdd29b5c4ae034278c Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Mon, 14 Dec 2015 22:40:49 +0200 Subject: [PATCH] generate uuid for action triggers --- apier/v1/accounts.go | 2 +- engine/action_trigger.go | 3 ++- engine/tp_reader.go | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apier/v1/accounts.go b/apier/v1/accounts.go index f0213d955..33274dafd 100644 --- a/apier/v1/accounts.go +++ b/apier/v1/accounts.go @@ -202,7 +202,7 @@ func (self *ApierV1) SetAccount(attr utils.AttrSetAccount, reply *string) error if err != nil { return 0, err } - ub.ActionTriggers = atrs + ub.ActionTriggers = atrs.Clone() ub.InitCounters() } if attr.AllowNegative != nil { diff --git a/engine/action_trigger.go b/engine/action_trigger.go index f2776160b..b07f34e3c 100644 --- a/engine/action_trigger.go +++ b/engine/action_trigger.go @@ -30,6 +30,7 @@ import ( type ActionTrigger struct { Id string // for visual identification + Uuid string ThresholdType string //*min_event_counter, *max_event_counter, *min_balance_counter, *max_balance_counter, *min_balance, *max_balance, *exp_balance // stats: *min_asr, *max_asr, *min_acd, *max_acd, *min_tcd, *max_tcd, *min_acc, *max_acc, *min_tcc, *max_tcc, *min_ddc, *max_ddc ThresholdValue float64 @@ -234,7 +235,7 @@ func (atrs ActionTriggers) Clone() ActionTriggers { var newATriggers ActionTriggers for _, atr := range atrs { newAtr := atr.Clone() - newAtr.Id = utils.GenUUID() + newAtr.Uuid = utils.GenUUID() newATriggers = append(newATriggers, newAtr) } return newATriggers diff --git a/engine/tp_reader.go b/engine/tp_reader.go index 5b93103cc..508e496ab 100644 --- a/engine/tp_reader.go +++ b/engine/tp_reader.go @@ -615,6 +615,7 @@ func (tpr *TpReader) LoadActionTriggers() (err error) { return err } atrs[idx] = &ActionTrigger{ + Id: key, ThresholdType: atr.ThresholdType, ThresholdValue: atr.ThresholdValue, Recurrent: atr.Recurrent, @@ -754,6 +755,8 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *TpAccountAction) error minSleep, _ := utils.ParseDurationWithSecs(apiAtr.MinSleep) expTime, _ := utils.ParseDate(apiAtr.BalanceExpirationDate) atrs[idx] = &ActionTrigger{ + Id: key, + Uuid: utils.GenUUID(), ThresholdType: apiAtr.ThresholdType, ThresholdValue: apiAtr.ThresholdValue, Recurrent: apiAtr.Recurrent, @@ -964,6 +967,8 @@ func (tpr *TpReader) LoadCdrStatsFiltered(tag string, save bool) (err error) { minSleep, _ := utils.ParseDurationWithSecs(apiAtr.MinSleep) expTime, _ := utils.ParseDate(apiAtr.BalanceExpirationDate) atrs[idx] = &ActionTrigger{ + Id: triggerTag, + Uuid: utils.GenUUID(), ThresholdType: apiAtr.ThresholdType, ThresholdValue: apiAtr.ThresholdValue, Recurrent: apiAtr.Recurrent,