1
0
Fork 0

Import dry run

This commit is contained in:
magnolia-fan 2011-06-29 00:54:46 +04:00
parent 391288d861
commit 655e30f995
4 changed files with 9 additions and 10 deletions

View File

@ -10,7 +10,6 @@ class Session
if params[key]?
_params[key] = params[key]
@vk_params = _params
false
setUser: (user) ->
@user = user

View File

@ -11,7 +11,7 @@ class ImportController < ApplicationController
@@brainz_login = 'magnolia_fan'
@@brainz_password = '111111'
def self.importArtist name
def self.importArtist name, dry_run = false
# Initializing gems
brainz = MusicBrainz::Client.new(@@brainz_login, @@brainz_password, @@user_agent)
@ -52,7 +52,7 @@ class ImportController < ApplicationController
# Checking if there is already an album with the same name
albums_db = Album.where(:artist_id => artist.id, :name => album_name, :album_type => mb_album['type'])
# Get album releases from MB
releases_mb = brainz.release(nil, {'release-group' => mb_album['id']})
@ -121,7 +121,8 @@ class ImportController < ApplicationController
album.mbid = mb_album['id']
album.album_type = mb_album['type']
album.pic_url = album_image
album.save
album.save unless dry_run
ap album if dry_run
# Creating hashed array for matching
mb_main_tracks_hashed = []
@ -175,7 +176,7 @@ class ImportController < ApplicationController
track.live = mb_track['recording']['title'].downcase.include? 'live'
track.acoustic = mb_track['recording']['title'].downcase.include? 'acoustic'
track.mbid = mb_track['recording']['id']
track.save
track.save unless dry_run
end
end
@ -199,7 +200,8 @@ class ImportController < ApplicationController
artist.status = 2
end
artist.save
artist.save unless dry_run
ap artist if dry_run
end # def self.importArtist name

View File

@ -4,10 +4,9 @@ namespace :db do
desc 'Imports test data from MusicBrainz database'
task :import => :environment do
ati = ['Ashes Divide']
ati = ['Vampire Weekend']
ati.each do |name|
ImportController.importArtist(name)
#ap res = ArtistController.musicBrainzExactSearch(name)
ImportController.importArtist(name, true)
end
end
end

View File

@ -13,7 +13,6 @@ Session = (function() {
}
}
this.vk_params = _params;
false;
}
Session.prototype.setUser = function(user) {
this.user = user;