diff --git a/data/tariffplans/prepaid1centpsec/ActionTriggers.csv b/data/tariffplans/prepaid1centpsec/ActionTriggers.csv index 22d063dfa..9e3929114 100644 --- a/data/tariffplans/prepaid1centpsec/ActionTriggers.csv +++ b/data/tariffplans/prepaid1centpsec/ActionTriggers.csv @@ -1,4 +1,4 @@ #Tag,BalanceType,Direction,ThresholdType,ThresholdValue,DestinationTag,ActionsTag,Weight -STANDARD_TRIGGERS,*monetary,*out,*min_balance,2,,LOG_BALANCE,10 -STANDARD_TRIGGERS,*monetary,*out,*max_balance,20,,LOG_BALANCE,10 -STANDARD_TRIGGERS,*monetary,*out,*max_counter,15,FS_USERS,LOG_BALANCE,10 +STANDARD_TRIGGERS,*monetary,*out,*min_balance,2,false,,LOG_BALANCE,10 +STANDARD_TRIGGERS,*monetary,*out,*max_balance,20,false,,LOG_BALANCE,10 +STANDARD_TRIGGERS,*monetary,*out,*max_counter,15,false,FS_USERS,LOG_BALANCE,10 diff --git a/engine/action_trigger.go b/engine/action_trigger.go index c5b73f75f..bac755d7e 100644 --- a/engine/action_trigger.go +++ b/engine/action_trigger.go @@ -32,11 +32,11 @@ type ActionTrigger struct { Direction string ThresholdType string //*min_counter, *max_counter, *min_balance, *max_balance ThresholdValue float64 + Recurrent bool // reset eexcuted flag each run DestinationId string Weight float64 ActionsId string Executed bool - Recurrent bool } func (at *ActionTrigger) Execute(ub *Account) (err error) { diff --git a/engine/loader_csv.go b/engine/loader_csv.go index f940f2a1e..573886f91 100644 --- a/engine/loader_csv.go +++ b/engine/loader_csv.go @@ -676,7 +676,11 @@ func (csvr *CSVReader) LoadActionTriggers() (err error) { if err != nil { return fmt.Errorf("Could not parse action trigger value: %v", err) } - weight, err := strconv.ParseFloat(record[7], 64) + recurrent, err := strconv.ParseBool(record[5]) + if err != nil { + return fmt.Errorf("Could not parse action trigger recurrent flag: %v", err) + } + weight, err := strconv.ParseFloat(record[8], 64) if err != nil { return fmt.Errorf("Could not parse action trigger weight: %v", err) } @@ -686,8 +690,9 @@ func (csvr *CSVReader) LoadActionTriggers() (err error) { Direction: record[2], ThresholdType: record[3], ThresholdValue: value, - DestinationId: record[5], - ActionsId: record[6], + Recurrent: recurrent, + DestinationId: record[6], + ActionsId: record[7], Weight: weight, } csvr.actionsTriggers[tag] = append(csvr.actionsTriggers[tag], at) diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 916d2f0d8..8d08b2353 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -158,11 +158,11 @@ TOPUP_SHARED10_AT,SE10,ASAP,10 TOPUP_EMPTY_AT,EE0,ASAP,10 ` actionTriggers = ` -STANDARD_TRIGGER,*call_duration,*out,*min_counter,10,GERMANY_O2,SOME_1,10 -STANDARD_TRIGGER,*call_duration,*out,*max_balance,200,GERMANY,SOME_2,10 -STANDARD_TRIGGERS,*monetary,*out,*min_balance,2,,LOG_WARNING,10 -STANDARD_TRIGGERS,*monetary,*out,*max_balance,20,,LOG_WARNING,10 -STANDARD_TRIGGERS,*monetary,*out,*max_counter,5,FS_USERS,LOG_WARNING,10 +STANDARD_TRIGGER,*call_duration,*out,*min_counter,10,false,GERMANY_O2,SOME_1,10 +STANDARD_TRIGGER,*call_duration,*out,*max_balance,200,false,GERMANY,SOME_2,10 +STANDARD_TRIGGERS,*monetary,*out,*min_balance,2,false,,LOG_WARNING,10 +STANDARD_TRIGGERS,*monetary,*out,*max_balance,20,false,,LOG_WARNING,10 +STANDARD_TRIGGERS,*monetary,*out,*max_counter,5,false,FS_USERS,LOG_WARNING,10 ` accountActions = ` vdf,minitsboy;a1;a2,*out,MORE_MINUTES,STANDARD_TRIGGER diff --git a/engine/loader_db.go b/engine/loader_db.go index d5baee716..993454094 100644 --- a/engine/loader_db.go +++ b/engine/loader_db.go @@ -529,6 +529,7 @@ func (dbr *DbReader) LoadActionTriggers() (err error) { DestinationId: apiAtr.DestinationId, Weight: apiAtr.Weight, ActionsId: apiAtr.ActionsId, + Recurrent: apiAtr.Recurrent, } } dbr.actionsTriggers[key] = atrs diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 895093848..ec359b849 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -1137,7 +1137,8 @@ func (self *SQLStorage) GetTpActionTriggers(tpid, tag string) (map[string][]*uti for rows.Next() { var threshold, weight float64 var tpid, tag, balances_type, direction, destinations_tag, actions_tag, thresholdType string - if err := rows.Scan(&tpid, &tag, &balances_type, &direction, &thresholdType, &threshold, &destinations_tag, &actions_tag, &weight); err != nil { + var recurrent bool + if err := rows.Scan(&tpid, &tag, &balances_type, &direction, &thresholdType, &threshold, &recurrent, &destinations_tag, &actions_tag, &weight); err != nil { return nil, err } diff --git a/utils/apitpdata.go b/utils/apitpdata.go index 9ef7beb19..f7571cc3c 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -245,6 +245,7 @@ type TPActionTrigger struct { Direction string // Traffic direction ThresholdType string // This threshold type ThresholdValue float64 // Threshold + Recurrent bool // reset executed flag each run DestinationId string // Id of the destination profile ActionsId string // Actions which will execute on threshold reached Weight float64 // weight diff --git a/utils/consts.go b/utils/consts.go index 612821ca8..5ae710082 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -56,7 +56,7 @@ const ( SHARED_GROUPS_NRCOLS = 4 ACTIONS_NRCOLS = 12 ACTION_PLANS_NRCOLS = 4 - ACTION_TRIGGERS_NRCOLS = 8 + ACTION_TRIGGERS_NRCOLS = 9 ACCOUNT_ACTIONS_NRCOLS = 5 DERIVED_CHARGERS_NRCOLS = 16 ROUNDING_UP = "*up"