Remove Blocker from SupplierProfile and add to Supplier

This commit is contained in:
TeoV
2018-01-30 12:50:33 +02:00
committed by Dan Christian Bogos
parent 24f19d6646
commit a12d80d415
15 changed files with 58 additions and 56 deletions

View File

@@ -1023,10 +1023,10 @@ func testV1FIdxSetSupplierProfileIndexes(t *testing.T) {
ResourceIDs: []string{"Res1", "ResGroup2"},
StatIDs: []string{"Stat1"},
Weight: 20,
Blocker: false,
},
},
Blocker: false,
Weight: 10,
Weight: 10,
}
if err := tFIdxRpc.Call("ApierV1.SetSupplierProfile", splPrf, &result); err != nil {
t.Error(err)
@@ -1132,10 +1132,10 @@ func testV1FIdxSetSecondSupplierProfileIndexes(t *testing.T) {
ResourceIDs: []string{"Res1", "ResGroup2"},
StatIDs: []string{"Stat1"},
Weight: 20,
Blocker: false,
},
},
Blocker: false,
Weight: 10,
Weight: 10,
}
if err := tFIdxRpc.Call("ApierV1.SetSupplierProfile", splPrf, &result); err != nil {
t.Error(err)

View File

@@ -237,11 +237,11 @@ func testV1SplSSetSupplierProfiles(t *testing.T) {
ResourceIDs: []string{"Res1", "ResGroup2"},
StatIDs: []string{"Stat1"},
Weight: 20,
Blocker: false,
SupplierParameters: "SortingParameter1",
},
},
Blocker: false,
Weight: 10,
Weight: 10,
}
var result string
if err := splSv1Rpc.Call("ApierV1.SetSupplierProfile", splPrf, &result); err != nil {
@@ -267,6 +267,7 @@ func testV1SplSUpdateSupplierProfiles(t *testing.T) {
ResourceIDs: []string{"Res1", "ResGroup2"},
StatIDs: []string{"Stat1"},
Weight: 20,
Blocker: false,
SupplierParameters: "SortingParameter1",
},
&engine.Supplier{
@@ -277,6 +278,7 @@ func testV1SplSUpdateSupplierProfiles(t *testing.T) {
ResourceIDs: []string{"Res2", "ResGroup2"},
StatIDs: []string{"Stat2"},
Weight: 20,
Blocker: true,
SupplierParameters: "SortingParameter2",
},
}
@@ -289,6 +291,7 @@ func testV1SplSUpdateSupplierProfiles(t *testing.T) {
ResourceIDs: []string{"Res2", "ResGroup2"},
StatIDs: []string{"Stat2"},
Weight: 20,
Blocker: true,
SupplierParameters: "SortingParameter2",
},
&engine.Supplier{
@@ -299,6 +302,7 @@ func testV1SplSUpdateSupplierProfiles(t *testing.T) {
ResourceIDs: []string{"Res1", "ResGroup2"},
StatIDs: []string{"Stat1"},
Weight: 20,
Blocker: false,
SupplierParameters: "SortingParameter1",
},
}

View File

@@ -142,11 +142,11 @@ func testTPSplPrfSetTPSplPrf(t *testing.T) {
ResourceIDs: []string{"ResGroup1"},
StatIDs: []string{"Stat1"},
Weight: 10,
Blocker: false,
SupplierParameters: "SortingParam1",
},
},
Blocker: false,
Weight: 20,
Weight: 20,
}
var result string
if err := tpSplPrfRPC.Call("ApierV1.SetTPSupplierProfile",
@@ -189,6 +189,7 @@ func testTPSplPrfUpdateTPSplPrf(t *testing.T) {
ResourceIDs: []string{"ResGroup1"},
StatIDs: []string{"Stat1"},
Weight: 10,
Blocker: true,
SupplierParameters: "SortingParam1",
},
&utils.TPSupplier{
@@ -199,6 +200,7 @@ func testTPSplPrfUpdateTPSplPrf(t *testing.T) {
ResourceIDs: []string{"ResGroup1"},
StatIDs: []string{"Stat1"},
Weight: 20,
Blocker: false,
SupplierParameters: "SortingParam2",
},
}
@@ -222,6 +224,7 @@ func testTPSplPrfGetTPSplPrfAfterUpdate(t *testing.T) {
ResourceIDs: []string{"ResGroup1"},
StatIDs: []string{"Stat1"},
Weight: 20,
Blocker: false,
SupplierParameters: "SortingParam2",
},
&utils.TPSupplier{
@@ -232,6 +235,7 @@ func testTPSplPrfGetTPSplPrfAfterUpdate(t *testing.T) {
ResourceIDs: []string{"ResGroup1"},
StatIDs: []string{"Stat1"},
Weight: 10,
Blocker: true,
SupplierParameters: "SortingParam1",
},
}

View File

@@ -510,8 +510,8 @@ CREATE TABLE tp_suppliers (
`supplier_resource_ids` varchar(64) NOT NULL,
`supplier_stat_ids` varchar(64) NOT NULL,
`supplier_weight` decimal(8,2) NOT NULL,
`supplier_blocker` BOOLEAN NOT NULL,
`supplier_parameters` varchar(64) NOT NULL,
`blocker` BOOLEAN NOT NULL,
`weight` decimal(8,2) NOT NULL,
`created_at` TIMESTAMP,
PRIMARY KEY (`pk`),

View File

@@ -502,8 +502,8 @@ CREATE TABLE tp_suppliers (
"supplier_resource_ids" varchar(64) NOT NULL,
"supplier_stat_ids" varchar(64) NOT NULL,
"supplier_weight" decimal(8,2) NOT NULL,
"supplier_blocker" BOOLEAN NOT NULL,
"supplier_parameters" varchar(64) NOT NULL,
"blocker" BOOLEAN NOT NULL,
"weight" decimal(8,2) NOT NULL,
"created_at" TIMESTAMP WITH TIME ZONE
);

View File

@@ -1,3 +1,3 @@
#Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParams,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,Blocker,Weight
#Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParams,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,SupplierBlocker,SortingParameters,Weight
cgrates.org,SPL_ACNT_1001,FLTR_ACCOUNT_1001,,*weight,,supplier1,,,,,,20,,,10
cgrates.org,SPL_ACNT_1001,,,,,supplier2,,,,,,10,,,
1 #Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParams,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,Blocker,Weight #Tenant ID FilterIDs ActivationInterval Sorting SortingParams SupplierID SupplierFilterIDs SupplierAccountIDs SupplierRatingPlanIDs SupplierResourceIDs SupplierStatIDs SupplierWeight SupplierBlocker SortingParameters Weight
2 cgrates.org,SPL_ACNT_1001,FLTR_ACCOUNT_1001,,*weight,,supplier1,,,,,,20,,,10 cgrates.org SPL_ACNT_1001 FLTR_ACCOUNT_1001 *weight supplier1 20 10
3 cgrates.org,SPL_ACNT_1001,,,,,supplier2,,,,,,10,,, cgrates.org SPL_ACNT_1001 supplier2 10

View File

@@ -1,4 +1,5 @@
#Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParams,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,Blocker,Weight
cgrates.org,SPP_1,FLTR_ACNT_dan;FLTR_DST_DE,2017-07-29T15:00:00Z,*lowest_cost,,supplier1,FLTR_ACNT_dan,,RPL_1,ResGroup1,Stat1,10,,false,10
cgrates.org,SPL_WEIGHT_1,FLTR_DST_DE;FLTR_ACNT_1007,2017-11-27T00:00:00Z,*weight,,supplier1,,,,,,10,,false,10
cgrates.org,SPL_WEIGHT_1,,,,,supplier2,,,,,,20,,,
#Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParams,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,SupplierBlocker,SortingParameters,Weight
cgrates.org,SPP_1,FLTR_ACNT_dan;FLTR_DST_DE,2017-07-29T15:00:00Z,*lowest_cost,,supplier1,FLTR_ACNT_dan,,RPL_1,ResGroup1,Stat1,10,false,SortingParameter1,10
cgrates.org,SPL_WEIGHT_1,FLTR_DST_DE;FLTR_ACNT_1007,2017-11-27T00:00:00Z,*weight,,supplier1,,,,,,10,,,10
cgrates.org,SPL_WEIGHT_1,FLTR_DST_DE,,,,supplier2,,,,,,20,,,
cgrates.org,SPL_WEIGHT_1,FLTR_ACNT_1007,,,,supplier3,FLTR_ACNT_dan,,,,,15,,,
1 #Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParams,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,Blocker,Weight #Tenant ID FilterIDs ActivationInterval Sorting SortingParams SupplierID SupplierFilterIDs SupplierAccountIDs SupplierRatingPlanIDs SupplierResourceIDs SupplierStatIDs SupplierWeight SupplierBlocker SortingParameters Weight
2 cgrates.org,SPP_1,FLTR_ACNT_dan;FLTR_DST_DE,2017-07-29T15:00:00Z,*lowest_cost,,supplier1,FLTR_ACNT_dan,,RPL_1,ResGroup1,Stat1,10,,false,10 cgrates.org SPP_1 FLTR_ACNT_dan;FLTR_DST_DE 2017-07-29T15:00:00Z *lowest_cost supplier1 FLTR_ACNT_dan RPL_1 ResGroup1 Stat1 10 false SortingParameter1 10
3 cgrates.org,SPL_WEIGHT_1,FLTR_DST_DE;FLTR_ACNT_1007,2017-11-27T00:00:00Z,*weight,,supplier1,,,,,,10,,false,10 cgrates.org SPL_WEIGHT_1 FLTR_DST_DE;FLTR_ACNT_1007 2017-11-27T00:00:00Z *weight supplier1 10 10
4 cgrates.org,SPL_WEIGHT_1,,,,,supplier2,,,,,,20,,, cgrates.org SPL_WEIGHT_1 FLTR_DST_DE supplier2 20
5 cgrates.org SPL_WEIGHT_1 FLTR_ACNT_1007 supplier3 FLTR_ACNT_dan 15

View File

@@ -1,8 +1,8 @@
#Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParams,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,SortingParameters,Blocker,Weight
cgrates.org,SPP_1,FLTR_ACNT_dan;FLTR_DST_DE,2017-07-29T15:00:00Z,*lowest_cost,,supplier1,FLTR_ACNT_dan,,RPL_1,ResGroup1,Stat1,10,SortingParameter1,false,10
cgrates.org,SPL_WEIGHT_1,FLTR_DST_DE;FLTR_ACNT_1007,2017-11-27T00:00:00Z,*weight,,supplier1,,,,,,10,,false,10
#Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParams,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,SupplierBlocker,SortingParameters,Weight
cgrates.org,SPP_1,FLTR_ACNT_dan;FLTR_DST_DE,2017-07-29T15:00:00Z,*lowest_cost,,supplier1,FLTR_ACNT_dan,,RPL_1,ResGroup1,Stat1,10,false,SortingParameter1,10
cgrates.org,SPL_WEIGHT_1,FLTR_DST_DE;FLTR_ACNT_1007,2017-11-27T00:00:00Z,*weight,,supplier1,,,,,,10,,,10
cgrates.org,SPL_WEIGHT_1,FLTR_DST_DE,,,,supplier2,,,,,,20,,,
cgrates.org,SPL_WEIGHT_1,FLTR_ACNT_1007,,,,supplier3,FLTR_ACNT_dan,,,,,15,,,
cgrates.org,SPL_LEASTCOST_1,FLTR_1,2017-11-27T00:00:00Z,*least_cost,,supplier1,,,RP_SPECIAL_1002,,,10,,false,10
cgrates.org,SPL_LEASTCOST_1,FLTR_1,2017-11-27T00:00:00Z,*least_cost,,supplier1,,,RP_SPECIAL_1002,,,10,false,,10
cgrates.org,SPL_LEASTCOST_1,,,,,supplier2,,,RP_RETAIL1,,,20,,,
cgrates.org,SPL_LEASTCOST_1,,,,,supplier3,,,RP_SPECIAL_1002,,,15,,,
1 #Tenant ID FilterIDs ActivationInterval Sorting SortingParams SupplierID SupplierFilterIDs SupplierAccountIDs SupplierRatingPlanIDs SupplierResourceIDs SupplierStatIDs SupplierWeight SupplierBlocker Blocker SortingParameters Weight
2 cgrates.org SPP_1 FLTR_ACNT_dan;FLTR_DST_DE 2017-07-29T15:00:00Z *lowest_cost supplier1 FLTR_ACNT_dan RPL_1 ResGroup1 Stat1 10 false false SortingParameter1 10
3 cgrates.org SPL_WEIGHT_1 FLTR_DST_DE;FLTR_ACNT_1007 2017-11-27T00:00:00Z *weight supplier1 10 false 10
4 cgrates.org SPL_WEIGHT_1 FLTR_DST_DE supplier2 20
5 cgrates.org SPL_WEIGHT_1 FLTR_ACNT_1007 supplier3 FLTR_ACNT_dan 15
6 cgrates.org SPL_LEASTCOST_1 FLTR_1 2017-11-27T00:00:00Z *least_cost supplier1 RP_SPECIAL_1002 10 false false 10
7 cgrates.org SPL_LEASTCOST_1 supplier2 RP_RETAIL1 20
8 cgrates.org SPL_LEASTCOST_1 supplier3 RP_SPECIAL_1002 15

View File

@@ -291,8 +291,8 @@ cgrates.org,FLTR_DST_DE,*destinations,Destination,DST_DE,2014-07-29T15:00:00Z
cgrates.org,FLTR_DST_NL,*destinations,Destination,DST_NL,2014-07-29T15:00:00Z
`
sppProfiles = `
#Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParams,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,SupplierParameters,Blocker,Weight
cgrates.org,SPP_1,FLTR_ACNT_dan,2014-07-29T15:00:00Z,*lowest_cost,,supplier1,FLTR_ACNT_dan,Account1;Account1_1,RPL_1,ResGroup1,Stat1,10,param1,true,20
#Tenant,ID,FilterIDs,ActivationInterval,Sorting,SortingParams,SupplierID,SupplierFilterIDs,SupplierAccountIDs,SupplierRatingPlanIDs,SupplierResourceIDs,SupplierStatIDs,SupplierWeight,SupplierBlocker,SupplierParameters,Weight
cgrates.org,SPP_1,FLTR_ACNT_dan,2014-07-29T15:00:00Z,*lowest_cost,,supplier1,FLTR_ACNT_dan,Account1;Account1_1,RPL_1,ResGroup1,Stat1,10,true,param1,20
cgrates.org,SPP_1,,,,,supplier1,,,RPL_2,ResGroup2,,10,,,
cgrates.org,SPP_1,,,,,supplier1,FLTR_DST_DE,Account2,RPL_3,ResGroup3,Stat2,10,,,
cgrates.org,SPP_1,,,,,supplier1,,,,ResGroup4,Stat3,10,,,
@@ -1652,11 +1652,11 @@ func TestLoadSupplierProfiles(t *testing.T) {
ResourceIDs: []string{"ResGroup1", "ResGroup2", "ResGroup3", "ResGroup4"},
StatIDs: []string{"Stat1", "Stat2", "Stat3"},
Weight: 10,
Blocker: true,
SupplierParameters: "param1",
},
},
Blocker: true,
Weight: 20,
Weight: 20,
},
}
resKey := utils.TenantID{Tenant: "cgrates.org", ID: "SPP_1"}

View File

@@ -2478,7 +2478,6 @@ func (tps TpSuppliers) AsTPSuppliers() (result []*utils.TPSupplierProfile) {
TPid: tp.Tpid,
Tenant: tp.Tenant,
ID: tp.ID,
Blocker: tp.Blocker,
Sorting: tp.Sorting,
SortingParams: []string{},
}
@@ -2490,8 +2489,9 @@ func (tps TpSuppliers) AsTPSuppliers() (result []*utils.TPSupplierProfile) {
sup, found := suppliersMap[tp.ID][tp.SupplierID]
if !found {
sup = &utils.TPSupplier{
ID: tp.SupplierID,
Weight: tp.SupplierWeight,
ID: tp.SupplierID,
Weight: tp.SupplierWeight,
Blocker: tp.SupplierBlocker,
}
}
if tp.SupplierParameters != "" {
@@ -2585,7 +2585,6 @@ func APItoModelTPSuppliers(st *utils.TPSupplierProfile) (mdls TpSuppliers) {
if i == 0 {
mdl.Sorting = st.Sorting
mdl.Weight = st.Weight
mdl.Blocker = st.Blocker
for i, val := range st.FilterIDs {
if i != 0 {
mdl.FilterIDs += utils.INFIELD_SEP
@@ -2645,7 +2644,6 @@ func APItoSupplierProfile(tpTH *utils.TPSupplierProfile, timezone string) (th *S
ID: tpTH.ID,
Sorting: tpTH.Sorting,
Weight: tpTH.Weight,
Blocker: tpTH.Blocker,
Suppliers: make([]*Supplier, len(tpTH.Suppliers)),
}
for _, stp := range tpTH.SortingParams {
@@ -2663,6 +2661,7 @@ func APItoSupplierProfile(tpTH *utils.TPSupplierProfile, timezone string) (th *S
supl := &Supplier{
ID: suplier.ID,
Weight: suplier.Weight,
Blocker: suplier.Blocker,
RatingPlanIDs: suplier.RatingPlanIDs,
FilterIDs: suplier.FilterIDs,
ResourceIDs: suplier.ResourceIDs,

View File

@@ -537,8 +537,8 @@ type TpSupplier struct {
SupplierResourceIDs string `index:"10" re:""`
SupplierStatIDs string `index:"11" re:""`
SupplierWeight float64 `index:"12" re:"\d+\.?\d*"`
SupplierParameters string `index:"13" re:""`
Blocker bool `index:"14" re:""`
SupplierBlocker bool `index:"13" re:""`
SupplierParameters string `index:"14" re:""`
Weight float64 `index:"15" re:"\d+\.?\d*"`
CreatedAt time.Time
}

View File

@@ -39,6 +39,7 @@ type Supplier struct {
ResourceIDs []string // queried in some strategies
StatIDs []string // queried in some strategies
Weight float64
Blocker bool // do not process further supplier after this one
SupplierParameters string
}
@@ -51,7 +52,6 @@ type SupplierProfile struct {
Sorting string // Sorting strategy
SortingParams []string
Suppliers []*Supplier
Blocker bool // do not process further profiles after this one
Weight float64
}
@@ -160,12 +160,6 @@ func (spS *SupplierService) matchingSupplierProfilesForEvent(ev *utils.CGREvent)
i++
}
sPrfls.Sort()
for i, sPrfl := range sPrfls {
if sPrfl.Blocker { // blocker will stop processing
sPrfls = sPrfls[:i+1]
break
}
}
return
}

View File

@@ -52,11 +52,11 @@ var (
ResourceIDs: []string{},
StatIDs: []string{},
Weight: 10.0,
Blocker: false,
SupplierParameters: "param1",
},
},
Blocker: false,
Weight: 10,
Weight: 10,
},
&SupplierProfile{
Tenant: "cgrates.org",
@@ -97,11 +97,11 @@ var (
ResourceIDs: []string{},
StatIDs: []string{},
Weight: 30.0,
Blocker: false,
SupplierParameters: "param1",
},
},
Blocker: false,
Weight: 20.0,
Weight: 20.0,
},
&SupplierProfile{
Tenant: "cgrates.org",
@@ -122,11 +122,11 @@ var (
ResourceIDs: []string{},
StatIDs: []string{},
Weight: 10.0,
Blocker: false,
SupplierParameters: "param1",
},
},
Blocker: false,
Weight: 10,
Weight: 10,
},
&SupplierProfile{
Tenant: "cgrates.org",
@@ -167,11 +167,11 @@ var (
ResourceIDs: []string{},
StatIDs: []string{},
Weight: 30.0,
Blocker: false,
SupplierParameters: "param1",
},
},
Blocker: false,
Weight: 20.0,
Weight: 20.0,
},
}
argPagEv = &ArgsGetSuppliers{
@@ -241,11 +241,11 @@ func TestSuppliersSort(t *testing.T) {
ResourceIDs: []string{},
StatIDs: []string{},
Weight: 10.0,
Blocker: false,
SupplierParameters: "param1",
},
},
Blocker: false,
Weight: 10,
Weight: 10,
},
&SupplierProfile{
Tenant: "cgrates.org",
@@ -266,11 +266,11 @@ func TestSuppliersSort(t *testing.T) {
ResourceIDs: []string{},
StatIDs: []string{},
Weight: 20.0,
Blocker: false,
SupplierParameters: "param1",
},
},
Blocker: false,
Weight: 20.0,
Weight: 20.0,
},
}
eSupplierProfile := SupplierProfiles{
@@ -293,11 +293,11 @@ func TestSuppliersSort(t *testing.T) {
ResourceIDs: []string{},
StatIDs: []string{},
Weight: 20.0,
Blocker: false,
SupplierParameters: "param1",
},
},
Blocker: false,
Weight: 20.0,
Weight: 20.0,
},
&SupplierProfile{
Tenant: "cgrates.org",
@@ -318,11 +318,11 @@ func TestSuppliersSort(t *testing.T) {
ResourceIDs: []string{},
StatIDs: []string{},
Weight: 10.0,
Blocker: false,
SupplierParameters: "param1",
},
},
Blocker: false,
Weight: 10.0,
Weight: 10.0,
},
}
sprs.Sort()

View File

@@ -2012,10 +2012,10 @@ func testMigratorTPSuppliers(t *testing.T) {
ResourceIDs: []string{"ResGroup1"},
StatIDs: []string{"Stat1"},
Weight: 10,
Blocker: false,
},
},
Blocker: false,
Weight: 20,
Weight: 20,
},
}
switch action {

View File

@@ -1387,6 +1387,7 @@ type TPSupplier struct {
ResourceIDs []string // queried in some strategies
StatIDs []string // queried in some strategies
Weight float64
Blocker bool
SupplierParameters string
}
@@ -1399,7 +1400,6 @@ type TPSupplierProfile struct {
Sorting string
SortingParams []string
Suppliers []*TPSupplier
Blocker bool
Weight float64
}