Class: SeoVisitsSyncFinalizer

Inherits:
Object
  • Object
show all
Defined in:
app/workers/seo_visits_sync_finalizer.rb

Overview

Reports completion of the actual SiteMap write jobs rather than the short
scheduled dispatcher.

Instance Method Summary collapse

Instance Method Details

#on_complete(status, options) ⇒ Object

Parameters:

  • status (Sidekiq::Batch::Status)

    batch status for the write jobs

  • options (Hash)

    batch payload serialized by the dispatcher

Options Hash (options):

  • started_at (String)

    ISO8601 time the batch started

  • page_count (Integer, String)

    number of pages written

  • period_end (String)

    last date included in the sync



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/workers/seo_visits_sync_finalizer.rb', line 11

def on_complete(status, options)
  duration = Time.current - Time.iso8601(options.fetch('started_at'))
  failures = status.failures.to_i
  page_count = options.fetch('page_count').to_i

  Rails.event.notify(
    'seo.visit_sync',
    action: 'completed',
    batch_id: status.bid,
    failures:,
    page_count:,
    duration_seconds: duration.round(1),
    period_end: options.fetch('period_end')
  )

  if defined?(Appsignal) && Appsignal.active?
    Appsignal.add_distribution_value('seo.visit_sync.duration_seconds', duration)
    Appsignal.increment_counter('seo.visit_sync.failures', failures) if failures.positive?
  end

  ErrorReporting.error("SEO visit sync batch #{status.bid}: #{failures} page batch(es) failed") if failures.positive?
end