Added result model; added form to submit results

This commit is contained in:
Gregory Ballantine 2024-05-29 11:25:45 -04:00
parent 7e294c8f72
commit 9df8f6c9e1
3 changed files with 59 additions and 1 deletions

View File

@ -21,6 +21,6 @@ func Open() {
}
// Migrate the schema
DB.AutoMigrate(&Test{}, &Hardware{}, &Benchmark{})
DB.AutoMigrate(&Test{}, &Hardware{}, &Benchmark{}, &Result{})
log.Println("Database migrations complete.")
}

23
models/result.go Normal file
View File

@ -0,0 +1,23 @@
package models
import (
"gorm.io/gorm"
)
type Test struct {
gorm.Model
Name string
Description string
// belongs to Hardware
HardwareID int
Hardware Hardware
// belongs to Benchmark
BenchmarkID int
Benchmark Benchmark
// belongs to Test
TestID int
Test Test
}

View File

@ -17,6 +17,41 @@
<hr>
<h4>Add new result:</h4>
<form class="u-full-width" action="/result/add" method="POST">
<div class="row">
<div class="columns seven">
<select class="u-full-width" name="result_benchmark">
{{ range $bm := .test.Benchmarks }}
<option value="{{ $bm.ID }}">{{ $bm.Name }}</option>
{{ end }}
</select>
</div>
<div class="columns one">
<input class="u-full-width" type="number" name="result_avg" value="0">
</div>
<div class="columns one">
<input class="u-full-width" type="number" name="result_min" value="0">
</div>
<div class="columns one">
<input class="u-full-width" type="number" name="result_max" value="0">
</div>
<div class="columns two">
<button class="button-primary u-full-width" type="submit" name="button">Submit</button>
</div>
<input type="hidden" name="result_test" value="{{ .test.ID }}">
<input type="hidden" name="result_hardware" value="{{ .test.Hardware.ID }}">
</div>
</form>
<hr>
<h4>Latest Benchmark Results:</h4>
<p>There are currently no benchmarks recorded in this test.</p>