[Issue #11] - added ability to create new benchmark settings profiles
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -18,11 +18,23 @@ func ApiV1BenchmarkDetails(c flamego.Context, r flamego.Render) {
|
||||
// find benchmark from DB
|
||||
var benchmark models.Benchmark
|
||||
models.DB.First(&benchmark, benchmarkID)
|
||||
|
||||
|
||||
// return JSON response
|
||||
r.JSON(200, benchmark)
|
||||
}
|
||||
|
||||
func ApiV1BenchmarkProfileDetails(c flamego.Context, r flamego.Render) {
|
||||
// find benchmark ID from request
|
||||
benchmarkProfileID := c.Query("benchmark_profile_id")
|
||||
|
||||
// find benchmark from DB
|
||||
var benchmarkProfile models.BenchmarkProfile
|
||||
models.DB.Preload("BenchmarkProfiles").First(&benchmarkProfile, benchmarkProfileID)
|
||||
|
||||
// return JSON response
|
||||
r.JSON(200, benchmarkProfile)
|
||||
}
|
||||
|
||||
func ApiV1ResultAdd(c flamego.Context, form forms.ResultForm, errs binding.Errors, r flamego.Render) {
|
||||
if len(errs) > 0 {
|
||||
var err error
|
||||
@@ -36,8 +48,8 @@ func ApiV1ResultAdd(c flamego.Context, form forms.ResultForm, errs binding.Error
|
||||
}
|
||||
|
||||
result := models.Result{
|
||||
TestID: form.Test,
|
||||
BenchmarkID: form.Benchmark,
|
||||
TestID: form.Test,
|
||||
BenchmarkProfileID: form.BenchmarkProfile,
|
||||
AverageScore: form.AverageScore,
|
||||
MinimumScore: form.MinimumScore,
|
||||
MaximumScore: form.MaximumScore,
|
||||
@@ -50,12 +62,12 @@ func ApiV1ResultAdd(c flamego.Context, form forms.ResultForm, errs binding.Error
|
||||
|
||||
func ApiV1ResultList(c flamego.Context, r flamego.Render) {
|
||||
// find benchmark and test IDs from request
|
||||
benchmarkID := c.Query("benchmark_id")
|
||||
benchmarkProfileID := c.Query("benchmark_id")
|
||||
testID := c.Query("test_id")
|
||||
|
||||
// find results from the DB that match the benchmark and test
|
||||
var results []models.Result
|
||||
models.DB.Where("test_id = ? AND benchmark_id = ?", testID, benchmarkID).Find(&results)
|
||||
models.DB.Where("test_id = ? AND benchmark_profile_id = ?", testID, benchmarkProfileID).Find(&results)
|
||||
|
||||
// return JSON response
|
||||
r.JSON(200, results)
|
||||
|
||||
Reference in New Issue
Block a user