Class: OpenaiAdsCampaignSyncWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/workers/openai_ads_campaign_sync_worker.rb

Overview

Sidekiq worker: syncs OpenAI Ads (ChatGPT) campaigns into the sources
table once a day.

Direct parallel to GoogleAdsCampaignSyncWorker: every active or paused
campaign on the OpenAI Ads account gets a 1:1 Source record under the
"ChatGPT Ads" sub-parent (seeded by
20260514130132_seed_chatgpt_ads_and_organic_sub_sources.rb). Archived
campaigns are mirrored by setting the local Source's visibility to
:archived rather than destroying the row, so historical attribution on
old visits / orders survives.

Scheduled at 01:15 America/Chicago daily — 15 minutes after the Google
Ads sync (which runs at 01:00) so the two API ceilings don't compete for
the same window.

See Also:

Constant Summary collapse

ACTIVE_STATUSES =

OpenAI campaign status values that should appear as active Source
records. "archived" maps to local Source#visibility = :archived.

%w[active paused].freeze

Instance Method Summary collapse

Instance Method Details

#performObject



29
30
31
32
33
# File 'app/workers/openai_ads_campaign_sync_worker.rb', line 29

def perform
  Source.with_advisory_lock('openai_ads_campaign_sync', timeout_seconds: 10) do
    sync_campaigns
  end
end