Mass artist controller refactoring
This commit is contained in:
@@ -3,4 +3,14 @@ class Artist < ActiveRecord::Base
|
||||
has_many :artist_links, :dependent => :destroy
|
||||
has_many :artist_aliases, :dependent => :destroy
|
||||
has_many :tracks, :through => :track_artists
|
||||
|
||||
after_initialize :prepare_description
|
||||
|
||||
def status_str
|
||||
%w(loading ok fail)[self.status]
|
||||
end
|
||||
|
||||
def prepare_description
|
||||
self.desc.gsub! /[\[<].*?[\]>]/, ''
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,4 +2,16 @@ class Track < ActiveRecord::Base
|
||||
belongs_to :album
|
||||
has_many :track_artists
|
||||
has_many :artists, :through => :track_artists
|
||||
@duration
|
||||
|
||||
def duration
|
||||
if self.length
|
||||
time = self.length
|
||||
time_m = (time / 60).floor
|
||||
time_s = time - time_m * 60
|
||||
time_m.to_s + ':' + (time_s < 10 ? '0' : '') + time_s.to_s
|
||||
else
|
||||
'0:00'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user