-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergei Tsoganov
authored and
Sergei Tsoganov
committed
Oct 3, 2023
1 parent
30c46c6
commit 73d86ef
Showing
3 changed files
with
4 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,17 @@ | ||
class WishlistJob < ApplicationJob | ||
LONG_WAIT_TIME = 2.hours | ||
SHORT_WAIT_TIME = 1.minute | ||
|
||
def perform(domain_name, auction_remote_id) | ||
wishlist_items = WishlistItem.where(domain_name: domain_name) | ||
auction = Auction.where('ends_at > ?', Time.zone.now) | ||
auction = Auction.where.not(starts_at: nil).where('ends_at > ?', Time.zone.now) | ||
.find_by(remote_id: auction_remote_id) | ||
return unless auction | ||
|
||
wishlist_items.each do |item| | ||
next if item.processed? | ||
|
||
WishlistMailer.auction_notification_mail(item, auction).deliver_later(wait_until: auction.starts_at) | ||
WishlistMailer.auction_notification_mail(item, auction) | ||
.deliver_later(wait_until: auction.starts_at) | ||
WishlistAutoOfferJob.set(wait_until: auction.starts_at).perform_later(auction.id) | ||
item.update(processed: true) | ||
end | ||
end | ||
|
||
def self.wait_time | ||
Rails.env.production? ? LONG_WAIT_TIME : SHORT_WAIT_TIME | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters