Class: SourceMonitor::LogCleanupJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/source_monitor/log_cleanup_job.rb

Constant Summary collapse

DEFAULT_FETCH_LOG_RETENTION_DAYS =
90
DEFAULT_SCRAPE_LOG_RETENTION_DAYS =
45

Instance Method Summary collapse

Methods inherited from ApplicationJob

source_monitor_queue

Instance Method Details

#perform(options = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'app/jobs/source_monitor/log_cleanup_job.rb', line 15

def perform(options = nil)
  options = SourceMonitor::Jobs::CleanupOptions.normalize(options)

  now = SourceMonitor::Jobs::CleanupOptions.resolve_time(options[:now])
  fetch_cutoff = resolve_cutoff(now:, days: options[:fetch_logs_older_than_days], default: DEFAULT_FETCH_LOG_RETENTION_DAYS)
  scrape_cutoff = resolve_cutoff(now:, days: options[:scrape_logs_older_than_days], default: DEFAULT_SCRAPE_LOG_RETENTION_DAYS)

  prune_fetch_logs(fetch_cutoff) if fetch_cutoff
  prune_scrape_logs(scrape_cutoff) if scrape_cutoff
end