about summary refs log tree commit diff
path: root/app/controllers/api
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-21 15:16:04 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-21 15:16:04 +0100
commit52119104b94f30d751b410ea865891258e1444ff (patch)
tree1da757ebfe990e74b8ed10e79b39f0a164c427d7 /app/controllers/api
parente8c27767aab0bf6c26d28944268a78fb5ac5d4e0 (diff)
Remove some n+1 queries from notifications API
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/v1/notifications_controller.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/controllers/api/v1/notifications_controller.rb b/app/controllers/api/v1/notifications_controller.rb
index 509471f61..63abee6b5 100644
--- a/app/controllers/api/v1/notifications_controller.rb
+++ b/app/controllers/api/v1/notifications_controller.rb
@@ -9,6 +9,8 @@ class Api::V1::NotificationsController < ApiController
   def index
     @notifications = Notification.where(account: current_account).with_includes.paginate_by_max_id(20, params[:max_id], params[:since_id])
 
+    set_maps(@notifications.select { |n| !n.target_status.nil? }.map(&:target_status))
+
     next_path = api_v1_notifications_url(max_id: @notifications.last.id)    if @notifications.size == 20
     prev_path = api_v1_notifications_url(since_id: @notifications.first.id) unless @notifications.empty?