Merge pull request #9676 from opf/fix/eager_load_for_notifications

add simple eager loading to the notifications api
pull/9687/head
ulferts 3 years ago committed by GitHub
commit 880c04f229
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      lib/api/v3/notifications/notification_representer.rb
  2. 4
      lib/api/v3/notifications/notifications_api.rb

@ -100,6 +100,10 @@ module API
'Notification'
end
self.to_eager_load = [:project,
:actor,
{ journal: %i[attachable_journals customizable_journals] }]
##
# For notifications, we want to skip the initial journal
# as the information is not that useful

@ -45,7 +45,9 @@ module API
def notification_scope
::Notification
.recipient(current_user)
.where.not(reason_ian: nil)
.includes(NotificationRepresenter.to_eager_load)
.where
.not(reason_ian: nil)
end
def bulk_update_status(attributes)

Loading…
Cancel
Save