5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/jobs/collavre/inbox_summary_job.rb', line 5
def perform
Rails.logger.info("Running InboxSummaryJob")
User.find_each do |user|
if user.notifications_enabled == false
Rails.logger.info("Skipping inbox summary for #{user.email} because notifications are disabled")
next
end
items = InboxItem.where(owner: user, state: "new").order(created_at: :desc).limit(10)
if items.empty?
Rails.logger.info("No new inbox items for #{user.email}")
next
end
Rails.logger.info("Sending inbox summary to #{user.email} with #{items.count} items")
Collavre::InboxMailer.with(user: user, items: items).daily_summary.deliver_now
end
end
|