mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 05:09:54 +05:00
Add MinHits in Threshold
This commit is contained in:
committed by
Dan Christian Bogos
parent
15a0793ff6
commit
70fbd6d71d
@@ -461,6 +461,7 @@ CREATE TABLE tp_thresholds (
|
||||
`filter_field_values` varchar(256) NOT NULL,
|
||||
`activation_interval` varchar(64) NOT NULL,
|
||||
`recurrent` BOOLEAN NOT NULL,
|
||||
`min_hits` int(11) NOT NULL,
|
||||
`min_sleep` varchar(16) NOT NULL,
|
||||
`blocker` BOOLEAN NOT NULL,
|
||||
`weight` decimal(8,2) NOT NULL,
|
||||
|
||||
@@ -456,6 +456,7 @@ CREATE TABLE tp_thresholds (
|
||||
"filter_field_values" varchar(256) NOT NULL,
|
||||
"activation_interval" varchar(64) NOT NULL,
|
||||
"recurrent" BOOLEAN NOT NULL,
|
||||
"min_hits" INTEGER NOT NULL,
|
||||
"min_sleep" varchar(16) NOT NULL,
|
||||
"blocker" BOOLEAN NOT NULL,
|
||||
"weight" decimal(8,2) NOT NULL,
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],Recurrent[6],MinSleep[7],Blocker[8],Weight[9],ActionIDs[10],Async[11]
|
||||
cgrates.org,Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,true,1s,true,10,THRESH1;THRESH2,true
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],Recurrent[6],MinHits[7],MinSleep[8],Blocker[9],Weight[10],ActionIDs[11],Async[12]
|
||||
cgrates.org,Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,true,10,1s,true,10,THRESH1;THRESH2,true
|
||||
|
||||
|
@@ -1,18 +1,18 @@
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],Recurrent[6],MinHits[7],MinSleep[8],Blocker[9],Weight[10],ActionIDs[11],Async[12]
|
||||
cgrates.org,THD_ACNT_BALANCE_1,*string,Account,1001;1002,2014-07-29T15:00:00Z,true,1s,false,10,LOG_WARNING,
|
||||
cgrates.org,THD_ACNT_BALANCE_1,*string,EventType,BalanceUpdate,,,,,,,
|
||||
cgrates.org,THD_ACNT_BALANCE_1,*gte,Units,10.0,,,,,,,
|
||||
cgrates.org,THD_ACNT_EXPIRED,*string,Account,1001;1002,2014-07-29T15:00:00Z,true,1s,false,10,LOG_WARNING,
|
||||
cgrates.org,THD_ACNT_EXPIRED,*gte,ExpiryTime,*now,,,,,,,
|
||||
cgrates.org,THD_STATS_1,*string,EventType,StatUpdate,2014-07-29T15:00:00Z,true,1s,false,10,LOG_WARNING,
|
||||
cgrates.org,THD_STATS_1,*lt,ASR,40.0,,,,,,,
|
||||
cgrates.org,THD_STATS_1,*lt,ACD,3m,,,,,,,
|
||||
cgrates.org,THD_STATS_2,*string,EventType,StatUpdate,2014-07-29T15:00:00Z,true,1s,false,10,DISABLE_AND_LOG,
|
||||
cgrates.org,THD_STATS_2,*string,StatID,STATS_HOURLY_DE,,,,,,,
|
||||
cgrates.org,THD_STATS_2,*gt,TCD,30m,,,,,,,
|
||||
cgrates.org,THD_STATS_3,*string,EventType,StatUpdate,2014-07-29T15:00:00Z,false,1s,false,10,TOPUP_100SMS_DE_MOBILE,
|
||||
cgrates.org,THD_STATS_3,*string,StatID,STATS_DAILY_DE,,,,,,,
|
||||
cgrates.org,THD_STATS_3,*gt,TCD,3h,,,,,,,
|
||||
cgrates.org,THD_RES_1,*string,EventType,ResourceUpdate,2014-07-29T15:00:00Z,true,1s,false,10,LOG_WARNING,
|
||||
cgrates.org,THD_RES_1,*string,ResourceID,RES_GRP_1,,,,,,,
|
||||
cgrates.org,THD_RES_1,*gte,Usage,10.0,,,,,,,
|
||||
cgrates.org,THD_ACNT_BALANCE_1,*string,Account,1001;1002,2014-07-29T15:00:00Z,true,1,1s,false,10,LOG_WARNING,false
|
||||
cgrates.org,THD_ACNT_BALANCE_1,*string,EventType,BalanceUpdate,,,,,,,,
|
||||
cgrates.org,THD_ACNT_BALANCE_1,*gte,Units,10.0,,,,,,,,
|
||||
cgrates.org,THD_ACNT_EXPIRED,*string,Account,1001;1002,2014-07-29T15:00:00Z,true,1,1s,false,10,LOG_WARNING,false
|
||||
cgrates.org,THD_ACNT_EXPIRED,*gte,ExpiryTime,*now,,,,,,,,
|
||||
cgrates.org,THD_STATS_1,*string,EventType,StatUpdate,2014-07-29T15:00:00Z,true,1,1s,false,10,LOG_WARNING,false
|
||||
cgrates.org,THD_STATS_1,*lt,ASR,40.0,,,,,,,,
|
||||
cgrates.org,THD_STATS_1,*lt,ACD,3m,,,,,,,,
|
||||
cgrates.org,THD_STATS_2,*string,EventType,StatUpdate,2014-07-29T15:00:00Z,true,1,1s,false,10,DISABLE_AND_LOG,false
|
||||
cgrates.org,THD_STATS_2,*string,StatID,STATS_HOURLY_DE,,,,,,,,
|
||||
cgrates.org,THD_STATS_2,*gt,TCD,30m,,,,,,,,
|
||||
cgrates.org,THD_STATS_3,*string,EventType,StatUpdate,2014-07-29T15:00:00Z,false,1,1s,false,10,TOPUP_100SMS_DE_MOBILE,false
|
||||
cgrates.org,THD_STATS_3,*string,StatID,STATS_DAILY_DE,,,,,,,,
|
||||
cgrates.org,THD_STATS_3,*gt,TCD,3h,,,,,,,,
|
||||
cgrates.org,THD_RES_1,*string,EventType,ResourceUpdate,2014-07-29T15:00:00Z,true,1,1s,false,10,LOG_WARNING,false
|
||||
cgrates.org,THD_RES_1,*string,ResourceID,RES_GRP_1,,,,,,,,
|
||||
cgrates.org,THD_RES_1,*gte,Usage,10.0,,,,,,,,
|
||||
|
||||
|
@@ -277,9 +277,10 @@ cgrates.org,Stats1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*a
|
||||
`
|
||||
|
||||
thresholds = `
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],Recurrent[6],MinSleep[7],Blocker[8],Weight[9],ActionIDs[10],Async[11]
|
||||
cgrates.org,Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,true,1s,true,10,THRESH1;THRESH2,true
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],Recurrent[6],MinHits[7],MinSleep[8],Blocker[9],Weight[10],ActionIDs[11],Async[12]
|
||||
cgrates.org,Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,true,10,1s,true,10,THRESH1;THRESH2,true
|
||||
`
|
||||
|
||||
filters = `
|
||||
#Tenant[0],ID[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5]
|
||||
cgrates.org,FLTR_1,*string,Account,1001;1002,2014-07-29T15:00:00Z
|
||||
@@ -1494,6 +1495,7 @@ func TestLoadThresholdProfiles(t *testing.T) {
|
||||
ActivationTime: "2014-07-29T15:00:00Z",
|
||||
},
|
||||
Recurrent: true,
|
||||
MinHits: 10,
|
||||
MinSleep: "1s",
|
||||
Blocker: true,
|
||||
Weight: 10,
|
||||
|
||||
@@ -2137,6 +2137,7 @@ func (tps TpThresholdS) AsTPThreshold() (result []*utils.TPThreshold) {
|
||||
ID: tp.ID,
|
||||
Blocker: tp.Blocker,
|
||||
Recurrent: tp.Recurrent,
|
||||
MinHits: tp.MinHits,
|
||||
MinSleep: tp.MinSleep,
|
||||
Async: tp.Async,
|
||||
}
|
||||
@@ -2188,6 +2189,7 @@ func APItoModelTPThreshold(th *utils.TPThreshold) (mdls TpThresholdS) {
|
||||
mdl.Blocker = th.Blocker
|
||||
mdl.Weight = th.Weight
|
||||
mdl.Recurrent = th.Recurrent
|
||||
mdl.MinHits = th.MinHits
|
||||
mdl.MinSleep = th.MinSleep
|
||||
mdl.Async = th.Async
|
||||
if th.ActivationInterval != nil {
|
||||
@@ -2225,6 +2227,7 @@ func APItoThresholdProfile(tpTH *utils.TPThreshold, timezone string) (th *Thresh
|
||||
Tenant: tpTH.Tenant,
|
||||
ID: tpTH.ID,
|
||||
Recurrent: tpTH.Recurrent,
|
||||
MinHits: tpTH.MinHits,
|
||||
Weight: tpTH.Weight,
|
||||
Blocker: tpTH.Blocker,
|
||||
Async: tpTH.Async,
|
||||
|
||||
@@ -945,6 +945,7 @@ func TestAsTPThresholdAsAsTPThreshold(t *testing.T) {
|
||||
FilterFieldValues: "1001;1002",
|
||||
ActivationInterval: "2014-07-29T15:00:00Z",
|
||||
Recurrent: false,
|
||||
MinHits: 10,
|
||||
MinSleep: "1s",
|
||||
Blocker: false,
|
||||
Weight: 20.0,
|
||||
@@ -967,6 +968,7 @@ func TestAsTPThresholdAsAsTPThreshold(t *testing.T) {
|
||||
},
|
||||
MinSleep: tps[0].MinSleep,
|
||||
Recurrent: tps[0].Recurrent,
|
||||
MinHits: tps[0].MinHits,
|
||||
Blocker: tps[0].Blocker,
|
||||
Weight: tps[0].Weight,
|
||||
ActionIDs: []string{"WARN3"},
|
||||
@@ -987,6 +989,7 @@ func TestAPItoTPThreshold(t *testing.T) {
|
||||
},
|
||||
ActivationInterval: &utils.TPActivationInterval{ActivationTime: "2014-07-29T15:00:00Z"},
|
||||
Recurrent: false,
|
||||
MinHits: 10,
|
||||
MinSleep: "1s",
|
||||
Blocker: false,
|
||||
Weight: 20.0,
|
||||
@@ -998,6 +1001,7 @@ func TestAPItoTPThreshold(t *testing.T) {
|
||||
Filters: make([]*RequestFilter, len(tps.Filters)),
|
||||
Recurrent: tps.Recurrent,
|
||||
Blocker: tps.Blocker,
|
||||
MinHits: tps.MinHits,
|
||||
Weight: tps.Weight,
|
||||
ActionIDs: []string{"WARN3"},
|
||||
}
|
||||
|
||||
@@ -510,11 +510,12 @@ type TpThreshold struct {
|
||||
FilterFieldValues string `index:"4" re:""`
|
||||
ActivationInterval string `index:"5" re:""`
|
||||
Recurrent bool `index:"6" re:""`
|
||||
MinSleep string `index:"7" re:""`
|
||||
Blocker bool `index:"8" re:""`
|
||||
Weight float64 `index:"9" re:"\d+\.?\d*"`
|
||||
ActionIDs string `index:"10" re:""`
|
||||
Async bool `index:"8" re:""`
|
||||
MinHits int `index:"7" re:""`
|
||||
MinSleep string `index:"8" re:""`
|
||||
Blocker bool `index:"9" re:""`
|
||||
Weight float64 `index:"10" re:"\d+\.?\d*"`
|
||||
ActionIDs string `index:"11" re:""`
|
||||
Async bool `index:"12" re:""`
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ type ThresholdProfile struct {
|
||||
Filters []*RequestFilter // Filters for the request
|
||||
ActivationInterval *utils.ActivationInterval // Time when this limit becomes active and expires
|
||||
Recurrent bool
|
||||
MinHits int
|
||||
MinSleep time.Duration
|
||||
Blocker bool // blocker flag to stop processing on filters matched
|
||||
Weight float64 // Weight to sort the thresholds
|
||||
|
||||
@@ -1362,6 +1362,7 @@ type TPThreshold struct {
|
||||
Filters []*TPRequestFilter // Filters for the request
|
||||
ActivationInterval *TPActivationInterval // Time when this limit becomes active and expires
|
||||
Recurrent bool
|
||||
MinHits int
|
||||
MinSleep string
|
||||
Blocker bool // blocker flag to stop processing on filters matched
|
||||
Weight float64 // Weight to sort the thresholds
|
||||
|
||||
Reference in New Issue
Block a user