Skip to content

Commit

Permalink
Ensuring the same now is used
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin.schmick committed Aug 26, 2022
1 parent 86c4094 commit ac5f515
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Jobs/DebouncedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,14 @@ protected function getMinimumMillisecondsLeft() : int
*/
$minimum = Cache::get($this->getMinimumWaitTimeKey());
$maximum = Cache::get($this->getMaximumWaitTimeKey());
$now = now();

if ($minimum && $maximum) {
return min($maximum->diffInMilliseconds(now()), $minimum->diffInMilliseconds(now()));
return min($maximum->diffInMilliseconds($now), $minimum->diffInMilliseconds($now));
}

if ($minimum) {
return $minimum->diffInMilliseconds(now());
return $minimum->diffInMilliseconds($now);
}

return 0;
Expand All @@ -207,17 +208,18 @@ protected function getMaximumMillisecondsLeft() : int
*/
$minimum = Cache::get($this->getMinimumWaitTimeKey());
$maximum = Cache::get($this->getMaximumWaitTimeKey());
$now = now();

if ($minimum && $maximum) {
return max($maximum->diffInMilliseconds(now()), $minimum->diffInMilliseconds(now()));
return max($maximum->diffInMilliseconds($now), $minimum->diffInMilliseconds($now));
}

if ($maximum) {
return $maximum->diffInMilliseconds(now());
return $maximum->diffInMilliseconds($now);
}

if ($minimum) {
return $minimum->diffInMilliseconds(now());
return $minimum->diffInMilliseconds($now);
}

return 0;
Expand Down

0 comments on commit ac5f515

Please sign in to comment.