Reduce the amount of data deployment endpoint returns
This commit is contained in:
parent
27cc95ab49
commit
4469946105
4 changed files with 30 additions and 13 deletions
|
@ -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
|
||||
|
|
28
app/serializers/deployment_entity_detailed.rb
Normal file
28
app/serializers/deployment_entity_detailed.rb
Normal 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
|
|
@ -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|
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DeploymentEntity do
|
||||
describe DeploymentEntityDetailed do
|
||||
let(:user) { create(:user) }
|
||||
let(:request) { double('request') }
|
||||
|
||||
|
|
Loading…
Reference in a new issue