Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.0 on 2022-01-18 at 14:00 UTC+1 (a few minutes of down time)

Commit c7fcad8e authored by Kamil Trzciński's avatar Kamil Trzciński Committed by Oswaldo Ferreira
Browse files

Merge branch 'reduce-queries-for-artifacts-button' into 'master'

Use arrays in Ci::Pipeline#latest_builds_with_artifacts

See merge request gitlab-org/gitlab-ce!15525

(cherry picked from commit ce019812a5127d503c735f5fe870e2aa4ad14665)

54f1e406 Use arrays in Pipeline#latest_builds_with_artifacts
parent 8b318f622b6b
......@@ -505,7 +505,10 @@ def detailed_status(current_user)
def latest_builds_with_artifacts
@latest_builds_with_artifacts ||= builds.latest.with_artifacts
# We purposely cast the builds to an Array here. Because we always use the
# rows if there are more than 0 this prevents us from having to run two
# queries: one to get the count and one to get the rows.
@latest_builds_with_artifacts ||= builds.latest.with_artifacts.to_a
title: Use arrays in Pipeline#latest_builds_with_artifacts
type: performance
......@@ -1502,6 +1502,10 @@ def create_build(name, stage_idx)
create(:ci_build, :success, :artifacts, pipeline: pipeline)
it 'returns an Array' do
expect(pipeline.latest_builds_with_artifacts).to be_an_instance_of(Array)
it 'returns the latest builds' do
expect(pipeline.latest_builds_with_artifacts).to eq([build])
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