Class: SeoGscSyncWorker

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

Overview

Syncs search performance data from Google Search Console.
Can run in parallel with GA4 and Visits sync (no dependencies).

Writes to site_map_data_points (source of truth) + caches seo_clicks on site_maps.

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

Instance Method Summary collapse

Instance Method Details

#perform(options = {}) ⇒ Object



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

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

  at 1, 'Syncing Google Search Console metrics...'
  result = Seo::GscSyncService.new(options.slice(:start_date, :end_date)).process

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

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