Created
February 13, 2019 15:31
-
-
Save swalke16/df6821da6f38868fe75971ecf25a5925 to your computer and use it in GitHub Desktop.
Sync Places For New Categories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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