Sha256: e4ab2c6ed5eafe37effd3884825bf5eb99655313977c54506d0860e83d30dc2d
Contents?: true
Size: 1.25 KB
Versions: 56
Compression:
Stored size: 1.25 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_for_item(item) 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
56 entries across 56 versions & 1 rubygems