Sha256: 3bad2cc333eef60783bd55cee0fc50bbd031ab7cd96f75000a313df39c1b2fca
Contents?: true
Size: 1.23 KB
Versions: 31
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module Cron # # Trim notifications in system after 30 days. # # This was historically done by a database index, however with the introduction # of adding an email attachment, and thus another collection, this needed to move # to a daily job here so that: # 1. the object hierarchy is deleted # 2. The paperclip call backs are fired to remove the file from S3 # # In case you are wondering why not make it an embedded class and allow the index # method to still work, the answer is that it won't clean up the S3 files. # class TrimNotifications < TrimCollection # # Return the collection # def collection Notification.all end # # Test if this should be archived # def archive?(item) time = if item.is_a?(EmailNotification) && template?(item) 5.years.ago.utc else allowed_time end item.updated_at < time end # # Determine if the notification has a template associated with it # def template?(item) item.notification_template.present? || item[:notification_template_id].present? && Template.where(_id: item[:notification_template_id]).present? end end end
Version data entries
31 entries across 31 versions & 1 rubygems