Rails models
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
class ArtistController < ApplicationController
|
||||
def view
|
||||
@artist = Artists.getByName(params[:name])
|
||||
@artist = Artist.getByName(params[:name])
|
||||
@albums = ReleaseGroup.getArtistAlbums(@artist.id)
|
||||
ids = []
|
||||
@albums.each do |a|
|
||||
ids << a.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class Artist < ActiveRecord::Base
|
||||
set_table_name 'musicbrainz.bh_artist'
|
||||
def self.getByName(name)
|
||||
Artist.first(:conditions => ['name = ? AND id=credit_id', name], :order => 'rating DESC')
|
||||
end
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
class Artists < ActiveRecord::Base
|
||||
set_table_name 'musicbrainz.bh_artist'
|
||||
def self.getByName(name)
|
||||
Artists.first(:conditions => ['name = ? AND id=credit_id', name], :order => 'rating DESC')
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
class ReleaseGroup < ActiveRecord::Base
|
||||
set_table_name 'musicbrainz.bh_release_group'
|
||||
def self.getArtistAlbums(artist_id)
|
||||
ReleaseGroup.all(:conditions => ['artist_id = ? AND release_type=1', artist_id], :order => 'year ASC, id ASC')
|
||||
end
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
class ReleaseGroups < ActiveRecord::Base
|
||||
set_table_name 'musicbrainz.bh_release_group'
|
||||
def self.getArtistAlbums(artist_id)
|
||||
ReleaseGroups.all(:conditions => ['artist_id = ? AND type=1', artist_id], :order => 'year ASC, id ASC')
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user