2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-07-22 12:35:13 +00:00
|
|
|
|
|
|
|
class UploadCacheCleanupJob < ApplicationJob
|
|
|
|
def perform
|
|
|
|
taskbar_form_ids = Taskbar.with_form_id.filter_map(&:persisted_form_id)
|
2021-10-05 15:18:31 +00:00
|
|
|
return if store_object_id.blank?
|
2021-07-22 12:35:13 +00:00
|
|
|
|
|
|
|
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|
|
|
|
|
Store.remove_item(store.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def store_object_id
|
2021-10-05 15:18:31 +00:00
|
|
|
Store::Object.lookup(name: 'UploadCache')&.id
|
2021-07-22 12:35:13 +00:00
|
|
|
end
|
|
|
|
end
|