1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require 'current_api_client'
7 module SweepTrashedCollections
8 extend CurrentApiClient
13 where('delete_at is not null and delete_at < statement_timestamp()').
16 where('is_trashed = false and trash_at < statement_timestamp()').
17 update_all('is_trashed = true')
21 def self.sweep_if_stale
22 return if Rails.configuration.trash_sweep_interval <= 0
23 exp = Rails.configuration.trash_sweep_interval.seconds
25 Rails.cache.fetch('SweepTrashedCollections', expires_in: exp) do
30 Thread.current.abort_on_exception = false
34 Rails.logger.error "#{e.class}: #{e}\n#{e.backtrace.join("\n\t")}"
36 ActiveRecord::Base.connection.close