Skip to content

Commit 14d366d

Browse files
Merge pull request #52 from Purple-Stock/staging
Staging
2 parents b593edb + 27a1ce1 commit 14d366d

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

app/jobs/application_job.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@ class ApplicationJob < ActiveJob::Base
66

77
# Most jobs are safe to ignore if the underlying records are no longer available
88
# discard_on ActiveJob::DeserializationError
9+
queue_as :default
10+
11+
rescue_from(StandardError) do |exception|
12+
Sentry.capture_message(exception)
13+
end
14+
15+
retry_on StandardError, wait: :exponentially_longer, attempts: 5
916
end

app/jobs/bling_order_item_creator_base_job.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# frozen_string_literal: true
22

33
class BlingOrderItemCreatorBaseJob < ApplicationJob
4-
queue_as :default
5-
rescue_from(StandardError) do |exception|
6-
Sentry.capture_message(exception)
7-
end
8-
9-
retry_on StandardError, wait: :exponentially_longer, attempts: 5
104

115
attr_accessor :account_id, :alteration_date
126

app/jobs/order_items_job.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
class OrderItemsJob < ApplicationJob
2-
queue_as :default
3-
retry_on StandardError, attempts: 5, wait: :exponentially_longer
2+
queue_as :items
43

54
def perform(record)
6-
return unless record.items.empty?
7-
85
account_id = record.account_id
96
items_attributes = []
107
order = Services::Bling::FindOrder.call(id: record.bling_order_id, order_command: 'find_order', tenant: account_id)
11-
raise StandardError if order['error'].present?
8+
raise(StandardError, order['error']) if order['error'].present?
129

1310
order['data']['itens'].each do |item|
1411
items_attributes << {

app/models/bling_order_item.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ def value
133133
end
134134

135135
def synchronize_items
136+
return unless items.empty?
137+
136138
OrderItemsJob.perform_later(self)
137139
end
138140
end

0 commit comments

Comments
 (0)