lib/musicbrainz/models/release_group.rb in musicbrainz-0.7.4 vs lib/musicbrainz/models/release_group.rb in musicbrainz-0.7.5

- old
+ new

@@ -3,10 +3,11 @@ field :id, String field :type, String field :title, String field :desc, String field :first_release_date, Date + field :urls, Hash alias_method :disambiguation, :desc def releases @releases ||= client.load(:release, { release_group: id, inc: [:media, :release_groups], limit: 100 }, { @@ -16,29 +17,25 @@ }) unless @id.nil? end class << self def find(id) - client.load(:release_group, { id: id }, { + client.load(:release_group, { id: id, inc: [:url_rels] }, { binding: :release_group, create_model: :release_group }) end - def search(artist_name, title, options = {}) - artist_name = CGI.escape(artist_name).gsub(/\!/, '\!') - title = CGI.escape(title).gsub(/\!/, '\!') - query = ["artist:\"#{artist_name}\"", "releasegroup:\"#{title}\""] - query << "type: #{options[:type]}" if options[:type] - - client.load( - :release_group, { query: query.join(' AND '), limit: 10 }, - { binding: :release_group_search } - ) + def search(artist_name, title, type = nil) + if type + super({artist: artist_name, releasegroup: title, type: type}) + else + super({artist: artist_name, releasegroup: title}) + end end - def find_by_artist_and_title(artist_name, title, options = {}) - matches = search(artist_name, title, options) + def find_by_artist_and_title(artist_name, title, type = nil ) + matches = search(artist_name, title, type) matches.empty? ? nil : find(matches.first[:id]) end end end end