diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /app/serializers/environment_serializer.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'app/serializers/environment_serializer.rb')
-rw-r--r-- | app/serializers/environment_serializer.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb index b13140efea7..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: [], - scheduled_actions: [] + manual_actions: [:metadata, :deployment], + scheduled_actions: [:metadata] }, - project: project_associations + project: project_associations, + deployment: [] } } end |