Added result model; added form to submit results
This commit is contained in:
		| @@ -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
									
								
							
							
						
						
									
										23
									
								
								models/result.go
									
									
									
									
									
										Normal 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 | ||||
| } | ||||
| @@ -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> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user