Class: MicrosoftAdsCampaignSyncWorker
- Inherits:
-
Object
- Object
- MicrosoftAdsCampaignSyncWorker
- Includes:
- Sidekiq::Job
- Defined in:
- app/workers/microsoft_ads_campaign_sync_worker.rb
Overview
Sidekiq worker: syncs Microsoft Advertising (Bing Ads) campaigns into the
sources table once a day.
Direct parallel to OpenaiAdsCampaignSyncWorker / GoogleAdsCampaignSyncWorker:
every active or paused campaign on the Microsoft Advertising account gets a
1:1 Source record under the "Microsoft Ads" sub-parent (seeded by
..._seed_microsoft_ads_sub_source.rb under the existing "Bing" source).
Campaigns that disappear from the account (deleted, suspended) are mirrored
by setting the local Source's visibility to :archived rather than
destroying the row, so historical attribution on old visits / orders
survives.
Unlike the REST platforms this reads through MicrosoftAds::CampaignManagementClient
(SOAP GetCampaignsByAccountId) and authenticates with the developer token
plus a lazily-refreshed OAuth access token from MicrosoftAds::OauthService.
Scheduled at 02:00 America/Chicago daily — after Google (01:00), OpenAI
(01:15), Pinterest (01:30) and Facebook (01:45) so the API ceilings don't
compete for the same window.
Constant Summary collapse
- BING_PARENT_SOURCE_ID =
Existing "Bing" source — Websites and Search Engines > Bing (Source 4005).
The "Microsoft Ads" sub-parent the worker fills hangs directly off it,
parallel to the legacy "Bing Ad Campaign" / "Bing Organic Search" nodes. 4005- ADS_PARENT_NAME =
Name of the worker-managed sub-parent under "Bing".
'Microsoft Ads'- ACTIVE_STATUSES =
Microsoft CampaignStatus values (compared case-insensitively) that should
appear as activeSourcerecords. Everything else returned — and any
campaign that drops out of the result entirely (Deleted aren't returned
by default) — maps to localSource#visibility = :archived. %w[active paused manualpaused budgetpaused budgetandmanualpaused].freeze
Instance Method Summary collapse
Instance Method Details
#perform ⇒ Object
44 45 46 47 48 |
# File 'app/workers/microsoft_ads_campaign_sync_worker.rb', line 44 def perform Source.with_advisory_lock('microsoft_ads_campaign_sync', timeout_seconds: 10) do sync_campaigns end end |