Reduced time from 35 min to 10 minutes until own read notifications are deleted (get long online notifications faster clean).

This commit is contained in:
Martin Edenhofer 2016-02-24 06:27:47 +01:00
parent 1aae6eacb5
commit 44bff0055a
2 changed files with 10 additions and 10 deletions

View file

@ -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|

View file

@ -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