Added back reference associations for result; added table of results to test view
This commit is contained in:
parent
8df9b7684f
commit
3eca29c2db
@ -11,5 +11,8 @@ type Benchmark struct {
|
|||||||
Description string
|
Description string
|
||||||
|
|
||||||
// many-to-many test
|
// many-to-many test
|
||||||
Tests[] Test `gorm:"many2many:tests_benchmarks;"`
|
Tests []Test `gorm:"many2many:tests_benchmarks;"`
|
||||||
|
|
||||||
|
// has many results
|
||||||
|
Results []Result
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,8 @@ type Hardware struct {
|
|||||||
Type string
|
Type string
|
||||||
|
|
||||||
// has many tests
|
// has many tests
|
||||||
Tests[] Test
|
Tests []Test
|
||||||
|
|
||||||
|
// has many results
|
||||||
|
Results []Result
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,8 @@ type Test struct {
|
|||||||
Hardware Hardware
|
Hardware Hardware
|
||||||
|
|
||||||
// many-to-many benchmarks
|
// many-to-many benchmarks
|
||||||
Benchmarks[] Benchmark `gorm:"many2many:tests_benchmarks;"`
|
Benchmarks []Benchmark `gorm:"many2many:tests_benchmarks;"`
|
||||||
|
|
||||||
|
// has many results
|
||||||
|
Results []Result
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,32 @@
|
|||||||
|
|
||||||
<h4>Latest Benchmark Results:</h4>
|
<h4>Latest Benchmark Results:</h4>
|
||||||
|
|
||||||
|
{{ $length := len .test.Results }} {{ if eq $length 0 }}
|
||||||
<p>There are currently no benchmarks recorded in this test.</p>
|
<p>There are currently no benchmarks recorded in this test.</p>
|
||||||
|
{{ else }}
|
||||||
|
<table class="u-full-width">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Hardware</th>
|
||||||
|
<th>Benchmark</th>
|
||||||
|
<th>Average</th>
|
||||||
|
<th>Minimum</th>
|
||||||
|
<th>Maximum</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{ range $res := .test.Results }}
|
||||||
|
<tr>
|
||||||
|
<td>{{ $res.Hardware.Name }}</td>
|
||||||
|
<td>{{ $res.Benchmark.Name }}</td>
|
||||||
|
<td>{{ $res.AverageScore }}</td>
|
||||||
|
<td>{{ $res.MinimumScore }}</td>
|
||||||
|
<td>{{ $res.MaximumScore }}</td>
|
||||||
|
</tr>
|
||||||
|
{{ end }}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ func TestGetView(c flamego.Context, t template.Template, data template.Data) {
|
|||||||
|
|
||||||
// find hardware from DB
|
// find hardware from DB
|
||||||
var test models.Test
|
var test models.Test
|
||||||
models.DB.Preload("Hardware").Preload("Benchmarks").First(&test, testID)
|
models.DB.Preload("Hardware").Preload("Benchmarks").Preload("Results").First(&test, testID)
|
||||||
data["test"] = test
|
data["test"] = test
|
||||||
|
|
||||||
data["title"] = test.Name
|
data["title"] = test.Name
|
||||||
|
Loading…
Reference in New Issue
Block a user