diff --git a/src/Interface/DataProviderServiceInterface.php b/src/Interface/DataProviderServiceInterface.php index 70bc1cca..fa304bdd 100644 --- a/src/Interface/DataProviderServiceInterface.php +++ b/src/Interface/DataProviderServiceInterface.php @@ -6,6 +6,7 @@ use App\Model\Invoices\ClientData; use App\Model\Invoices\PagedResult; use App\Model\Invoices\ProjectDataCollection; +use App\Model\Invoices\WorklogDataCollection; use App\Model\Planning\PlanningData; use App\Model\SprintReport\SprintReportData; use App\Model\SprintReport\SprintReportProjects; @@ -35,5 +36,5 @@ public function getSprintReportVersions(string $projectId): SprintReportVersions public function getProjectDataCollection(): ProjectDataCollection; - public function getWorklogDataForProjectPaged(string $projectId, int $startAt = 0, $maxResults = 50): PagedResult; + public function getWorklogDataCollection(string $projectId): WorklogDataCollection; } diff --git a/src/Service/LeantimeApiService.php b/src/Service/LeantimeApiService.php index cb1d7d27..74b3c15b 100644 --- a/src/Service/LeantimeApiService.php +++ b/src/Service/LeantimeApiService.php @@ -307,10 +307,14 @@ public function getSprintReportVersions(string $projectId): SprintReportVersions return $sprintReportVersions; } - public function getWorklogDataForProjectPaged(string $projectId, $startAt = 0, $maxResults = 50): PagedResult + /** + * @throws \DateMalformedStringException + * @throws EconomicsException + * @throws ApiServiceException + */ + public function getWorklogDataCollection(string $projectId): WorklogDataCollection { $worklogDataCollection = new WorklogDataCollection(); - $worklogs = $this->getProjectWorklogs($projectId); $workersData = $this->request(self::API_PATH_JSONRPC, 'POST', 'leantime.rpc.users.getAll'); @@ -321,10 +325,10 @@ public function getWorklogDataForProjectPaged(string $projectId, $startAt = 0, $ return $carry; }, []); + // Filter out all worklogs that do not belong to the project. + // TODO: Remove filter when worklogs are filtered correctly by projectId in the API. $worklogs = array_filter($worklogs, fn ($worklog) => $worklog->projectId == $projectId); - $total = count($worklogs); - foreach ($worklogs as $worklog) { $worklogData = new WorklogData(); if (isset($worklog->ticketId)) { @@ -341,8 +345,7 @@ public function getWorklogDataForProjectPaged(string $projectId, $startAt = 0, $ } } - // Return a new PagedResult instance - return new PagedResult($worklogDataCollection->worklogData->toArray(), $startAt, $maxResults, $total); + return $worklogDataCollection; } /**