Eager load notification targets
This commit is contained in:
parent
80e312eb3b
commit
40f7f8f525
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue