Class: SeoVisitPageDailyRefreshWorker
- Inherits:
-
Object
- Object
- SeoVisitPageDailyRefreshWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/seo_visit_page_daily_refresh_worker.rb
Overview
Rebuilds exactly one daily checkpoint. A dedicated one-thread capsule keeps
these grouped scans sequential and gives Sidekiq a safe boundary between days.
Instance Method Summary collapse
-
#perform(visit_date, position = 1, total = 1) ⇒ Object
Runs the job.
Instance Method Details
#perform(visit_date, position = 1, total = 1) ⇒ Object
Runs the job.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/workers/seo_visit_page_daily_refresh_worker.rb', line 16 def perform(visit_date, position = 1, total = 1) started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) result = Seo::VisitPageDailyCountsQuery.new(period_end: visit_date.to_date).refresh_date!(visit_date) duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - started_at = { visit_date: result.fetch(:visit_date).to_s } if defined?(Appsignal) && Appsignal.active? Appsignal.add_distribution_value('seo.visit_aggregate.duration_seconds', duration, ) Appsignal.add_distribution_value('seo.visit_aggregate.source_visits', result.fetch(:source_visits_count), ) Appsignal.add_distribution_value('seo.visit_aggregate.pages', result.fetch(:page_count), ) end Rails.event.notify( 'seo.visit_daily_aggregate', action: 'completed', position:, total:, duration_seconds: duration.round(1), **result ) end |