diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-05-06 17:30:57 +0200 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2019-05-24 10:04:05 +0100 |
commit | de24df98a3a20f87f5fed513d27a20b6238d6959 (patch) | |
tree | 56d19ee9c2e15e946c3f7c0962c0a062a64565c6 /app/serializers | |
parent | 412a38570245003b6509bf20cff2cce206ec8aa7 (diff) | |
download | gitlab-ce-de24df98a3a20f87f5fed513d27a20b6238d6959.tar.gz |
Do not serialize deployment details for build details page
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/build_details_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/deployment_entity.rb | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb index f391b6f8a1b..6928968edc0 100644 --- a/app/serializers/build_details_entity.rb +++ b/app/serializers/build_details_entity.rb @@ -14,7 +14,7 @@ class BuildDetailsEntity < JobEntity expose :deployment_status, if: -> (*) { build.starts_environment? } do expose :deployment_status, as: :status expose :persisted_environment, as: :environment do |build, options| - options.merge(except: [{ last_deployment: [:commit] }]).yield_self do |opts| + options.merge(deployment_details: false).yield_self do |opts| EnvironmentEntity.represent(build.persisted_environment, opts) end end diff --git a/app/serializers/deployment_entity.rb b/app/serializers/deployment_entity.rb index 34ae06278c8..2bafcee0109 100644 --- a/app/serializers/deployment_entity.rb +++ b/app/serializers/deployment_entity.rb @@ -20,15 +20,19 @@ class DeploymentEntity < Grape::Entity expose :created_at expose :tag expose :last? - expose :user, using: UserEntity - expose :commit, using: CommitEntity - expose :deployable, using: JobEntity - expose :manual_actions, using: JobEntity, if: -> (*) { can_create_deployment? } - expose :scheduled_actions, using: JobEntity, if: -> (*) { can_create_deployment? } + + expose :commit, using: CommitEntity, if: -> (*) { include_details? } + expose :deployable, using: JobEntity, if: -> (*) { include_details? } + expose :manual_actions, using: JobEntity, if: -> (*) { include_details? && can_create_deployment? } + expose :scheduled_actions, using: JobEntity, if: -> (*) { include_details? && can_create_deployment? } private + def include_details? + options.fetch(:deployment_details, true) + end + def can_create_deployment? can?(request.current_user, :create_deployment, request.project) end |