wip: order checkout
This commit is contained in:
23
app/jobs/expired_orders_cleanup_job.rb
Normal file
23
app/jobs/expired_orders_cleanup_job.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
class ExpiredOrdersCleanupJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform
|
||||
# Find and expire all draft orders that have passed their expiry time
|
||||
expired_orders = Order.expired_drafts
|
||||
|
||||
Rails.logger.info "Found #{expired_orders.count} expired orders to process"
|
||||
|
||||
expired_orders.find_each do |order|
|
||||
begin
|
||||
order.expire_if_overdue!
|
||||
Rails.logger.info "Expired order ##{order.id} for user ##{order.user_id}"
|
||||
rescue => e
|
||||
Rails.logger.error "Failed to expire order ##{order.id}: #{e.message}"
|
||||
# Continue processing other orders even if one fails
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
Rails.logger.info "Completed expired orders cleanup job"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user