Class: Netcore::SyncUserDataWorker

Inherits:
ApplicationWorker show all
Includes:
Payload
Defined in:
app/workers/netcore/sync_user_data_worker.rb

Overview

Upload user data to Netcore Uplading process is very a long time process So we shoudln't use User.all

Constant Summary collapse

USER_FROM_CLEVERTAP_LIST_ID =
5

Instance Method Summary collapse

Methods included from Payload

#fav_payload, #reservation_data_payload, #reward_data_payload, #user_loyalty_payload, #user_properties, #user_properties_for_client

Methods included from CountryIdMemoization

#malaysia_id, #singapore_id, #thailand_id

Methods inherited from ApplicationWorker

unlimited_retry

Instance Method Details

#perform(user_ids) ⇒ Object

Upload user data to Netcore

Parameters:

  • user_ids (Array<Integer>)

    list of user ids



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/workers/netcore/sync_user_data_worker.rb', line 14

def perform(user_ids)
  return if user_ids.blank?

  return if AdminSetting.enable_netcore_events.to_s == 'false'

  user_data = []
  active_users = User.active.where(id: user_ids)
  return if active_users.blank?

  active_users.find_each do |user|
    user_data << user_properties(user)
  end

  return if user_data.blank?

  payload = {
    listid: USER_FROM_CLEVERTAP_LIST_ID,
    notifyemail: AdminSetting.netcore_report_email,
    callbackurl: "#{Figaro.env.HH_HOST_URL}/api/webhook/netcore_callback",
    primarykey: 'email',
    data: user_data,
  }

  client.upload_v3(payload)
end