forked from OpenNeo/impress
add pet state replacement task
This commit is contained in:
parent
8bd7ad5a1e
commit
2b870cf91b
3 changed files with 25 additions and 6 deletions
|
@ -135,6 +135,18 @@ class PetState < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def replace_with(other)
|
||||||
|
PetState.transaction do
|
||||||
|
count = outfits.count
|
||||||
|
outfits.find_each { |outfit|
|
||||||
|
outfit.pet_state = other
|
||||||
|
outfit.save!
|
||||||
|
}
|
||||||
|
destroy
|
||||||
|
end
|
||||||
|
count
|
||||||
|
end
|
||||||
|
|
||||||
def self.from_pet_type_and_biology_info(pet_type, info)
|
def self.from_pet_type_and_biology_info(pet_type, info)
|
||||||
swf_asset_ids = []
|
swf_asset_ids = []
|
||||||
info.each do |zone_id, asset_info|
|
info.each do |zone_id, asset_info|
|
||||||
|
|
13
lib/tasks/pet_states.rake
Normal file
13
lib/tasks/pet_states.rake
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
namespace :pet_states do
|
||||||
|
desc "Sort pet state SWFs, then remove duplicates and reassign children"
|
||||||
|
task :repair => :environment do
|
||||||
|
PetState.repair_all!
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Delete the bad pet state, replacing it in outfits with the good pet state"
|
||||||
|
task :replace, [:bad_id, :good_id] => :environment do |t, args|
|
||||||
|
bad, good = PetState.find(args[:bad_id], args[:good_id])
|
||||||
|
outfit_count = bad.replace_with(good)
|
||||||
|
puts "Updated #{outfit_count} outfits"
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +0,0 @@
|
||||||
namespace :pet_states do
|
|
||||||
desc "Sort pet state SWFs, then remove duplicates and reassign children"
|
|
||||||
task :repair => :environment do
|
|
||||||
PetState.repair_all!
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue