Skip to content

Conversation

brunomiguelpinto
Copy link
Contributor

@brunomiguelpinto brunomiguelpinto commented May 23, 2025

Context

Threshold-based wallet top-ups can sometimes enqueue duplicate jobs if the job is triggered multiple times within a short time window. This leads to unnecessary or duplicate credit grants.

To prevent this, we want to ensure that these jobs are uniquely enqueued based on relevant identifiers: organization_id, wallet_id, paid_credits, and granted_credits.

Description

This PR adds job uniqueness handling to WalletTransactions::CreateJob using sidekiq-unique-jobs, but only when the unique_transaction flag is set to true.

  • Introduced conditional uniqueness based on unique_transaction
  • Fallback to non-unique behaviour when the flag is not set

This keeps behaviour backward-compatible for other use cases of CreateJob, while enforcing uniqueness where it matters.

@brunomiguelpinto brunomiguelpinto changed the title feat: added job unique params feat: Unique wallet transaction job for threshold top-ups May 23, 2025
@brunomiguelpinto brunomiguelpinto self-assigned this May 23, 2025
@brunomiguelpinto brunomiguelpinto merged commit 7ba40d5 into main May 26, 2025
14 checks passed
@brunomiguelpinto brunomiguelpinto deleted the fix-wallet-unique-job branch May 26, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants