diff --git a/app/models/offer.rb b/app/models/offer.rb index 15c831943..8d848363d 100644 --- a/app/models/offer.rb +++ b/app/models/offer.rb @@ -22,6 +22,15 @@ class Offer < ApplicationRecord attr_accessor :skip_autobider, :skip_if_wishlist_case, :skip_validation + after_create :update_auction_ends_at + after_update :update_auction_ends_at + + def update_auction_ends_at + return if auction.platform == 'blind' || auction.platform.nil? + + auction.update_ends_at(self) + end + def broadcast_replace_auction return if auction.platform == 'blind' || auction.platform.nil? diff --git a/app/services/autobider_service.rb b/app/services/autobider_service.rb index 66a5a3545..6c0f3bc28 100644 --- a/app/services/autobider_service.rb +++ b/app/services/autobider_service.rb @@ -12,8 +12,7 @@ def self.autobid(auction) autobiders = bider.auctual_autobiders filtered_autobiders = bider.filter_autobider_for_banned_users(autobiders: autobiders) - filtered_autobiders = bider.reject_autobiders_which_bid_equal_to_auction_current_price(filtered_autobiders: filtered_autobiders, - auction: auction) + filtered_autobiders = bider.reject_autobiders_which_bid_equal_to_auction_current_price(filtered_autobiders: filtered_autobiders, auction: auction) return if filtered_autobiders.empty? @@ -99,6 +98,10 @@ def outbid_if_exists(autobider:, auction:) auction.update_minimum_bid_step(auction.min_bids_step) end + auction.reload + offer = auction.currently_winning_offer + auction.update_ends_at(offer) + return end