All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
45 lines
804 B
Go
45 lines
804 B
Go
package models
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Test struct {
|
|
gorm.Model
|
|
Name string
|
|
Description string
|
|
|
|
// belongs to hardware
|
|
HardwareID int
|
|
Hardware Hardware
|
|
|
|
// many-to-many benchmark profiles
|
|
BenchmarkProfiles []Benchmark `gorm:"many2many:tests_benchmark_profiles;"`
|
|
|
|
// has many results
|
|
Results []Result
|
|
}
|
|
|
|
func (t *Test) SelectedBenchmarks() []string {
|
|
benchmarks := t.BenchmarkProfiles
|
|
ids := make([]string, len(benchmarks))
|
|
for i, b := range benchmarks {
|
|
ids[i] = strconv.Itoa(int(b.ID))
|
|
}
|
|
return ids
|
|
}
|
|
|
|
func (t *Test) IsBenchmarkSelected(benchmarkID uint) bool {
|
|
benchmarkUint := uint(benchmarkID)
|
|
|
|
for _, b := range t.BenchmarkProfiles {
|
|
if b.ID == benchmarkUint {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|