diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 08:17:02 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 08:17:02 +0000 |
commit | b39512ed755239198a9c294b6a45e65c05900235 (patch) | |
tree | d234a3efade1de67c46b9e5a38ce813627726aa7 /app/serializers/environment_serializer.rb | |
parent | d31474cf3b17ece37939d20082b07f6657cc79a9 (diff) | |
download | gitlab-ce-15.3.0-rc42.tar.gz |
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'app/serializers/environment_serializer.rb')
-rw-r--r-- | app/serializers/environment_serializer.rb | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb index 3f236fa55df..6363d6276a7 100644 --- a/app/serializers/environment_serializer.rb +++ b/app/serializers/environment_serializer.rb @@ -34,8 +34,8 @@ class EnvironmentSerializer < BaseSerializer # rubocop: disable CodeReuse/ActiveRecord def itemize(resource) items = resource.order('folder ASC') - .group('COALESCE(environment_type, name)') - .select('COALESCE(environment_type, name) AS folder', + .group('COALESCE(environment_type, id::text)', 'COALESCE(environment_type, name)') + .select('COALESCE(environment_type, id::text), COALESCE(environment_type, name) AS folder', 'COUNT(*) AS size', 'MAX(id) AS last_id') # It makes a difference when you call `paginate` method, because @@ -54,11 +54,7 @@ class EnvironmentSerializer < BaseSerializer 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 + resource = resource.preload(environment_associations) Preloaders::Environments::DeploymentPreloader.new(resource) .execute_with_union(:last_deployment, temp_deployment_associations) @@ -72,18 +68,14 @@ class EnvironmentSerializer < BaseSerializer 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 + # Batch loading last_deployment_group which is called later by environment.stop_actions + environment.last_deployment_group end end end def environment_associations { - last_deployment: deployment_associations, - upcoming_deployment: deployment_associations, project: project_associations } end @@ -101,7 +93,8 @@ class EnvironmentSerializer < BaseSerializer metadata: [], pipeline: { manual_actions: [:metadata, :deployment], - scheduled_actions: [:metadata] + scheduled_actions: [:metadata], + latest_successful_builds: [] }, project: project_associations, deployment: [] |