Reduce the amount of data deployment endpoint returns

This commit is contained in:
Pawel Chojnacki 2017-04-20 11:58:31 +02:00
parent 27cc95ab49
commit 4469946105
4 changed files with 30 additions and 13 deletions

View file

@ -9,20 +9,9 @@ class DeploymentEntity < Grape::Entity
expose :name do |deployment|
deployment.ref
end
expose :ref_path do |deployment|
namespace_project_tree_path(
deployment.project.namespace,
deployment.project,
id: deployment.ref)
end
end
expose :created_at
expose :tag
expose :last?
expose :user, using: UserEntity
expose :commit, using: CommitEntity
expose :deployable, using: BuildEntity
expose :manual_actions, using: BuildEntity
end

View file

@ -0,0 +1,28 @@
class DeploymentEntityDetailed < Grape::Entity
include RequestAwareEntity
expose :id
expose :iid
expose :sha
expose :ref do
expose :name do |deployment|
deployment.ref
end
expose :ref_path do |deployment|
namespace_project_tree_path(
deployment.project.namespace,
deployment.project,
id: deployment.ref)
end
end
expose :created_at
expose :tag
expose :last?
expose :user, using: UserEntity
expose :commit, using: CommitEntity
expose :deployable, using: BuildEntity
expose :manual_actions, using: BuildEntity
end

View file

@ -6,7 +6,7 @@ class EnvironmentEntity < Grape::Entity
expose :state
expose :external_url
expose :environment_type
expose :last_deployment, using: DeploymentEntity
expose :last_deployment, using: DeploymentEntityDetailed
expose :stop_action?
expose :metrics_path, if: -> (environment, _) { environment.has_metrics? } do |environment|

View file

@ -1,6 +1,6 @@
require 'spec_helper'
describe DeploymentEntity do
describe DeploymentEntityDetailed do
let(:user) { create(:user) }
let(:request) { double('request') }