Symbols syntax convert

This commit is contained in:
Gregory Eremin 2011-10-20 15:02:39 +04:00
parent 73ce491479
commit ba65a8370c

View File

@ -5,7 +5,7 @@ class ArtistController < ApplicationController
def data def data
# Bad params # Bad params
if params[:name].nil? or params[:name].empty? if params[:name].nil? or params[:name].empty?
return render :json => { :status => 'loading_failed' } return render json: { status: 'loading_failed' }
end end
# Searching for artist # Searching for artist
@ -16,25 +16,25 @@ class ArtistController < ApplicationController
unless @artist unless @artist
results = MusicBrainz::Artist.search(artist_name) results = MusicBrainz::Artist.search(artist_name)
if results.empty? if results.empty?
return render :json => { :status => 'not_found' } return render json: { status: 'not_found' }
end end
best_match = results[0][:name] best_match = results[0][:name]
if best_match != artist_name and (best_match.downcase == artist_name.downcase or best_match.downcase == 'the '+ artist_name.downcase) if best_match != artist_name and (best_match.downcase == artist_name.downcase or best_match.downcase == 'the '+ artist_name.downcase)
return render :json => { :status => 'corrected', :correct_name => best_match } return render json: { status: 'corrected', correct_name: best_match }
elsif results[0][:name] == artist_name elsif results[0][:name] == artist_name
queue_loading(artist_name, results[0][:mbid]) queue_loading(artist_name, results[0][:mbid])
@artist = { :artist => @artist, :albums => [] } @artist = { artist: @artist, albums: [] }
@loading = true @loading = true
return render :json => { :status => 'loading', :html => render_compact_partial(:page) } return render json: { status: 'loading', html: render_compact_partial(:page) }
else else
@suggestions = results.take(5) @suggestions = results.take(5)
return render :json => { :status => 'suggestions', :html => render_compact_partial(:suggestions) } return render json: { status: 'suggestions', html: render_compact_partial(:suggestions) }
end end
end end
# Artist loading failed # Artist loading failed
if @artist.status == 2 if @artist.status == 2
return render :json => { :status => 'fail', :html => render_compact_partial(:fail) } return render json: { status: 'fail', html: render_compact_partial(:fail) }
end end
render json: { status: @artist.status_str, artist: @artist, html: render_compact_partial(:page) }, include: {albums: {include: {tracks: {}}}} render json: { status: @artist.status_str, artist: @artist, html: render_compact_partial(:page) }, include: {albums: {include: {tracks: {}}}}
@ -47,7 +47,7 @@ private
end end
def queue_loading artist_name, mbid def queue_loading artist_name, mbid
@artist = Artist.create( :name => artist_name, :mbid => mbid, :status => 0 ) @artist = Artist.create( name: artist_name, mbid: mbid, status: 0 )
Delayed::Job.enqueue(LoadArtistJob.new(artist_name)) Delayed::Job.enqueue(LoadArtistJob.new(artist_name))
end end
end end