diff --git a/app/models/online_notification.rb b/app/models/online_notification.rb index 69508555b..6388d9e60 100644 --- a/app/models/online_notification.rb +++ b/app/models/online_notification.rb @@ -260,14 +260,14 @@ cleanup old online notifications with dedicated times max_age = Time.zone.now - 9.months - max_own_seen = Time.zone.now - 35.minutes + max_own_seen = Time.zone.now - 10.minutes max_auto_seen = Time.zone.now - 8.hours OnlineNotification.cleanup(max_age, max_own_seen, max_auto_seen) =end - def self.cleanup(max_age = Time.zone.now - 9.months, max_own_seen = Time.zone.now - 35.minutes, max_auto_seen = Time.zone.now - 8.hours) + def self.cleanup(max_age = Time.zone.now - 9.months, max_own_seen = Time.zone.now - 10.minutes, max_auto_seen = Time.zone.now - 8.hours) OnlineNotification.where('created_at < ?', max_age).delete_all OnlineNotification.where('seen = ? AND updated_at < ?', true, max_own_seen).each {|notification| diff --git a/test/unit/online_notifiaction_test.rb b/test/unit/online_notifiaction_test.rb index 12d3c8a7f..8956794ed 100644 --- a/test/unit/online_notifiaction_test.rb +++ b/test/unit/online_notifiaction_test.rb @@ -500,8 +500,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase user_id: agent_user1.id, created_by_id: 1, updated_by_id: 1, - created_at: Time.zone.now - 10.months, - updated_at: Time.zone.now - 10.months, + created_at: Time.zone.now - 5.months, + updated_at: Time.zone.now - 5.months, ) online_notification2 = OnlineNotification.add( type: 'create', @@ -511,8 +511,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase user_id: agent_user1.id, created_by_id: 1, updated_by_id: 1, - created_at: Time.zone.now - 10.months, - updated_at: Time.zone.now - 10.months, + created_at: Time.zone.now - 5.months, + updated_at: Time.zone.now - 5.months, ) online_notification3 = OnlineNotification.add( type: 'create', @@ -555,8 +555,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase user_id: agent_user1.id, created_by_id: agent_user1.id, updated_by_id: agent_user1.id, - created_at: Time.zone.now - 10.minutes, - updated_at: Time.zone.now - 10.minutes, + created_at: Time.zone.now - 5.minutes, + updated_at: Time.zone.now - 5.minutes, ) online_notification7 = OnlineNotification.add( type: 'create', @@ -566,8 +566,8 @@ class OnlineNotificationTest < ActiveSupport::TestCase user_id: agent_user1.id, created_by_id: agent_user2.id, updated_by_id: agent_user2.id, - created_at: Time.zone.now - 10.minutes, - updated_at: Time.zone.now - 10.minutes, + created_at: Time.zone.now - 5.minutes, + updated_at: Time.zone.now - 5.minutes, ) OnlineNotification.cleanup