Fixed the test edit page
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:
@@ -7,4 +7,8 @@ class Test < Sequel::Model
|
||||
many_to_one :hardware
|
||||
many_to_many :benchmarks
|
||||
|
||||
def has_benchmark(benchmark_id)
|
||||
return benchmarks_dataset.where(Sequel[:benchmarks][:id] => benchmark_id).any?
|
||||
end
|
||||
|
||||
end
|
||||
|
@@ -65,9 +65,25 @@ class GameData < Sinatra::Base
|
||||
|
||||
tst.update(
|
||||
name: params[:test_name],
|
||||
type: params[:test_type]
|
||||
hardware_id: params[:test_hardware],
|
||||
description: params[:test_description]
|
||||
)
|
||||
|
||||
# create an array of the selected benchmarks
|
||||
selected_benchmarks = Array(params[:test_benchmarks])
|
||||
# remove benchmarks no longer associated with the test
|
||||
tst.benchmarks.each do |b|
|
||||
if not selected_benchmarks.include?(b)
|
||||
tst.remove_benchmark(b)
|
||||
end
|
||||
end
|
||||
# associate the benchmarks to the test
|
||||
selected_benchmarks.each do |b|
|
||||
if not tst.has_benchmark(b)
|
||||
tst.add_benchmark(b)
|
||||
end
|
||||
end
|
||||
|
||||
redirect "/test/#{tst.id}"
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user