BigW Consortium Gitlab

Improve performance of Pipelines API

parent 9eed507d
...@@ -20,6 +20,7 @@ class PipelinesFinder ...@@ -20,6 +20,7 @@ class PipelinesFinder
end end
scoped_pipelines.order(id: :desc) scoped_pipelines.order(id: :desc)
.includes(project: [:namespace])
end end
private private
......
...@@ -124,7 +124,7 @@ module Ci ...@@ -124,7 +124,7 @@ module Ci
end end
def artifacts def artifacts
builds.latest.with_artifacts_not_expired builds.latest.with_artifacts_not_expired.includes(project: [:namespace])
end end
def project_id def project_id
...@@ -173,7 +173,11 @@ module Ci ...@@ -173,7 +173,11 @@ module Ci
end end
def manual_actions def manual_actions
builds.latest.manual_actions builds.latest.manual_actions.includes(project: [:namespace])
end
def stuck?
builds.pending.any?(&:stuck?)
end end
def retryable? def retryable?
......
...@@ -33,9 +33,7 @@ class PipelineEntity < Grape::Entity ...@@ -33,9 +33,7 @@ class PipelineEntity < Grape::Entity
pipeline.yaml_errors.present? pipeline.yaml_errors.present?
end end
expose :stuck?, as: :stuck do |pipeline| expose :stuck?, as: :stuck
pipeline.builds.any?(&:stuck?)
end
end end
expose :ref do expose :ref do
......
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