Class: SeoVisitsSyncWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Status::Worker, Sidekiq::Worker
Defined in:
app/workers/seo_visits_sync_worker.rb

Overview

Syncs first-party visit counts from our Visits table.
Can run in parallel with GSC and GA4 sync (no dependencies).
No external API - purely database queries, very fast.

Updates: visit_count_30d on SiteMap records

Scheduled nightly at 2:15 AM CT via sidekiq_production_schedule.yml

Instance Method Summary collapse

Instance Method Details

#perform(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/workers/seo_visits_sync_worker.rb', line 17

def perform(options = {})
  options = options.with_indifferent_access
  total 2

  at 1, 'Syncing first-party visit counts...'
  result = Seo::VisitsSyncService.new(options.slice(:days)).process

  at 2, 'Complete'
  store info_message: "Visits: #{result[:pages_updated]} pages updated"
  store pages_updated: result[:pages_updated]
  store errors: result[:errors]

  Rails.logger.info "[SeoVisitsSyncWorker] Completed: #{result[:pages_updated]} pages"
rescue StandardError => e
  Rails.logger.error "[SeoVisitsSyncWorker] Failed: #{e.message}"
  store info_message: "Visits sync failed: #{e.message}"
  raise
end