Delete unused rake tasks
This commit is contained in:
parent
eb4a3ce0d9
commit
93511b3d51
5 changed files with 0 additions and 150 deletions
|
@ -157,18 +157,6 @@ class PetState < ApplicationRecord
|
|||
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 artist_name
|
||||
artist_neopets_username || I18n.translate("pet_states.default_artist_name")
|
||||
end
|
||||
|
@ -236,25 +224,6 @@ class PetState < ApplicationRecord
|
|||
pet_state
|
||||
end
|
||||
|
||||
def self.repair_all!
|
||||
self.transaction do
|
||||
self.all.each do |pet_state|
|
||||
pet_state.sort_swf_asset_ids!
|
||||
pet_state.save
|
||||
end
|
||||
|
||||
self.
|
||||
select('pet_states.pet_type_id, pet_states.swf_asset_ids, GROUP_CONCAT(DISTINCT pet_states.id) AS duplicate_ids').
|
||||
joins('INNER JOIN pet_states ps2 ON pet_states.pet_type_id = ps2.pet_type_id AND pet_states.swf_asset_ids = ps2.swf_asset_ids').
|
||||
group('pet_states.pet_type_id, pet_states.swf_asset_ids').
|
||||
having('count(*) > 1').
|
||||
all.
|
||||
each do |pet_state|
|
||||
pet_state.reassign_duplicates!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Copied from https://github.com/matchu/neopets/blob/5d13a720b616ba57fbbd54541f3e5daf02b3fedc/lib/neopets/pet/mood.rb
|
||||
class Mood
|
||||
attr_reader :id, :name
|
||||
|
|
|
@ -1,13 +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
|
||||
|
||||
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,52 +1,4 @@
|
|||
namespace :pet_types do
|
||||
namespace :pranks do
|
||||
desc 'Create a prank pet type with one state and one asset'
|
||||
task :create, [:color_id, :species_id, :body_id, :asset_remote_id, :asset_url, :female, :mood_id, :unconverted, :zones_restrict] => :environment do |t, args|
|
||||
args.with_defaults(female: false, mood_id: 1, unconverted: false,
|
||||
zone_id: 15, # body zone; a pretty good compromise for most items
|
||||
zones_restrict: '0000000000000000000000000000000000000000000000000000')
|
||||
PetType.transaction do
|
||||
swf_asset = SwfAsset.new
|
||||
swf_asset.type = 'biology'
|
||||
swf_asset.remote_id = args[:asset_remote_id]
|
||||
swf_asset.url = args[:asset_url]
|
||||
swf_asset.zone_id = args[:zone_id]
|
||||
swf_asset.zones_restrict = args[:zones_restrict]
|
||||
swf_asset.body_id = 0 # biology assets use 0, not pet type's body id
|
||||
swf_asset.has_image = false
|
||||
swf_asset.image_requested = false
|
||||
swf_asset.save! # get it an ID
|
||||
puts "Asset #{swf_asset.inspect} created"
|
||||
|
||||
pet_type = PetType.new
|
||||
pet_type.color_id = args[:color_id]
|
||||
pet_type.species_id = args[:species_id]
|
||||
pet_type.body_id = args[:body_id]
|
||||
# This isn't really a valid image hash, but we can teach PetType to
|
||||
# use this override when reporting its image URLs.
|
||||
pet_type.image_hash = "a:#{swf_asset.remote_id}"
|
||||
pet_type.save!
|
||||
puts "Pet type #{pet_type.inspect} created"
|
||||
|
||||
pet_state = pet_type.pet_states.build
|
||||
pet_state.swf_asset_ids = "#{swf_asset.id}"
|
||||
pet_state.female = args[:female]
|
||||
pet_state.mood_id = args[:mood_id]
|
||||
pet_state.unconverted = args[:unconverted]
|
||||
pet_state.labeled = true
|
||||
pet_state.glitched = false
|
||||
pet_state.save!
|
||||
puts "Pet state #{pet_state.inspect} created"
|
||||
|
||||
parent_swf_asset_relationship = ParentSwfAssetRelationship.new
|
||||
parent_swf_asset_relationship.parent = pet_state
|
||||
parent_swf_asset_relationship.swf_asset = swf_asset
|
||||
parent_swf_asset_relationship.save!
|
||||
puts "Relationship #{parent_swf_asset_relationship.inspect} created"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Download the Rainbow Pool data for the given locale"
|
||||
task :download_basic_image_hashes => :environment do
|
||||
Species.find_each do |species|
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
require 'nokogiri'
|
||||
|
||||
namespace :spotlight do
|
||||
|
||||
desc "Update spotlight pets by HTML download of contest results"
|
||||
task :update do |t, args|
|
||||
input_path = args[:file]
|
||||
unless input_path
|
||||
raise ArgumentError, "provide FILE=/path/to/contest/results.html"
|
||||
end
|
||||
|
||||
input_doc = File.open(input_path, 'r') { |file| Nokogiri::HTML(file) }
|
||||
|
||||
output_path = Rails.root.join('public', 'spotlight_pets.txt')
|
||||
File.open(output_path, 'w') do |output_file|
|
||||
links = input_doc.css('a[href^="/petlookup.phtml"]')
|
||||
|
||||
links.each do |link|
|
||||
output_file.puts(link.text)
|
||||
end
|
||||
|
||||
puts "Wrote #{links.size} names to #{output_path}"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,32 +0,0 @@
|
|||
namespace :users do
|
||||
namespace :image_mode do
|
||||
|
||||
desc "Grants given username access to image mode"
|
||||
task :add, [:username] => :environment do |t, args|
|
||||
user = toggle_user_image_mode(args, true)
|
||||
puts "#{user.name} has gained access to image mode"
|
||||
end
|
||||
|
||||
desc "Removes given username's access to image mode"
|
||||
task :remove, [:username] => :environment do |t, args|
|
||||
user = toggle_user_image_mode(args, false)
|
||||
puts "#{user.name} has lost access to image mode"
|
||||
end
|
||||
|
||||
def find_user(args)
|
||||
name = args[:username]
|
||||
user = User.find_by_name(name)
|
||||
raise RuntimeError, "Could not find user with name #{name.inspect}" unless user
|
||||
user
|
||||
end
|
||||
|
||||
def toggle_user_image_mode(args, image_mode)
|
||||
user = find_user(args)
|
||||
user.image_mode_tester = image_mode
|
||||
user.save!
|
||||
user
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in a new issue