Skip to content

Commit

Permalink
Undid changes to api service
Browse files Browse the repository at this point in the history
  • Loading branch information
jeppekroghitk committed Jan 2, 2025
1 parent d2744af commit 8a75b38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Interface/DataProviderServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
15 changes: 9 additions & 6 deletions src/Service/LeantimeApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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)) {
Expand All @@ -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;
}

/**
Expand Down

0 comments on commit 8a75b38

Please sign in to comment.