diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-30 18:08:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-30 18:08:03 +0300 |
commit | 02c48d0a6bf00afd66a603253ec59db4e1412392 (patch) | |
tree | 0b7ea896f1f535e55e1988f4cb8d105e3983ea7c /app/serializers | |
parent | f1284938edfc2e033baf2c26ebadf42c526f6432 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/environment_serializer.rb | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb index 3cb60a59f51..3f236fa55df 100644 --- a/app/serializers/environment_serializer.rb +++ b/app/serializers/environment_serializer.rb @@ -52,19 +52,30 @@ class EnvironmentSerializer < BaseSerializer end def batch_load(resource) + temp_deployment_associations = deployment_associations + resource = resource.preload(environment_associations.except(:last_deployment, :upcoming_deployment)) + if ::Feature.enabled?(:batch_load_environment_last_deployment_group, resource.first&.project) + temp_deployment_associations[:deployable][:pipeline][:latest_successful_builds] = [] + end + Preloaders::Environments::DeploymentPreloader.new(resource) - .execute_with_union(:last_deployment, deployment_associations) + .execute_with_union(:last_deployment, temp_deployment_associations) Preloaders::Environments::DeploymentPreloader.new(resource) - .execute_with_union(:upcoming_deployment, deployment_associations) + .execute_with_union(:upcoming_deployment, temp_deployment_associations) resource.to_a.tap do |environments| environments.each do |environment| # Batch loading the commits of the deployments environment.last_deployment&.commit&.try(:lazy_author) environment.upcoming_deployment&.commit&.try(:lazy_author) + + if ::Feature.enabled?(:batch_load_environment_last_deployment_group, environment.project) + # Batch loading last_deployment_group which is called later by environment.stop_actions + environment.last_deployment_group + end end end end @@ -89,10 +100,11 @@ class EnvironmentSerializer < BaseSerializer user: [], metadata: [], pipeline: { - manual_actions: [:metadata], + manual_actions: [:metadata, :deployment], scheduled_actions: [:metadata] }, - project: project_associations + project: project_associations, + deployment: [] } } end |