mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
queue a downgrade job several months in the future to reset prepay storage, needs testing
This commit is contained in:
parent
c4f0ce692f
commit
33495e55ac
@ -30,10 +30,7 @@ class PayPalPrepayProcessingJob < ApplicationJob
|
||||
|
||||
# Add the extra Premium space
|
||||
SubscriptionService.add_any_referral_bonuses(invoice.user, 'premium')
|
||||
|
||||
# Rather than queueing up a job to run N months from now to reset space,
|
||||
# we'll probably go with a worker that ensures everyone's space is correct
|
||||
# every day. Worker TBD.
|
||||
PremiumDowngradeJob.set(wait: (invoice.months).months).perform_later(invoice.user_id)
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
15
app/jobs/premium_downgrade_job.rb
Normal file
15
app/jobs/premium_downgrade_job.rb
Normal file
@ -0,0 +1,15 @@
|
||||
class PremiumDowngradeJob < ApplicationJob
|
||||
queue_as :low_priority
|
||||
|
||||
def perform(*args)
|
||||
user_id = args.shift
|
||||
|
||||
user = User.find_by(id: user_id)
|
||||
raise "No user to downgrade; id=#{user_id}" if user.nil?
|
||||
|
||||
# Remove any bonus bandwidth granted by the plan
|
||||
premium_bandwidth_bonus = BillingPlan.find(4).bonus_bandwidth_kb
|
||||
user.update!(upload_bandwidth_kb: user.upload_bandwidth_kb - premium_bandwidth_bonus)
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user