generate uuid for action triggers

This commit is contained in:
Radu Ioan Fericean
2015-12-14 22:40:49 +02:00
parent ec003006b0
commit 048a499e7b
3 changed files with 8 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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

View File

@@ -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,