upload_cache_cleanup_job.rb 534 B

123456789101112131415161718
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class UploadCacheCleanupJob < ApplicationJob
  3. def perform
  4. taskbar_form_ids = Taskbar.with_form_id.filter_map(&:persisted_form_id)
  5. return if store_object_id.blank?
  6. Store.where(store_object_id: store_object_id).where('created_at < ?', 1.month.ago).where.not(o_id: taskbar_form_ids).find_each do |store|
  7. Store.remove_item(store.id)
  8. end
  9. end
  10. private
  11. def store_object_id
  12. Store::Object.lookup(name: 'UploadCache')&.id
  13. end
  14. end