2011-09-18 14:25:47 +00:00
|
|
|
namespace :db do
|
|
|
|
namespace :artist do
|
|
|
|
desc 'Fix broken imports'
|
|
|
|
task :fix => :environment do
|
|
|
|
Artist.where(:status => [0, 2]).each do |artist|
|
|
|
|
artist.albums.each do |album|
|
|
|
|
album.destroy
|
|
|
|
end
|
2011-09-19 04:07:45 +00:00
|
|
|
puts 'Artist:'+artist.name
|
|
|
|
puts 'MBID: '+artist.mbid unless artist.mbid.nil?
|
2011-09-18 14:25:47 +00:00
|
|
|
res = ImportController.importArtist(artist.name)
|
|
|
|
if res == 1
|
2011-09-19 04:07:45 +00:00
|
|
|
puts 'Status: OK'
|
2011-09-18 14:25:47 +00:00
|
|
|
elsif res == 2
|
2011-09-19 04:07:45 +00:00
|
|
|
puts 'Status: FAILED'
|
2011-09-18 14:25:47 +00:00
|
|
|
elsif res == 3
|
2011-09-19 04:07:45 +00:00
|
|
|
puts 'Status: SKIP'
|
2011-09-18 14:25:47 +00:00
|
|
|
end
|
|
|
|
puts ''
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|