Class: SourceArchivalWorker
- Inherits:
-
Object
- Object
- SourceArchivalWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/source_archival_worker.rb
Overview
Sidekiq worker: source archival.
Constant Summary collapse
- DEFAULT_STALE_MONTHS =
Default stale months.
36
Instance Method Summary collapse
Instance Method Details
#perform(stale_months: DEFAULT_STALE_MONTHS) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/workers/source_archival_worker.rb', line 12 def perform(stale_months: DEFAULT_STALE_MONTHS) cutoff = stale_months.to_i.months.ago preserve_ids = build_preserve_set(cutoff) preserve_ids << Source::UNKNOWN_ID archived_count = Source .where(visibility: :active) .where.not(id: preserve_ids) .update_all(visibility: :archived) logger.info "SourceArchivalWorker: Archived #{archived_count} sources " \ "with no activity since #{cutoff.to_date} " \ "(#{preserve_ids.size} preserved)" end |