From 1ca7c02ee69223a1b8e704b8422c6bdebd389d81 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Tue, 19 Sep 2023 13:50:16 +0300 Subject: [PATCH] fixed time extend by autobider --- app/models/offer.rb | 9 +++++++++ app/services/autobider_service.rb | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) 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