Cache clear hooks, track length update fix
This commit is contained in:
@@ -5,6 +5,7 @@ class Album < ActiveRecord::Base
|
||||
has_many :release_formats, :through => :album_formats
|
||||
|
||||
default_scope where(:master => true)
|
||||
after_save :clear_artist_cache
|
||||
|
||||
def self.with_format f
|
||||
joins(:release_formats).where(:release_formats => { :hash => f.to_s })
|
||||
@@ -18,4 +19,10 @@ class Album < ActiveRecord::Base
|
||||
tracks: tracks.map(&:serialize)
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def clear_artist_cache
|
||||
artist.clear_cache
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,7 @@ class Artist < ActiveRecord::Base
|
||||
has_many :playlists
|
||||
|
||||
after_initialize :prepare_description
|
||||
after_save :clear_cache
|
||||
|
||||
def status_str
|
||||
%w(loading ok fail)[self.status]
|
||||
|
||||
@@ -4,6 +4,8 @@ class Track < ActiveRecord::Base
|
||||
has_many :artists, :through => :track_artists
|
||||
has_many :playlist_items
|
||||
|
||||
after_save :clear_artist_cache
|
||||
|
||||
def duration
|
||||
if self.length
|
||||
time = self.length
|
||||
@@ -28,4 +30,10 @@ class Track < ActiveRecord::Base
|
||||
album_pic: album.pic_url
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def clear_artist_cache
|
||||
artists.each(&:clear_cache)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user