~singpolyma/whiplash-mboa

69bdf926decae3936811cee11063891b51a3bde3 — Stephen Paul Weber 1 year, 6 months ago fc29468
Make sure shopify app is all set up before starting background tasks
2 files changed, 7 insertions(+), 16 deletions(-)

M config/initializers/shopify_app.rb
D config/initializers/z_recurring_jobs.rb
M config/initializers/shopify_app.rb => config/initializers/shopify_app.rb +7 -0
@@ 50,5 50,12 @@ Rails.application.config.after_initialize do
		)

		ShopifyApp::WebhooksManager.add_registrations

		Shop.all.each do |shop|
			next unless shop.whiplash_api_key

			SyncAssignedOrdersJob.perform_later(shop, true)
			SyncWhiplashOrderStatusJob.perform_later(shop, true)
		end
	end
end

D config/initializers/z_recurring_jobs.rb => config/initializers/z_recurring_jobs.rb +0 -16
@@ 1,16 0,0 @@
# frozen_string_literal: true

if Rake.application.top_level_tasks.empty?
	module WhiplashMboa
		class Application
			config.after_initialize do
				Shop.all.each do |shop|
					next unless shop.whiplash_api_key

					SyncAssignedOrdersJob.perform_later(shop, true)
					SyncWhiplashOrderStatusJob.perform_later(shop, true)
				end
			end
		end
	end
end