Skip to content

Commit

Permalink
fix(netsuite): Aggregator jobs should be unique (#2818)
Browse files Browse the repository at this point in the history
## Context

While syncing invoices to Netsuite, some invoices were sent twice

## Description

Add `unique :until_executed` to aggregator jobs so that the resources
are only sync'd once.
  • Loading branch information
ivannovosad authored Nov 14, 2024
1 parent 360e224 commit 0d43376
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/jobs/integrations/aggregator/credit_notes/create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module CreditNotes
class CreateJob < ApplicationJob
queue_as 'integrations'

unique :until_executed, on_conflict: :log

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

Expand Down
2 changes: 2 additions & 0 deletions app/jobs/integrations/aggregator/invoices/create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module Invoices
class CreateJob < ApplicationJob
queue_as 'integrations'

unique :until_executed, on_conflict: :log

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 3
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Crm
class CreateCustomerAssociationJob < ApplicationJob
queue_as 'integrations'

unique :until_executed, on_conflict: :log

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

Expand Down
2 changes: 2 additions & 0 deletions app/jobs/integrations/aggregator/invoices/crm/create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Crm
class CreateJob < ApplicationJob
queue_as 'integrations'

unique :until_executed, on_conflict: :log

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100
Expand Down
2 changes: 2 additions & 0 deletions app/jobs/integrations/aggregator/invoices/crm/update_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Crm
class UpdateJob < ApplicationJob
queue_as 'integrations'

unique :until_executed, on_conflict: :log

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100
Expand Down
2 changes: 2 additions & 0 deletions app/jobs/integrations/aggregator/payments/create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module Payments
class CreateJob < ApplicationJob
queue_as 'integrations'

unique :until_executed, on_conflict: :log

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 5
retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Crm
class CreateCustomerAssociationJob < ApplicationJob
queue_as 'integrations'

unique :until_executed, on_conflict: :log

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Crm
class CreateJob < ApplicationJob
queue_as 'integrations'

unique :until_executed, on_conflict: :log

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module Crm
class UpdateJob < ApplicationJob
queue_as 'integrations'

unique :until_executed, on_conflict: :log

retry_on LagoHttpClient::HttpError, wait: :polynomially_longer, attempts: 10
retry_on Integrations::Aggregator::BasePayload::Failure, wait: :polynomially_longer, attempts: 10
retry_on RequestLimitError, wait: :polynomially_longer, attempts: 100
Expand Down

0 comments on commit 0d43376

Please sign in to comment.