Improved design, delayed blowjobs, error handling, nice artist loading.

This commit is contained in:
magnolia-fan
2011-06-21 00:42:21 +04:00
parent 7dbf6b87cc
commit b69c9cdbe0
13 changed files with 219 additions and 395 deletions
+9 -2
View File
@@ -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]}