Files
blt/models/test.go
Gregory Ballantine 008a6a5c72
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
[Issue #11] - added ability to create new benchmark settings profiles
2025-10-22 00:58:32 -04:00

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
}