From dca496f3b742ceb6fb44873796473feea19b41b1 Mon Sep 17 00:00:00 2001 From: jaspercroome <128058464+jaspercroome@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:55:37 -0700 Subject: [PATCH] na - static values for threshold (#920) * static values for threshold * update eval logic --- .../goodbids/src/classes/Auctions/Auction.php | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/client-mu-plugins/goodbids/src/classes/Auctions/Auction.php b/client-mu-plugins/goodbids/src/classes/Auctions/Auction.php index ebf1be81..8e8db07a 100644 --- a/client-mu-plugins/goodbids/src/classes/Auctions/Auction.php +++ b/client-mu-plugins/goodbids/src/classes/Auctions/Auction.php @@ -533,14 +533,19 @@ public function is_ending_soon(): bool { return false; } - $extension = $this->get_bid_extension(); + // commenting out extension logic for now + // TODO add a variable in the UI for 'ending soon notification threshold' + // $extension = $this->get_bid_extension(); - if ( ! $extension ) { - return false; - } + $static_threshold_min = 60*60; // 60 minutes + $static_threshold_max = 60*115; // 115 minutes + + // if ( ! $extension ) { + // return false; + // } - // Set threshold to be 1/3 of bid extension window. - $threshold = intval( round( $extension * .3 ) ); + // Set threshold to be static + // $threshold = intval( round( $extension * .3 ) ); try { $end = new DateTimeImmutable( $end_date_time, wp_timezone() ); @@ -555,8 +560,13 @@ public function is_ending_soon(): bool { return false; } - // If the Auction ends in less than the extension threshold, it is ending soon. - return $diff < $threshold; + // if the diff is less than the max for the threshold + // and the diff is more than the min for the threshold + // (i.e., if it falls within the threshold), + // then it's ending soon. + $ending_soon = $static_threshold_max > $diff && $static_threshold_min < $diff; + + return $ending_soon; } /**