Class: Webhookdb::Jobs::StaleRowDeleter

Inherits:
Object
  • Object
show all
Extended by:
Async::Job
Defined in:
lib/webhookdb/jobs/stale_row_deleter.rb

Overview

Run the stale_row_deleter for each service integration which match the given where/exclude clauses. This is generally used to delete old stale rows in the backend (by passing initial: true) when a new stale row deleter is deployed.

Instance Method Summary collapse

Methods included from Async::Job

extended

Instance Method Details

#perform(opts = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/webhookdb/jobs/stale_row_deleter.rb', line 12

def perform(opts={})
  opts = opts.deep_symbolize_keys
  opts[:where] ||= {}
  opts[:exclude] ||= {}
  opts[:initial] ||= false
  ds = Webhookdb::ServiceIntegration.dataset
  ds = ds.where(opts[:where]) if opts[:where]
  ds = ds.exclude(opts[:exclude]) if opts[:exclude]
  self.set_job_tags(dataset: ds.sql)
  count = 0
  ds.each do |sint|
    self.with_log_tags(sint.log_tags) do
      d = sint.replicator.stale_row_deleter
      opts[:initial] ? d.run_initial : d.run
      count += 1
    end
  end
  self.set_job_tags(run_count: count)
end