about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorabcang <abcang1015@gmail.com>2017-11-19 23:32:48 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-11-19 15:32:48 +0100
commit53e95c4efcc0bbf480e9c416bc0673558aa8e20e (patch)
treeb493ca261cff6ded4cc2f1fcbf6970ed703f41e8 /app
parent08deec4c84f00d241d60a6962806d5abe4638edd (diff)
Fix N+1 at notification (#5752)
Diffstat (limited to 'app')
-rw-r--r--app/models/notification.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/models/notification.rb b/app/models/notification.rb
index a3ffb1f45..976963528 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -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