Skip to content

Commit

Permalink
chore: remove legacy team model and associations
Browse files Browse the repository at this point in the history
  • Loading branch information
mromulus committed Nov 2, 2023
1 parent 1fa99f7 commit 56dff7b
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 118 deletions.
78 changes: 0 additions & 78 deletions app/models/actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,84 +23,6 @@ def self.to_icon
'fa-building-shield'
end

### TEMPORARY: until migrated
def self.migrate_from_teams
Exercise.find_each do |ex|
ex.actors
.where(abbreviation: 'admin')
.first_or_create(name: 'Exercise admin')
.update!(
prefs: {
ui_color: Team.find_by(name: 'Green').ui_color
}
)
ex.actors
.where(abbreviation: 'gt')
.first_or_create(name: 'Green team')
.update!(
prefs: {
ui_color: Team.find_by(name: 'Green').ui_color
}
)
ex.actors
.where(abbreviation: 'yt')
.first_or_create(name: 'Yellow team')
.update!(
prefs: {
ui_color: Team.find_by(name: 'Yellow').ui_color
}
)
ex.actors
.where(abbreviation: 'rt')
.first_or_create(name: 'Red team')
.update!(
prefs: {
ui_color: Team.find_by(name: 'Red').ui_color
}
)

prefs = if ex.blue_team_count || ex.dev_team_count
{
ui_color: Team.find_by(name: 'Blue').ui_color,
numbered: { count: ex.blue_team_count, dev_count: ex.dev_team_count }
}
else
{
ui_color: Team.find_by(name: 'Blue').ui_color
}
end
bt = ex.actors.where(abbreviation: 'bt').first_or_create(name: 'Blue teams')
bt.update!(prefs:)

ex.networks.find_each do |net|
next unless net.team
net.update actor: ex.actors.find_by(abbreviation: abbreviation_for_team(net.team)) || ex.actors.first
end

ex.virtual_machines.find_each do |vm|
next unless vm.team
vm.update actor: ex.actors.find_by(abbreviation: abbreviation_for_team(vm.team)) || ex.actors.first
if vm.deploy_mode_bt?
vm.update numbered_by: bt
end
end
end
end

### TEMPORARY: until migrated
def self.abbreviation_for_team(team)
case team.name
when 'Red'
:rt
when 'Green'
:gt
when 'Yellow'
:yt
when 'Blue'
:bt
end
end

# THIS IS TEMPORARY UNTIL MIGRATED TO ACTORS
def as_team_api
case abbreviation
Expand Down
1 change: 0 additions & 1 deletion app/models/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Network < ApplicationRecord
has_paper_trail

belongs_to :exercise
belongs_to :team, optional: true # TEMPORARY
belongs_to :actor
has_many :network_interfaces, dependent: :restrict_with_error
has_many :address_pools, dependent: :destroy
Expand Down
21 changes: 0 additions & 21 deletions app/models/team.rb

This file was deleted.

1 change: 0 additions & 1 deletion app/models/virtual_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class VirtualMachine < ApplicationRecord
}, _prefix: :visibility

belongs_to :exercise
belongs_to :team, optional: true # TEMPORARY, to be removed
belongs_to :actor
belongs_to :operating_system, optional: true
belongs_to :system_owner, class_name: 'User', inverse_of: :owned_systems, optional: true
Expand Down
17 changes: 0 additions & 17 deletions app/policies/team_policy.rb

This file was deleted.

0 comments on commit 56dff7b

Please sign in to comment.