about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-30 15:57:56 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-30 15:57:56 +0100
commita21bcac9e156d8c40fe7c15c62ac71a901091cc5 (patch)
treeb02405fbe4fc288bfc74525c1eddcef1a86d9444 /app/models/status.rb
parent356d3874ebd79573a8da58e2ac76eaa4612cec16 (diff)
Further abstract caching for includes
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index f9dcd97e4..8f65a3ecc 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -3,6 +3,7 @@
 class Status < ApplicationRecord
   include Paginable
   include Streamable
+  include Cacheable
 
   belongs_to :account, inverse_of: :statuses
 
@@ -27,7 +28,8 @@ class Status < ApplicationRecord
   default_scope { order('id desc') }
 
   scope :with_counters, -> { select('statuses.*, (select count(r.id) from statuses as r where r.reblog_of_id = statuses.id) as reblogs_count, (select count(f.id) from favourites as f where f.status_id = statuses.id) as favourites_count') }
-  scope :with_includes, -> { includes(:account, :media_attachments, :tags, :stream_entry, mentions: :account, reblog: [:account, :stream_entry, :tags, :media_attachments, mentions: :account], thread: :account) }
+
+  cache_associated :account, :media_attachments, :tags, :stream_entry, mentions: :account, reblog: [:account, :stream_entry, :tags, :media_attachments, mentions: :account], thread: :account
 
   def local?
     uri.nil?