Sha256: 29b6d294b46acd47563a3417f1d834a8c4ca3de0deb4027691ba320af8b41389
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module SolidusBactracs module Api class ScheduleShipmentSyncsJob < ApplicationJob queue_as :default def perform shipments = query_shipments Rails.logger.info("#{self.class.name} - #{shipments.count} shipments to sync to Bactracs") shipments.find_in_batches(batch_size: SolidusBactracs.config.api_batch_size) do |batch| SyncShipmentsJob.perform_later(batch.to_a) end rescue StandardError => e SolidusBactracs.config.error_handler.call(e, {}) end def shippable_skus SolidusBactracs.config.shippable_skus.present? ? SolidusBactracs.config.shippable_skus : Spree::Variant.pluck(:sku) end def query_shipments shipments = SolidusBactracs::Shipment::PendingApiSyncQuery.apply( ::Spree::Shipment .joins(inventory_units: [:variant]) .where("spree_variants.sku" => SolidusBactracs.config.shippable_skus) .where("spree_shipments.state" => :ready) .where(bactracs_synced_at: nil) .distinct ) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems