Last active
April 12, 2025 14:01
-
-
Save pmatsinopoulos/4b42cba1efbbbf7e3b9b57471396cbbf to your computer and use it in GitHub Desktop.
Update balance to a random value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CalculateUserBalanceJob < ApplicationJob | |
queue_as :default | |
def perform(user_id) | |
user = User.find(user_id) | |
puts "Calculating balance for user: #{user.email}" | |
user_balance = user.user_balance | |
sleep rand(5..10) | |
new_balance = rand(5..50) | |
user_balance.update!(balance: new_balance, job_id: provider_job_id) | |
JobLog.create!(job_id: provider_job_id, balance: new_balance) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment