Skip to content

Instantly share code, notes, and snippets.

@bleonard
Created May 2, 2017 05:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bleonard/057252a6b0a21f6f093cc633f2689c8b to your computer and use it in GitHub Desktop.
Save bleonard/057252a6b0a21f6f093cc633f2689c8b to your computer and use it in GitHub Desktop.
class InvoiceChargeBatchWorker
include TResque::Worker
worker_lock :all
queue_lock :all
def work
Invoice.where(stat: 'pending').find_each do |invoice|
InvoiceChargeWorker.enqueue(invoice_id: invoice.id)
end
end
end
# process all pending invoices
InvoiceChargeBatchWorker.enqueue()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment