Skip to content

Commit 21875bd

Browse files
committed
t Merge branch 'main' into demo
2 parents 7011906 + 5071c95 commit 21875bd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server/pkg/utils/loadster.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ func HttpReqByType(loads []models.Loadster, reqType string) ([]models.Loadster,
3535

3636
func calcDataTransfer(load []models.Loadster, nsType string) ([]models.Loadster, models.Loadster) {
3737
val := []models.Loadster{}
38+
var lastLoad models.Loadster
3839
data, _ := HttpReqByType(load, nsType)
3940
for _, value := range data {
4041
if value.Count > 0 {
4142
val = append(val, value)
4243
}
4344
}
44-
return val, val[len(val)-1]
45+
if len(val) > 0 {
46+
lastLoad = val[len(val)-1]
47+
}
48+
return val, lastLoad
4549

4650
}
4751
func CalculateRPSByTitle(loadsByServer map[string][]models.Loadster) customModels.CalculatedLoad {

0 commit comments

Comments
 (0)