33 lines
559 B
Go
33 lines
559 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
|
|
}
|