feat(wallet): Improve how we're refreshing wallet's ongoing balance #2682
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new feature to flag wallets that are ready to be refreshed and updates the related logic across the codebase. The most important changes include adding a new
ready_to_be_refreshed
attribute to theWallet
model, updating the job and service logic to handle this new attribute.Model Changes:
app/models/wallet.rb
: Added a new scopeready_to_be_refreshed
and a new boolean attributeready_to_be_refreshed
with a default value offalse
.Job and Service Logic Updates:
app/jobs/clock/refresh_wallets_ongoing_balance_job.rb
: Updated the job to process only wallets that are ready to be refreshed.app/services/events/post_process_service.rb
: Added a new methodflag_wallets_for_refresh
to set theready_to_be_refreshed
attribute totrue
for active wallets. [1] [2]app/services/wallets/balance/update_ongoing_service.rb
: Set theready_to_be_refreshed
attribute tofalse
after updating the wallet balance.Database Migration:
db/migrate/20241014093451_add_ready_to_be_refreshed_to_wallets.rb
: Added a migration to introduce theready_to_be_refreshed
column and its index.