2022-01-18 10:14:54 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Packages
|
|
|
|
module Destructible
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
class_methods do
|
2022-04-22 08:08:38 -04:00
|
|
|
def next_pending_destruction(order_by:)
|
2022-01-18 10:14:54 -05:00
|
|
|
set = pending_destruction.limit(1).lock('FOR UPDATE SKIP LOCKED')
|
|
|
|
set = set.order(order_by) if order_by
|
|
|
|
set.take
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|