Change from LoadValue to Load for Suppliers

This commit is contained in:
TeoV
2019-08-19 15:17:22 +03:00
committed by Dan Christian Bogos
parent 0e70c57d37
commit fcc0344fcb
4 changed files with 13 additions and 13 deletions

View File

@@ -147,8 +147,8 @@ func (sSpls *SortedSuppliers) SortResourceDescendent() {
// sort based on the following formula (float64(ratio + metricVal) / float64(ratio)) -1 with fallback on Weight
func (sSpls *SortedSuppliers) SortLoadDistribution() {
sort.Slice(sSpls.SortedSuppliers, func(i, j int) bool {
splIVal := ((sSpls.SortedSuppliers[i].SortingData[utils.Ratio].(float64)+sSpls.SortedSuppliers[i].SortingData[utils.LoadValue].(float64))/sSpls.SortedSuppliers[i].SortingData[utils.Ratio].(float64) - 1.0)
splJVal := ((sSpls.SortedSuppliers[j].SortingData[utils.Ratio].(float64)+sSpls.SortedSuppliers[j].SortingData[utils.LoadValue].(float64))/sSpls.SortedSuppliers[j].SortingData[utils.Ratio].(float64) - 1.0)
splIVal := ((sSpls.SortedSuppliers[i].SortingData[utils.Ratio].(float64)+sSpls.SortedSuppliers[i].SortingData[utils.Load].(float64))/sSpls.SortedSuppliers[i].SortingData[utils.Ratio].(float64) - 1.0)
splJVal := ((sSpls.SortedSuppliers[j].SortingData[utils.Ratio].(float64)+sSpls.SortedSuppliers[j].SortingData[utils.Load].(float64))/sSpls.SortedSuppliers[j].SortingData[utils.Ratio].(float64) - 1.0)
if splIVal == splJVal {
return sSpls.SortedSuppliers[i].SortingData[utils.Weight].(float64) > sSpls.SortedSuppliers[j].SortingData[utils.Weight].(float64)
}

View File

@@ -637,25 +637,25 @@ func TestLibSuppliersSortLoadDistribution(t *testing.T) {
&SortedSupplier{
SupplierID: "supplier1",
SortingData: map[string]interface{}{
utils.Weight: 25.0,
utils.Ratio: 4.0,
utils.LoadValue: 3.0,
utils.Weight: 25.0,
utils.Ratio: 4.0,
utils.Load: 3.0,
},
},
&SortedSupplier{
SupplierID: "supplier2",
SortingData: map[string]interface{}{
utils.Weight: 15.0,
utils.Ratio: 10.0,
utils.LoadValue: 5.0,
utils.Weight: 15.0,
utils.Ratio: 10.0,
utils.Load: 5.0,
},
},
&SortedSupplier{
SupplierID: "supplier3",
SortingData: map[string]interface{}{
utils.Weight: 25.0,
utils.Ratio: 1.0,
utils.LoadValue: 1.0,
utils.Weight: 25.0,
utils.Ratio: 1.0,
utils.Load: 1.0,
},
},
},

View File

@@ -443,7 +443,7 @@ func (spS *SupplierService) populateSortingData(ev *utils.CGREvent, spl *Supplie
return nil, false, err
}
}
sortedSpl.SortingData[utils.LoadValue] = metricSum
sortedSpl.SortingData[utils.Load] = metricSum
} else {
metricSupp, err := spS.statMetrics(spl.StatIDs, ev.Tenant) //create metric map for suppier
if err != nil {

View File

@@ -565,7 +565,7 @@ const (
MetaAccount = "*account"
ERs = "ERs"
Ratio = "Ratio"
LoadValue = "LoadValue"
Load = "Load"
)
// Migrator Action