Eager load notification targets

This commit is contained in:
Karina Kwiatek 2023-02-02 11:03:27 +01:00
parent 80e312eb3b
commit 40f7f8f525
1 changed files with 2 additions and 2 deletions

View File

@ -11,11 +11,11 @@ class Notification < ApplicationRecord
define_cursor_paginator :cursored_for_type, :for_type
def for(recipient, **kwargs)
where(kwargs.merge!(recipient:)).order(:created_at).reverse_order
where(kwargs.merge!(recipient:)).includes(:target).order(:created_at).reverse_order
end
def for_type(recipient, type, **kwargs)
where(kwargs.merge!(recipient:)).where(type:).order(:created_at).reverse_order
where(kwargs.merge!(recipient:)).includes(:target).where(type:).order(:created_at).reverse_order
end
def notify(recipient, target)