summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-07-20 22:00:34 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-07-20 22:00:34 +0800
commit4a1edae3ac321241e2168b98df695e11048f7724 (patch)
treef20ba9f23c71f68aaf3d8e448a82a8a6878460f8 /app
parentfcdfeba922a8480cf9cafdb98bb96c558165e51e (diff)
downloadgitlab-ce-4a1edae3ac321241e2168b98df695e11048f7724.tar.gz
Use one query. Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5347#note_13199055
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 4fd635abbb3..80860f142d4 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -431,13 +431,8 @@ class Project < ActiveRecord::Base
# ref can't be HEAD, can only be branch/tag name or SHA
def latest_successful_builds_for(ref = default_branch)
- latest_successful_pipeline = pipelines.latest_successful_for(ref).first
-
- if latest_successful_pipeline
- latest_successful_pipeline.builds.with_artifacts.latest
- else
- builds.none
- end
+ pipeline = pipelines.latest_successful_for(ref)
+ builds.where(pipeline: pipeline).latest.with_artifacts
end
def merge_base_commit(first_commit_id, second_commit_id)