Further abstract caching for includes
This commit is contained in:
parent
356d3874eb
commit
a21bcac9e1
4 changed files with 22 additions and 2 deletions
|
@ -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?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue