Skip to content

Instantly share code, notes, and snippets.

@swalke16
Created February 13, 2019 15:31
Show Gist options
  • Save swalke16/df6821da6f38868fe75971ecf25a5925 to your computer and use it in GitHub Desktop.
Save swalke16/df6821da6f38868fe75971ecf25a5925 to your computer and use it in GitHub Desktop.
Sync Places For New Categories
# this script given that new categories have been created and attached to the relevant apps
# will for the specified account_names and category_names sync all the relevant google places
account_names = ["Baltimore", "Denver", "Los Angeles",
"Short North", "SMRT Columbus"]
category_names = ["Antiques & Vintage", "Beer, Wine, & Spirits", "Juice & Natural Foods"]
accounts = Account.where(name: account_names)
accounts.each do |account|
category_ids = account.categories.where(name: category_names).pluck(:id)
strategies = CategoryQueryStrategy.where(category_id: category_ids)
place_lists = account.place_lists.where(type: 'PlaceLists::Google')
account.kiosks.each do |kiosk|
strategies.each do |strategy|
place_lists.each do |place_list|
p "Queuing Job to Sync: #{account.name} - #{kiosk.location_description} - #{place_list.name} - #{strategy.query}"
SyncExternalPlacesJobs::GoogleJob.perform_later(strategy, kiosk, place_list)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment