Skip to content

Commit

Permalink
[268] remove unusable data for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
zipofar committed Sep 6, 2023
1 parent d4be8c7 commit 283063f
Showing 1 changed file with 1 addition and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,9 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentSerializer < UffizziCore::B
type :deployment

attributes :id,
:kind,
:project_id,
:created_at,
:updated_at,
:state,
:preview_url,
:tag,
:branch,
:image_id,
:ingress_container_ready,
:ingress_container_state,
:creation_source,
:metadata
:preview_url

has_many :containers

Expand All @@ -28,38 +18,4 @@ class UffizziCore::Api::Cli::V1::Projects::DeploymentSerializer < UffizziCore::B
def containers
object.containers.active
end

def tag
object.ingress_container&.tag
end

def branch
object.ingress_container&.repo&.branch
end

def image_id
object.ingress_container&.repo&.name
end

def ingress_container_ready
!!object.ingress_container&.activity_items&.last&.events&.last&.deployed?
end

def ingress_container_state
last_event = object.ingress_container&.activity_items&.last&.events&.last

case last_event&.state
when UffizziCore::Event.state.deployed
:deployed
when UffizziCore::Event.state.failed, UffizziCore::Event.state.timeout, UffizziCore::Event.state.cancelled
:failed
else
state_from_activity_items
end
end

def state_from_activity_items
activity_items_count = object.ingress_container&.activity_items&.count
activity_items_count.to_i > 1 ? :updating : :pending
end
end

0 comments on commit 283063f

Please sign in to comment.