Class: SeoVisitsSyncBatchWorker
- Inherits:
-
Object
- Object
- SeoVisitsSyncBatchWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/seo_visits_sync_batch_worker.rb
Overview
Applies one bounded SiteMap cohort from the daily visit aggregate.
Defined Under Namespace
Classes: AggregateIncompleteError
Instance Method Summary collapse
-
#perform(site_map_ids, period_end) ⇒ Object
Runs the job.
Instance Method Details
#perform(site_map_ids, period_end) ⇒ Object
Runs the job.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/workers/seo_visits_sync_batch_worker.rb', line 17 def perform(site_map_ids, period_end) started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = Seo::VisitsSyncService.new(site_map_ids:, period_end:).call duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - started_at if defined?(Appsignal) && Appsignal.active? Appsignal.add_distribution_value('seo.visit_sync.batch_duration_seconds', duration) Appsignal.add_distribution_value('seo.visit_sync.pages', result.fetch(:pages_updated)) end Rails.event.notify( 'seo.visit_sync_batch', action: result[:deferred] ? 'deferred' : 'completed', pages_updated: result.fetch(:pages_updated), duration_seconds: duration.round(1), period_end: ) return unless result[:deferred] raise AggregateIncompleteError, "Daily visit aggregate is incomplete through #{period_end}" end |