add geo info and do refractor on workers

This commit is contained in:
2021-04-29 20:44:21 +02:00
parent f7799bb514
commit c5190b48f8
32 changed files with 241 additions and 205 deletions

View File

@@ -9,6 +9,8 @@ class WowCharacter < ApplicationRecord
belongs_to :wow_class
belongs_to :wow_race
belongs_to :wow_character_title, optional: true
belongs_to :last_position, class_name: 'WowGeoPosition', optional: true
belongs_to :bind_position, class_name: 'WowGeoPosition', optional: true
has_one :wow_character_medium, dependent: :nullify
validates :name, presence: true

11
app/models/wow_geo_map.rb Normal file
View File

@@ -0,0 +1,11 @@
# frozen_string_literal: true
class WowGeoMap < ApplicationRecord
extend Mobility
translates :name
has_many :wow_geo_positions, dependent: :destroy
validates :name, presence: true
validates :map_id, presence: true, uniqueness: true
end

View File

@@ -0,0 +1,21 @@
# frozen_string_literal: true
class WowGeoPosition < ApplicationRecord
belongs_to :wow_geo_map
belongs_to :wow_geo_zone
has_one(
:last_position_character,
class_name: 'WowCharacter',
foreign_key: 'last_position_id',
inverse_of: :last_position,
dependent: :destroy
)
has_one(
:bind_position_character,
class_name: 'WowCharacter',
foreign_key: 'bind_position_id',
inverse_of: :bind_position,
dependent: :destroy
)
end

View File

@@ -0,0 +1,11 @@
# frozen_string_literal: true
class WowGeoZone < ApplicationRecord
extend Mobility
translates :name
has_many :wow_geo_positions, dependent: :destroy
validates :name, presence: true
validates :zone_id, presence: true, uniqueness: true
end