Files
blt/models/test.go
Gregory Ballantine 352950467c
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending
Finishing the test/edit route
2025-10-02 11:28:56 -04:00

45 lines
770 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 benchmarks
Benchmarks []Benchmark `gorm:"many2many:tests_benchmarks;"`
// has many results
Results []Result
}
func (t *Test) SelectedBenchmarks() []string {
benchmarks := t.Benchmarks
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.Benchmarks {
if b.ID == benchmarkUint {
return true
}
}
return false
}