Fix bugs and failed testcases

This commit is contained in:
2024-07-04 14:14:27 +02:00
parent 1b70596735
commit 80c46bea7f
7 changed files with 833 additions and 802 deletions

View File

@@ -4,7 +4,10 @@
// license that can be found in the LICENSE file.
package util
import "golang.org/x/exp/constraints"
import (
"github.com/ClusterCockpit/cc-backend/pkg/schema"
"golang.org/x/exp/constraints"
)
func Min[T constraints.Ordered](a, b T) T {
if a < b {
@@ -19,3 +22,15 @@ func Max[T constraints.Ordered](a, b T) T {
}
return b
}
func LoadJobStat(job *schema.JobMeta, metric string) float64 {
if stats, ok := job.Statistics[metric]; ok {
if metric == "mem_used" {
return stats.Max
} else {
return stats.Avg
}
}
return 0.0
}