[Issue #11] - added ability to create new benchmark settings profiles
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
27
models/Benchmark_profile.go
Normal file
27
models/Benchmark_profile.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type BenchmarkProfile struct {
|
||||
gorm.Model
|
||||
Label string
|
||||
Settings string
|
||||
|
||||
// belongs to Benchmark
|
||||
BenchmarkID int
|
||||
Benchmark Benchmark
|
||||
|
||||
// many-to-many with tests
|
||||
Tests []Test `gorm:"many2many:tests_benchmark_profiles;"`
|
||||
|
||||
// has many results
|
||||
Results []Result
|
||||
}
|
||||
|
||||
func (b *BenchmarkProfile) StringID() string {
|
||||
return strconv.Itoa(int(b.ID))
|
||||
}
|
||||
@@ -12,11 +12,8 @@ type Benchmark struct {
|
||||
ScoringType string
|
||||
Description string
|
||||
|
||||
// many-to-many test
|
||||
Tests []Test `gorm:"many2many:tests_benchmarks;"`
|
||||
|
||||
// has many results
|
||||
Results []Result
|
||||
// one-to-many BenchmarkProfiles
|
||||
BenchmarkProfiles []BenchmarkProfile
|
||||
}
|
||||
|
||||
func (b *Benchmark) StringID() string {
|
||||
|
||||
@@ -11,8 +11,8 @@ type Result struct {
|
||||
MaximumScore float32
|
||||
|
||||
// belongs to Benchmark
|
||||
BenchmarkID int
|
||||
Benchmark Benchmark
|
||||
BenchmarkProfileID int
|
||||
BenchmarkProfile BenchmarkProfile
|
||||
|
||||
// belongs to Test
|
||||
TestID int
|
||||
|
||||
@@ -15,15 +15,15 @@ type Test struct {
|
||||
HardwareID int
|
||||
Hardware Hardware
|
||||
|
||||
// many-to-many benchmarks
|
||||
Benchmarks []Benchmark `gorm:"many2many:tests_benchmarks;"`
|
||||
// many-to-many benchmark profiles
|
||||
BenchmarkProfiles []Benchmark `gorm:"many2many:tests_benchmark_profiles;"`
|
||||
|
||||
// has many results
|
||||
Results []Result
|
||||
}
|
||||
|
||||
func (t *Test) SelectedBenchmarks() []string {
|
||||
benchmarks := t.Benchmarks
|
||||
benchmarks := t.BenchmarkProfiles
|
||||
ids := make([]string, len(benchmarks))
|
||||
for i, b := range benchmarks {
|
||||
ids[i] = strconv.Itoa(int(b.ID))
|
||||
@@ -34,7 +34,7 @@ func (t *Test) SelectedBenchmarks() []string {
|
||||
func (t *Test) IsBenchmarkSelected(benchmarkID uint) bool {
|
||||
benchmarkUint := uint(benchmarkID)
|
||||
|
||||
for _, b := range t.Benchmarks {
|
||||
for _, b := range t.BenchmarkProfiles {
|
||||
if b.ID == benchmarkUint {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user