Commit fa5af694 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'ali/fix-environment-serializer-preloading-deployments' into 'master'

Fix preloading of Deployments in EnvironmentSerializer

See merge request gitlab-org/gitlab!81328
parents ac36025c 1f0de0b8
......@@ -60,7 +60,7 @@ class EnvironmentSerializer < BaseSerializer
Preloaders::Environments::DeploymentPreloader.new(resource)
.execute_with_union(:upcoming_deployment, deployment_associations)
resource.all.to_a.tap do |environments|
resource.to_a.tap do |environments|
environments.each do |environment|
# Batch loading the commits of the deployments
environment.last_deployment&.commit&.try(:lazy_author)
......
# frozen_string_literal: true
RSpec.shared_examples 'avoid N+1 on environments serialization' do |ee: false|
# Investigating in https://gitlab.com/gitlab-org/gitlab/-/issues/353209
let(:query_threshold) { 50 + (ee ? 4 : 0) }
let(:query_threshold) { 9 + (ee ? 4 : 0) }
it 'avoids N+1 database queries with grouping', :request_store do
create_environment_with_associations(project)
......
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