only cancel recent duplicate pending messages

a created_at scope will limit the search at most two
partitions

closes #CORE-2381

Change-Id: I4893eaad14198385e88dc7455200198eac550e24
Reviewed-on: https://gerrit.instructure.com/178647
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
Tested-by: Rob Orton <rob@instructure.com>
This commit is contained in:
James Williams 2019-01-21 07:56:41 -07:00 committed by Rob Orton
parent 0b31194649
commit e39e27ae40
1 changed files with 1 additions and 0 deletions

View File

@ -297,6 +297,7 @@ class NotificationMessageCreator
by_name(@notification.name).
for_user(@to_users + @to_channels).
cancellable.
where("created_at BETWEEN ? AND ?", Setting.get("pending_duplicate_message_window_hours", "6").to_i.hours.ago, Time.now.utc).
update_all(:workflow_state => 'cancelled')
end