Class: Netcore::SyncAllUserDataWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- Netcore::SyncAllUserDataWorker
- Defined in:
- app/workers/netcore/sync_all_user_data_worker.rb
Overview
This worker is responsible for syncing last week's updated user data to Netcore. It will fetch all users who have been updated in the last week and send their IDs to the Netcore::SyncUserDataWorker. The batch size is set to 1000, as the Netcore API has a limit of 1000 contacts per request.
Instance Method Summary collapse
Methods inherited from ApplicationWorker
Instance Method Details
#perform ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/workers/netcore/sync_all_user_data_worker.rb', line 7 def perform return if AdminSetting.enable_netcore_events.to_s == 'false' # Netcore API has a limit of 1000 contacts per request # ref: https://developer.netcorecloud.com/docs/add-bulk-contact-through-api#api-specs batch_size = 1000 UserLoyalty.updated_in_last_week.select('id, user_id').find_in_batches(batch_size: batch_size) do |user_loyalties| user_ids = user_loyalties.map(&:user_id) Netcore::SyncUserDataWorker.perform_async(user_ids) end end |