Improved design, delayed blowjobs, error handling, nice artist loading.
This commit is contained in:
@@ -6,7 +6,14 @@ class ArtistController < ApplicationController
|
||||
name = params[:name].gsub('%20', ' ').gsub('+', ' ')
|
||||
artist = Artist.find_by_name(name)
|
||||
if artist and artist.status == 0
|
||||
render :json => {status: 'loading'}
|
||||
pics = []
|
||||
pics << artist.pic_url unless artist.pic_url.nil?
|
||||
unless artist.albums.empty?
|
||||
artist.albums.each do |album|
|
||||
pics << album.pic_url unless album.pic_url.nil?
|
||||
end
|
||||
end
|
||||
render :json => {status: 'loading', pics: pics}
|
||||
return
|
||||
end
|
||||
unless artist
|
||||
@@ -21,7 +28,7 @@ class ArtistController < ApplicationController
|
||||
artist.status = 0
|
||||
artist.save
|
||||
Delayed::Job.enqueue LoadArtistJob.new(name)
|
||||
render :json => {status: 'loading_started'}
|
||||
render :json => {status: 'loading', pics: []}
|
||||
return
|
||||
elsif results[0][:name].downcase == name.downcase or results[0][:name].downcase == 'the '+ name.downcase
|
||||
render :json => {status: 'corrected', page: results[0][:name]}
|
||||
|
||||
Reference in New Issue
Block a user