Skip to content

Commit

Permalink
Merge pull request #59 from WeareJH/flag-manager
Browse files Browse the repository at this point in the history
Fix for pagination calculation error
  • Loading branch information
bartoszkubicki authored Oct 28, 2022
2 parents b1bc6a1 + 9eb3ac3 commit b9a4233
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Source/Webapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
?FilterDecoratorInterface $dataRequestFilterDecorator = null
) {
$this->idField = $idField;
$this->sourceId = $sourceId;
$this->sourceId = sprintf('%s_%s', $sourceId, date('Y_m_d H:i:s'));
$this->pagingManager = $pagingManager;
$this->countRequestFactory = $countRequestFactory;
$this->countResponseHandler = $countResponseHandler;
Expand All @@ -71,7 +71,7 @@ public function count(): int
public function traverse(callable $onSuccess, callable $onError, Report $report): void
{
try {
$totalNumberOfItems = $this->count();
$totalNumberOfItems = $this->countAll();
$pagesAmount = ceil($totalNumberOfItems / $this->dataRequestPageSize);

for (
Expand All @@ -98,6 +98,12 @@ public function getSourceId(): string
return $this->sourceId;
}

private function countAll(): int
{
$response = $this->httpClient->sendRequest($this->countRequestFactory->create());
return $this->countResponseHandler->handle($response);
}

private function getPageToStartFrom(): int
{
return $this->pagingManager->getValue() === null ? 1 : (int) $this->pagingManager->getValue();
Expand Down

0 comments on commit b9a4233

Please sign in to comment.