Skip to content

Commit

Permalink
Only update balance if changed
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgoll committed Jan 24, 2025
1 parent 61321f6 commit c655b75
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ def enrich_data_later
end

def update_with_sync!(attributes)
should_update_balance = attributes[:balance] && attributes[:balance].to_d != balance

transaction do
update!(attributes)
update_balance!(attributes[:balance]) if attributes[:balance]
update_balance!(attributes[:balance]) if should_update_balance
end

sync_later
Expand Down

0 comments on commit c655b75

Please sign in to comment.