Started adding test model/routes/views; removed a bit of the old paradigm with tying results directly to hardware

This commit is contained in:
2025-06-10 17:35:52 -04:00
parent 883019b181
commit 47cb580393
16 changed files with 343 additions and 85 deletions

View File

@ -11,79 +11,3 @@
Hardware type: <%= hardware.type %>
</div>
</div>
<hr>
<div class="grix-x grix-margin-x">
<div class="cell small-12">
<form class="u-full-width" action="/result/add" method="post">
<input type="hidden" name="result_hardware" value="<%= hardware.id %>">
<input type="hidden" name="result_referrer" value="hardware">
<div class="grid-x grid-margin-x">
<div class="cell medium-5">
<label for="result_benchmark">
Add benchmark result:
<select class="u-full-width" id="result_benchmark" name="result_benchmark">
<% benchmarks.each do |b| %>
<option value="<%= b.id %>"><%= b.name %></option>
<% end %>
</select>
</label>
</div>
<div class="cell medium-2">
<label for="result_average">
Average score:
<input type="text" id="result_average" name="result_average" value="">
</label>
</div>
<div class="cell medium-2">
<label for="result_minimum">
Minimum score:
<input type="text" id="result_minimum" name="result_minimum" value="">
</label>
</div>
<div class="cell medium-2">
<label for="result_maximum">
Maximum score:
<input type="text" id="result_maximum" name="result_maximum" value="">
</label>
</div>
<div class="cell medium-1">
<input type="submit" class="u-full-width button" value="Submit">
</div>
</div>
</form>
<hr>
<h4>Benchmark results involving this hardware:</h4>
<table>
<thead>
<th>Benchmark name</th>
<th>Scoring type</th>
<th># results</th>
<th>Average</th>
<th>Minimum</th>
<th>Maximum</th>
</thead>
<tbody>
<% hardware.bench_results().each do |k, r| %>
<tr>
<td><%= k %></td>
<td>N/a</td>
<td><%= r.length %></td>
<td><%= average_array(r) %></td>
<td>N/a</td>
<td>N/a</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>

View File

@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><%= title %> | Game Data</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.7.5/css/foundation.min.css">
<link rel="stylesheet" href="/css/remmington.css">
<link rel="stylesheet" href="/css/rimmington.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.7.5/js/foundation.min.js" charset="utf-8"></script>
<script src="/js/edgeville.js" charset="utf-8"></script>

View File

@ -4,7 +4,7 @@
<li><a href="/">Dashboard</a></li>
<li><a href="/hardware">Hardware</a></li>
<li><a href="/benchmark">Benchmarks</a></li>
<li><a href="/result">Results</a></li>
<li><a href="/test">Tests</a></li>
<li><a href="/reports">Reports</a></li>
</ul>
</div>

50
views/test/add.erb Normal file
View File

@ -0,0 +1,50 @@
<div class="grid-x grid-margin-x">
<div class="cell small-12">
<h1>Add new test</h1>
</div>
</div>
<div class="grid-x grid-margin-x">
<form class="cell small-12" action="/test/add" method="post">
<div class="grid-x grid-padding-x">
<div class="cell medium-6">
<label>
Test name
<input type="text" name="test_name" placeholder="My hardware test (01/99)">
</label>
</div>
<div class="cell medium-6">
<label>
Type
<select name="test_hardware">
<% for h in hardware %>
<option value="<%= h.id %>"><%= h.name %></option>
<% end %>
</select>
</label>
</div>
<div class="cell medium-4">
<label>
Benchmarks
<select name="test_benchmarks[]" multiple>
<% for b in benchmarks %>
<option value="<%= b.id %>"><%= b.name %></option>
<% end %>
</select>
</label>
</div>
<div class="cell medium-8">
<label>
Test description
<textarea name="test_description" placeholder="This is my test for a hardware..."></textarea>
</label>
</div>
<input type="submit" class="button" value="Submit">
</form>
</div>

32
views/test/edit.erb Normal file
View File

@ -0,0 +1,32 @@
<div class="grid-x grid-margin-x">
<div class="cell small-12">
<h1>Editing: <%= hardware.name %></h1>
</div>
</div>
<div class="grid-x grid-margin-x">
<form class="cell small-12" action="/hardware/<%= hardware.id %>/edit" method="post">
<div class="grid-x grid-padding-x">
<div class="cell medium-9">
<label>
Hardware name
<input type="text" name="hardware_name" placeholder="Example hardware" value="<%= hardware.name %>">
</label>
</div>
<div class="cell medium-3">
<label>
Type
<select name="hardware_type">
<option value="gpu" <% if hardware.type == 'gpu' %>selected<% end %>>Graphics card</option>
<option value="cpu" <% if hardware.type == 'cpu' %>selected<% end %>>Processor</option>
</select>
</label>
</div>
</div>
<input type="submit" class="button" value="Submit">
</form>
</div>

42
views/test/index.erb Normal file
View File

@ -0,0 +1,42 @@
<div class="grid-x grid-margin-x">
<div class="cell small-12">
<h1>List of tests</h1>
</div>
<div class="cell small-12">
<p>
<a href="/test/add">Add new test</a>
</p>
</div>
</div>
<div class="grid-x grid-margin-x">
<% if tests.length > 0 %>
<div class="cell small-12">
<table>
<thead>
<tr>
<th>Test name</th>
<th># of benchmarks</th>
<th>Date added</th>
<th>Date modified</th>
</tr>
</thead>
<tbody>
<% tests.each do |t| %>
<tr>
<td><a href="/hardware/<%= t.id %>"><%= t.name %></a></td>
<td><%= t.benchmark.length %></td>
<td><%= date_format(t.created_at) %></td>
<td><%= date_format(t.updated_at) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<div class="cell small-12">
<p>I'm sorry, there doesn't appear to be any tests added yet. Check again later!</p>
</div>
<% end %>
</div>

84
views/test/view.erb Normal file
View File

@ -0,0 +1,84 @@
<div class="grid-x grid-margin-x">
<div class="cell small-12">
<h1><%= test.name %></h1>
</div>
<div class="cell small-12">
<p><a href="/test/<%= test.id %>/edit">Edit</a></p>
</div>
<div class="cell small-12">
Hardware tested: <%= test.hardware.name %>
</div>
<div class="cell small-12">
<p><%= test.description %></p>
</div>
</div>
<hr>
<div class="grix-x grix-margin-x">
<div class="cell small-12">
<form class="u-full-width" action="/result/add" method="post">
<input type="hidden" name="result_hardware" value="<%= test.id %>">
<input type="hidden" name="result_referrer" value="test">
<div class="grid-x grid-margin-x">
<div class="cell medium-5">
<label for="result_benchmark">
Add benchmark result:
<select class="u-full-width" id="result_benchmark" name="result_benchmark">
<% test.benchmark.each do |b| %>
<option value="<%= b.id %>"><%= b.name %></option>
<% end %>
</select>
</label>
</div>
<div class="cell medium-2">
<label for="result_average">
Average score:
<input type="text" id="result_average" name="result_average" value="">
</label>
</div>
<div class="cell medium-2">
<label for="result_minimum">
Minimum score:
<input type="text" id="result_minimum" name="result_minimum" value="">
</label>
</div>
<div class="cell medium-2">
<label for="result_maximum">
Maximum score:
<input type="text" id="result_maximum" name="result_maximum" value="">
</label>
</div>
<div class="cell medium-1">
<input type="submit" class="u-full-width button" value="Submit">
</div>
</div>
</form>
<hr>
<h4>Benchmark results for this test:</h4>
<table>
<thead>
<th>Benchmark name</th>
<th>Scoring type</th>
<th># results</th>
<th>Average</th>
<th>Minimum</th>
<th>Maximum</th>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>