Add PayRecurringDonation(s)Job
This commit is contained in:
parent
0144372084
commit
e073b9a7d0
3 changed files with 17 additions and 15 deletions
7
app/jobs/pay_recurring_donation_job.rb
Normal file
7
app/jobs/pay_recurring_donation_job.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class PayRecurringDonationJob < ApplicationJob
|
||||||
|
queue_as :rec_don_payments
|
||||||
|
|
||||||
|
def perform(id)
|
||||||
|
PayRecurringDonation.with_stripe(id)
|
||||||
|
end
|
||||||
|
end
|
9
app/jobs/pay_recurring_donations_job.rb
Normal file
9
app/jobs/pay_recurring_donations_job.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
class PayRecurringDonationsJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(*ids)
|
||||||
|
ids.each do |id|
|
||||||
|
PayRecurringDonationJob.perform_later(id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -15,21 +15,7 @@ module PayRecurringDonation
|
||||||
QueryRecurringDonations._all_that_are_due
|
QueryRecurringDonations._all_that_are_due
|
||||||
)[1..-1].flatten
|
)[1..-1].flatten
|
||||||
|
|
||||||
jobs = ids.map do |id|
|
PayRecurringDonationsJob.perform_later(*id)
|
||||||
{ handler: DelayedJobHelper.create_handler(PayRecurringDonation, :with_stripe, [id]) }
|
|
||||||
end
|
|
||||||
|
|
||||||
Psql.execute(Qexpr.new.insert(:delayed_jobs, jobs,
|
|
||||||
common_data: {
|
|
||||||
run_at: Time.current,
|
|
||||||
attempts: 0,
|
|
||||||
failed_at: nil,
|
|
||||||
last_error: nil,
|
|
||||||
locked_at: nil,
|
|
||||||
locked_by: nil,
|
|
||||||
priority: 0,
|
|
||||||
queue: 'rec-don-payments'
|
|
||||||
}))
|
|
||||||
ids
|
ids
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue