Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #52

Merged
merged 5 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@ class ApplicationJob < ActiveJob::Base

# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
queue_as :default

rescue_from(StandardError) do |exception|
Sentry.capture_message(exception)
end

retry_on StandardError, wait: :exponentially_longer, attempts: 5
end
6 changes: 0 additions & 6 deletions app/jobs/bling_order_item_creator_base_job.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# frozen_string_literal: true

class BlingOrderItemCreatorBaseJob < ApplicationJob
queue_as :default
rescue_from(StandardError) do |exception|
Sentry.capture_message(exception)
end

retry_on StandardError, wait: :exponentially_longer, attempts: 5

attr_accessor :account_id, :alteration_date

Expand Down
7 changes: 2 additions & 5 deletions app/jobs/order_items_job.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
class OrderItemsJob < ApplicationJob
queue_as :default
retry_on StandardError, attempts: 5, wait: :exponentially_longer
queue_as :items

def perform(record)
return unless record.items.empty?

account_id = record.account_id
items_attributes = []
order = Services::Bling::FindOrder.call(id: record.bling_order_id, order_command: 'find_order', tenant: account_id)
raise StandardError if order['error'].present?
raise(StandardError, order['error']) if order['error'].present?

order['data']['itens'].each do |item|
items_attributes << {
Expand Down
2 changes: 2 additions & 0 deletions app/models/bling_order_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def value
end

def synchronize_items
return unless items.empty?

OrderItemsJob.perform_later(self)
end
end
Loading