Class: Auctify::BiddingIsCloseToEndNotifierJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/auctify/bidding_is_close_to_end_notifier_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(auction_id:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/jobs/auctify/bidding_is_close_to_end_notifier_job.rb', line 7

def perform(auction_id:)
  return if auction_id.blank?
  return if Auctify.configuration.when_to_notify_bidders_before_end_of_bidding.nil?

  begin
    auction = Auctify::Sale::Auction.find(auction_id)
  rescue ActiveRecord::RecordNotFound
    return
  end

  notify_time = auction.bidding_is_close_to_end_notification_time

  return unless auction.open_for_bids?

  if notify_time <= Time.current
    auction.before_bidding_is_close_to_end
  else
    self.class.set(wait_until: notify_time)
              .perform_later(auction_id: auction.id)
  end
end