mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
[FIX/BE] add clamp maximum value
This commit is contained in:
@@ -625,7 +625,7 @@ func higherIsBetterPercent(actual map[int]map[uint]float64, week int, seriesId u
|
||||
if !ok || val <= 0 {
|
||||
return 0, false
|
||||
}
|
||||
return (val / standard) * 100, true
|
||||
return clampPercent((val / standard) * 100), true
|
||||
}
|
||||
|
||||
func lowerIsBetterPercent(actual map[int]map[uint]float64, week int, seriesId uint, standard float64) (float64, bool) {
|
||||
@@ -636,7 +636,7 @@ func lowerIsBetterPercent(actual map[int]map[uint]float64, week int, seriesId ui
|
||||
if !ok || val <= 0 {
|
||||
return 0, false
|
||||
}
|
||||
return (standard / val) * 100, true
|
||||
return clampPercent((standard / val) * 100), true
|
||||
}
|
||||
|
||||
func metricValue(actual map[int]map[uint]float64, week int, seriesId uint) (float64, bool) {
|
||||
@@ -648,6 +648,16 @@ func metricValue(actual map[int]map[uint]float64, week int, seriesId uint) (floa
|
||||
return val, ok
|
||||
}
|
||||
|
||||
func clampPercent(value float64) float64 {
|
||||
if value < 0 {
|
||||
return 0
|
||||
}
|
||||
if value > 200 {
|
||||
return 200
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func buildComparisonAggregateChart(seriesRows []repository.ComparisonSeries, weeks []int, actual map[int]map[uint]float64) dto.DashboardChartDTO {
|
||||
series := make([]dto.DashboardChartSeriesDTO, 0, len(seriesRows))
|
||||
for _, sRow := range seriesRows {
|
||||
|
||||
Reference in New Issue
Block a user