Skip to content

Commit

Permalink
Calculate seconds and initialize interval with it
Browse files Browse the repository at this point in the history
  • Loading branch information
codeliner committed Apr 30, 2018
1 parent b49ef28 commit 5e74bde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/Projection/PdoEventStoreProjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -955,10 +955,12 @@ private function shouldUpdateLock(DateTimeImmutable $now): bool
return true;
}

$intervalSeconds = floor($this->updateLockThreshold / 1000);

//Create a 0 interval
$updateLockThreshold = new \DateInterval('PT0S');
$updateLockThreshold = new \DateInterval("PT{$intervalSeconds}S");
//and manually add split seconds
$updateLockThreshold->f = $this->updateLockThreshold / 1000;
$updateLockThreshold->f = ($this->updateLockThreshold % 1000) / 1000;

$threshold = $this->lastLockUpdate->add($updateLockThreshold);

Expand Down
6 changes: 4 additions & 2 deletions src/Projection/PdoEventStoreReadModelProjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -902,10 +902,12 @@ private function shouldUpdateLock(DateTimeImmutable $now): bool
return true;
}

$intervalSeconds = floor($this->updateLockThreshold / 1000);

//Create a 0 interval
$updateLockThreshold = new \DateInterval('PT0S');
$updateLockThreshold = new \DateInterval("PT{$intervalSeconds}S");
//and manually add split seconds
$updateLockThreshold->f = $this->updateLockThreshold / 1000;
$updateLockThreshold->f = ($this->updateLockThreshold % 1000) / 1000;

$threshold = $this->lastLockUpdate->add($updateLockThreshold);

Expand Down

0 comments on commit 5e74bde

Please sign in to comment.