Skip to content

Commit

Permalink
na - static values for threshold (#920)
Browse files Browse the repository at this point in the history
* static values for threshold

* update eval logic
  • Loading branch information
jaspercroome authored Apr 19, 2024
1 parent 8dd3de4 commit dca496f
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions client-mu-plugins/goodbids/src/classes/Auctions/Auction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand All @@ -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;
}

/**
Expand Down

0 comments on commit dca496f

Please sign in to comment.