Add PayRecurringDonation(s)Job

This commit is contained in:
Eric Schultz 2019-11-07 17:06:45 -06:00
parent 0144372084
commit e073b9a7d0
3 changed files with 17 additions and 15 deletions

View file

@ -0,0 +1,7 @@
class PayRecurringDonationJob < ApplicationJob
queue_as :rec_don_payments
def perform(id)
PayRecurringDonation.with_stripe(id)
end
end

View 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

View file

@ -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