Added tests to hardware page

This commit is contained in:
Gregory Ballantine 2024-05-29 12:33:45 -04:00
parent 06262431da
commit fb76f28643
2 changed files with 24 additions and 3 deletions

View File

@ -7,9 +7,30 @@
<hr>
<h4>Latest Benchmark Results:</h4>
<h4>Tests Using This Component:</h4>
<p>There are currently no benchmarks recorded using this hardware component.</p>
{{ $length := len .hardware.Tests }} {{ if eq $length 0 }}
<p>There are currently no tests using this hardware component.</p>
{{ else }}
<table class="u-full-width">
<thead>
<tr>
<th>Test</th>
<th># of Benchmarks</th>
<th>Last Updated</th>
</tr>
</thead>
<tbody>
{{ range $test := .hardware.Tests }}
<tr>
<td><a href="/test/{{ $test.ID }}">{{ $test.Name }}</a></td>
<td>{{ len $test.Benchmarks }}</td>
<td>{{ $test.CreatedAt.Format "01/02/2006 15:04am" }}</td>
</tr>
{{ end }}
</tbody>
</table>
{{ end }}
<hr>

View File

@ -30,7 +30,7 @@ func HardwareGetView(c flamego.Context, t template.Template, data template.Data)
// find hardware from DB
var hardware models.Hardware
models.DB.First(&hardware, hardwareID)
models.DB.Preload("Tests.Benchmarks").First(&hardware, hardwareID)
data["hardware"] = hardware
data["title"] = hardware.Name