~singpolyma/whiplash-mboa

59d58002c5c546a8e4698112663e091bb5782e25 — Stephen Paul Weber 1 year, 6 months ago 048736b
Add debugging for sync order status and made it more frequent
1 files changed, 7 insertions(+), 4 deletions(-)

M app/jobs/sync_whiplash_order_status_job.rb
M app/jobs/sync_whiplash_order_status_job.rb => app/jobs/sync_whiplash_order_status_job.rb +7 -4
@@ 6,16 6,19 @@ class SyncWhiplashOrderStatusJob < ApplicationJob
	after_perform do |job|
		next unless job.arguments.length == 2 && job.arguments.last

		self.class.set(wait: 1.hour).perform_later(*job.arguments)
		self.class.set(wait: 15.minutes).perform_later(*job.arguments)
	end

	def perform(shop, _=false)
		shop.with_shopify_session do
			WHIPLASH_HTTP.get(
			response = WHIPLASH_HTTP.get(
				"orders",
				{ provider: "api", limit: 100, status: [40, 95, 300] },
				{ provider: "api", limit: 200, status: [40, 95, 300] },
				"X-API-KEY" => shop.whiplash_api_key
			).body.each do |order|
			)
			raise response.inspect if response.is_a?(String) || response.status >= 400

			response.body.each do |order|
				next unless order["originator_id"]

				fulfillment_order = ShopifyAPI::FulfillmentOrder.find(id: order["originator_id"]) rescue nil