Commit 3ff27a70 authored by Maxime Orefice's avatar Maxime Orefice

Refactor test show endpoint

This MR clean up some technical debt by
simplify our test show controller endpoint.
parent 19368f19
...@@ -35,23 +35,19 @@ module Projects ...@@ -35,23 +35,19 @@ module Projects
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def builds def builds
pipeline.latest_builds.where(id: build_params) @builds ||= pipeline.latest_builds.for_ids(build_ids).presence || render_404
end end
def build_params def build_ids
return [] unless params[:build_ids] return [] unless params[:build_ids]
params[:build_ids].split(",") params[:build_ids].split(",")
end end
def test_suite def test_suite
if builds.present? builds.map do |build|
builds.map do |build| build.collect_test_reports!(Gitlab::Ci::Reports::TestReports.new)
build.collect_test_reports!(Gitlab::Ci::Reports::TestReports.new) end.sum
end.sum
else
render_404
end
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment