1
0
Fork 0
oldhaven/rails/app/models/release.rb

24 lines
646 B
Ruby
Raw Normal View History

2011-04-04 18:10:22 +00:00
class Release < ActiveRecord::Base
set_table_name 'musicbrainz.bh_release'
def self.getReleases(release_groups, group_by_release = false, only_official = false)
2011-04-04 19:08:49 +00:00
releases = Release.all(
:conditions => [
'release_group IN(?) AND '+
(only_official ? 'release_type=1' : 'release_type IS NOT NULL'), release_groups
],
:order => 'date ASC, id ASC'
)
if group_by_release
g_releases = {}
releases.each do |release|
if g_releases[release.release_group].nil?
g_releases[release.release_group] = {}
end
g_releases[release.release_group] << release
2011-04-04 19:08:49 +00:00
end
return g_releases
end
return releases
2011-04-04 18:10:22 +00:00
end
end