diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-01-09 08:21:07 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-01-09 08:21:07 +0000 |
commit | f7efb2e090e4fd07608a742722b4bd17c9bb7121 (patch) | |
tree | c9978899bfab60d3ad15a0fba67721e6cb1a4e60 /app/controllers | |
parent | cfaa19f21ea4f01ef8e77fbacbdfd0e1b965a8aa (diff) | |
parent | 935dc667178673022cc221f92e5b59ddcd839eaf (diff) | |
download | gitlab-ce-f7efb2e090e4fd07608a742722b4bd17c9bb7121.tar.gz |
Merge branch 'refactor-artifact-api-endpoint' into 'master'
Refactor artifact api endpoint
Closes #55445
See merge request gitlab-org/gitlab-ce!23582
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/artifacts_controller.rb | 9 | ||||
-rw-r--r-- | app/controllers/projects/build_artifacts_controller.rb | 9 |
2 files changed, 4 insertions, 14 deletions
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 1a91e07b97f..9a0997e92ee 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -85,20 +85,15 @@ class Projects::ArtifactsController < Projects::ApplicationController end end - # rubocop: disable CodeReuse/ActiveRecord def build_from_id - project.builds.find_by(id: params[:job_id]) if params[:job_id] + project.get_build(params[:job_id]) if params[:job_id] end - # rubocop: enable CodeReuse/ActiveRecord - # rubocop: disable CodeReuse/ActiveRecord def build_from_ref return unless @ref_name - builds = project.latest_successful_builds_for(@ref_name) - builds.find_by(name: params[:job]) + project.latest_successful_build_for(params[:job], @ref_name) end - # rubocop: enable CodeReuse/ActiveRecord def artifacts_file @artifacts_file ||= build&.artifacts_file_for_type(params[:file_type] || :archive) diff --git a/app/controllers/projects/build_artifacts_controller.rb b/app/controllers/projects/build_artifacts_controller.rb index 7d4d566499c..d3d5ba5c75d 100644 --- a/app/controllers/projects/build_artifacts_controller.rb +++ b/app/controllers/projects/build_artifacts_controller.rb @@ -44,18 +44,13 @@ class Projects::BuildArtifactsController < Projects::ApplicationController @job ||= job_from_id || job_from_ref end - # rubocop: disable CodeReuse/ActiveRecord def job_from_id - project.builds.find_by(id: params[:build_id]) if params[:build_id] + project.get_build(params[:build_id]) if params[:build_id] end - # rubocop: enable CodeReuse/ActiveRecord - # rubocop: disable CodeReuse/ActiveRecord def job_from_ref return unless @ref_name - jobs = project.latest_successful_builds_for(@ref_name) - jobs.find_by(name: params[:job]) + project.latest_successful_build_for(params[:job], @ref_name) end - # rubocop: enable CodeReuse/ActiveRecord end |