diff --git a/app/jobs/pay_recurring_donation_job.rb b/app/jobs/pay_recurring_donation_job.rb new file mode 100644 index 00000000..7a64e372 --- /dev/null +++ b/app/jobs/pay_recurring_donation_job.rb @@ -0,0 +1,7 @@ +class PayRecurringDonationJob < ApplicationJob + queue_as :rec_don_payments + + def perform(id) + PayRecurringDonation.with_stripe(id) + end +end diff --git a/app/jobs/pay_recurring_donations_job.rb b/app/jobs/pay_recurring_donations_job.rb new file mode 100644 index 00000000..a1b51bdc --- /dev/null +++ b/app/jobs/pay_recurring_donations_job.rb @@ -0,0 +1,9 @@ +class PayRecurringDonationsJob < ApplicationJob + queue_as :default + + def perform(*ids) + ids.each do |id| + PayRecurringDonationJob.perform_later(id) + end + end +end diff --git a/lib/pay_recurring_donation.rb b/lib/pay_recurring_donation.rb index 73293f36..8f293c93 100644 --- a/lib/pay_recurring_donation.rb +++ b/lib/pay_recurring_donation.rb @@ -15,21 +15,7 @@ module PayRecurringDonation QueryRecurringDonations._all_that_are_due )[1..-1].flatten - jobs = ids.map do |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' - })) + PayRecurringDonationsJob.perform_later(*id) ids end