Fix N+1 at notification (#5752)
This commit is contained in:
parent
08deec4c84
commit
53e95c4efc
2 changed files with 18 additions and 23 deletions
|
@ -24,7 +24,7 @@ class Notification < ApplicationRecord
|
|||
favourite: 'Favourite',
|
||||
}.freeze
|
||||
|
||||
STATUS_INCLUDES = [:account, :stream_entry, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, :media_attachments, :tags, mentions: :account]].freeze
|
||||
STATUS_INCLUDES = [:account, :application, :stream_entry, :media_attachments, :tags, mentions: :account, reblog: [:stream_entry, :account, :application, :media_attachments, :tags, mentions: :account]].freeze
|
||||
|
||||
belongs_to :account
|
||||
belongs_to :from_account, class_name: 'Account'
|
||||
|
@ -55,9 +55,11 @@ class Notification < ApplicationRecord
|
|||
def target_status
|
||||
case type
|
||||
when :reblog
|
||||
activity&.reblog
|
||||
when :favourite, :mention
|
||||
activity&.status
|
||||
status&.reblog
|
||||
when :favourite
|
||||
favourite&.status
|
||||
when :mention
|
||||
mention&.status
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue