search autocomplete
This commit is contained in:
+12
-1
@@ -1,8 +1,19 @@
|
||||
class Artist < ActiveRecord::Base
|
||||
set_table_name 'musicbrainz.bh_artist'
|
||||
has_many :albums, :conditions => "release_type = 1", :order => 'year ASC, id ASC'
|
||||
|
||||
|
||||
def self.getByName(name)
|
||||
Artist.first(:conditions => ['name = ? AND id=credit_id', name], :order => 'rating DESC')
|
||||
end
|
||||
|
||||
def self.getLastFmAutocomplete(query)
|
||||
return nil if query.nil? or query.strip.empty?
|
||||
|
||||
json = ActiveSupport::JSON.decode(open(
|
||||
'http://www.last.fm/search/autocomplete' <<
|
||||
'?q=' << URI.escape(query)
|
||||
).read)
|
||||
return nil if json.empty? else return json
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user