Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
zipofar committed Sep 6, 2023
2 parents a6d25e1 + 9d5f9ea commit 6af8fe3
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 63 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: core
specs:
uffizzi_core (2.2.18)
uffizzi_core (2.2.20)
aasm
actionpack (~> 6.1.0)
active_model_serializers
Expand Down Expand Up @@ -111,7 +111,7 @@ GEM
ast (2.4.2)
awesome_print (1.9.2)
aws-eventstream (1.2.0)
aws-partitions (1.812.0)
aws-partitions (1.817.0)
aws-sdk-core (3.181.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
Expand All @@ -120,7 +120,7 @@ GEM
aws-sdk-ecr (1.63.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sigv4 (~> 1.1)
aws-sdk-eventbridge (1.48.0)
aws-sdk-eventbridge (1.49.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sigv4 (~> 1.1)
aws-sdk-iam (1.86.0)
Expand Down
12 changes: 6 additions & 6 deletions core/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
uffizzi_core (2.2.18)
uffizzi_core (2.2.20)
aasm
actionpack (~> 6.1.0)
active_model_serializers
Expand Down Expand Up @@ -110,7 +110,7 @@ GEM
activerecord (>= 5.2.6)
awesome_print (1.9.2)
aws-eventstream (1.2.0)
aws-partitions (1.812.0)
aws-partitions (1.817.0)
aws-sdk-core (3.181.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.651.0)
Expand All @@ -119,7 +119,7 @@ GEM
aws-sdk-ecr (1.63.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sigv4 (~> 1.1)
aws-sdk-eventbridge (1.48.0)
aws-sdk-eventbridge (1.49.0)
aws-sdk-core (~> 3, >= 3.177.0)
aws-sigv4 (~> 1.1)
aws-sdk-iam (1.86.0)
Expand Down Expand Up @@ -228,8 +228,8 @@ GEM
faraday (>= 0.9.0)
faraday_middleware (1.2.0)
faraday (~> 1.0)
globalid (1.1.0)
activesupport (>= 5.0)
globalid (1.2.1)
activesupport (>= 6.1)
hash_diff (1.1.1)
hashdiff (1.0.1)
hashie (5.0.0)
Expand Down Expand Up @@ -287,7 +287,7 @@ GEM
faraday (>= 1, < 3)
sawyer (~> 0.9)
parslet (2.0.0)
pg (1.5.3)
pg (1.5.4)
power_assert (2.0.1)
pry (0.13.1)
coderay (~> 1.1)
Expand Down
3 changes: 2 additions & 1 deletion core/app/lib/uffizzi_core/concerns/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ module UffizziCore::Concerns::Models::Project
has_many :host_volume_files, dependent: :destroy
has_many :clusters, dependent: :destroy

validates :name, presence: true, uniqueness: { scope: :account }
validates :name, presence: true
validates_uniqueness_of :name, conditions: -> { where(state: :active) }
validates :slug, presence: true, uniqueness: true

aasm(:state) do
Expand Down
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class UpdateNameConstraintToProjects < ActiveRecord::Migration[6.1]
def change
remove_index(:uffizzi_core_projects, [:account_id, :name])
add_index(:uffizzi_core_projects, [:account_id, :name], unique: true,
where: "state = 'active'",
name: 'proj_uniq_name')
end
end
2 changes: 1 addition & 1 deletion core/lib/uffizzi_core/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module UffizziCore
VERSION = '2.2.18'
VERSION = '2.2.20'
end
8 changes: 3 additions & 5 deletions core/test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_08_10_140316) do
ActiveRecord::Schema.define(version: 2023_08_24_150022) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -30,10 +30,8 @@
t.integer "container_memory_limit"
t.string "workos_organization_id"
t.string "sso_state"
t.string "slug"
t.index ["customer_token"], name: "index_accounts_on_customer_token", unique: true
t.index ["domain"], name: "index_accounts_on_domain", unique: true
t.index ["slug"], name: "index_uffizzi_core_accounts_on_slug", unique: true
t.index ["subscription_token"], name: "index_accounts_on_subscription_token", unique: true
end

Expand Down Expand Up @@ -85,7 +83,7 @@
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "host"
t.string "source"
t.string "creation_source"
t.index ["project_id"], name: "index_cluster_on_project_id"
end

Expand Down Expand Up @@ -331,7 +329,7 @@
t.string "state"
t.string "slug"
t.string "description"
t.index ["account_id", "name"], name: "index_projects_on_account_id_and_name", unique: true
t.index ["account_id", "name"], name: "proj_uniq_name", unique: true, where: "((state)::text = 'active'::text)"
t.index ["account_id"], name: "index_projects_on_account_id"
end

Expand Down
10 changes: 10 additions & 0 deletions db/migrate/20230824150022_update_name_constraint_to_projects.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

class UpdateNameConstraintToProjects < ActiveRecord::Migration[6.1]
def change
remove_index(:uffizzi_core_projects, [:account_id, :name])
add_index(:uffizzi_core_projects, [:account_id, :name], unique: true,
where: "state = 'active'",
name: 'proj_uniq_name')
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_07_11_101901) do
ActiveRecord::Schema.define(version: 2023_08_24_150022) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -328,7 +328,7 @@
t.string "state"
t.string "slug"
t.string "description"
t.index ["account_id", "name"], name: "index_projects_on_account_id_and_name", unique: true
t.index ["account_id", "name"], name: "proj_uniq_name", unique: true, where: "((state)::text = 'active'::text)"
t.index ["account_id"], name: "index_projects_on_account_id"
end

Expand Down

0 comments on commit 6af8fe3

Please sign in to comment.