feat: Update last_snoozed_at after the un-snooze notification (#8943)
This commit is contained in:
@@ -2,9 +2,24 @@ class Notification::ReopenSnoozedNotificationsJob < ApplicationJob
|
||||
queue_as :low
|
||||
|
||||
def perform
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
Notification.where(snoozed_until: 3.days.ago..Time.current)
|
||||
.update_all(snoozed_until: nil, updated_at: Time.current, last_activity_at: Time.current, read_at: nil)
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
Notification.where(snoozed_until: 3.days.ago..Time.current).find_in_batches(batch_size: 100) do |notifications_batch|
|
||||
notifications_batch.each do |notification|
|
||||
update_notification(notification)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_notification(notification)
|
||||
updated_meta = (notification.meta || {}).merge('last_snoozed_at' => notification.snoozed_until)
|
||||
|
||||
notification.update!(
|
||||
snoozed_until: nil,
|
||||
updated_at: Time.current,
|
||||
last_activity_at: Time.current,
|
||||
meta: updated_meta,
|
||||
read_at: nil
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user