summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-12-15 22:06:39 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2016-12-15 22:06:39 +0100
commitb2508cbdaf600bbb8fb2fd56c9891304502429b3 (patch)
tree45494ec34713bd874e8d52b4f272963242cdbd92 /app
parent9eed507dafbfdd09fcd51b970d633ba0fd764d78 (diff)
downloadgitlab-ce-b2508cbdaf600bbb8fb2fd56c9891304502429b3.tar.gz
Improve performance of Pipelines API
Diffstat (limited to 'app')
-rw-r--r--app/finders/pipelines_finder.rb1
-rw-r--r--app/models/ci/pipeline.rb8
-rw-r--r--app/serializers/pipeline_entity.rb4
3 files changed, 8 insertions, 5 deletions
diff --git a/app/finders/pipelines_finder.rb b/app/finders/pipelines_finder.rb
index 32aea75486d..af4bb54e52d 100644
--- a/app/finders/pipelines_finder.rb
+++ b/app/finders/pipelines_finder.rb
@@ -20,6 +20,7 @@ class PipelinesFinder
end
scoped_pipelines.order(id: :desc)
+ .includes(project: [:namespace])
end
private
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 54f73171fd4..9efda36fc0c 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -124,7 +124,7 @@ module Ci
end
def artifacts
- builds.latest.with_artifacts_not_expired
+ builds.latest.with_artifacts_not_expired.includes(project: [:namespace])
end
def project_id
@@ -173,7 +173,11 @@ module Ci
end
def manual_actions
- builds.latest.manual_actions
+ builds.latest.manual_actions.includes(project: [:namespace])
+ end
+
+ def stuck?
+ builds.pending.any?(&:stuck?)
end
def retryable?
diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb
index 613a18e6357..3ede0fb0f53 100644
--- a/app/serializers/pipeline_entity.rb
+++ b/app/serializers/pipeline_entity.rb
@@ -33,9 +33,7 @@ class PipelineEntity < Grape::Entity
pipeline.yaml_errors.present?
end
- expose :stuck?, as: :stuck do |pipeline|
- pipeline.builds.any?(&:stuck?)
- end
+ expose :stuck?, as: :stuck
end
expose :ref do