mongodb select tracks optimized
This commit is contained in:
@@ -5,19 +5,28 @@ class ArtistController < ApplicationController
|
||||
if params[:name].nil?
|
||||
name = ''
|
||||
else
|
||||
if request.request_method == 'POST'
|
||||
if request.request_method == 'POST'
|
||||
redirect_to :action => 'view', :name => params[:name].gsub(' ', '+')
|
||||
end
|
||||
name = params[:name].gsub('+', ' ')
|
||||
end
|
||||
@artist = Artist.getByName(name)
|
||||
@albums = []
|
||||
@artist.albums.each do |album|
|
||||
unless album.releases.empty?
|
||||
tracks = album.tracksInDb()
|
||||
@albums << {
|
||||
:object => album,
|
||||
:tracks => tracks
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def autocomplete
|
||||
autocomplete = Artist.getLastFmAutocomplete(params[:query])
|
||||
return render :nothing => true if autocomplete.nil?
|
||||
suggestions = []
|
||||
pp autocomplete["response"]
|
||||
autocomplete["response"]["docs"].each do |doc|
|
||||
suggestions << doc["artist"] unless suggestions.include?(doc["artist"])
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user