Skip to content

Commit

Permalink
Merge pull request #32 from itk-dev/feature/sprint-planning
Browse files Browse the repository at this point in the history
LEAT-58: Sprint report
  • Loading branch information
jeppekroghitk authored Jan 4, 2024
2 parents febf1d6 + e2e816c commit 34f9c88
Show file tree
Hide file tree
Showing 12 changed files with 550 additions and 148 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ See [keep a changelog](https://keepachangelog.com/en/1.0.0/) for information abo

* Updated api source to use Leantime
* Modified getPlanningData to work with Leantime data
* Modified getSprintReportData to work with Leantime data
* Added Leantime specific header to api service.

## 1.0.4
Expand Down
21 changes: 11 additions & 10 deletions src/Controller/SprintReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Form\SprintReportType;
use App\Model\SprintReport\SprintReportFormData;
use App\Service\ApiServiceInterface;
use App\Service\ProjectTrackerInterface;
use App\Service\SprintReportService;
use Mpdf\Mpdf;
use Mpdf\MpdfException;
Expand All @@ -20,7 +20,7 @@
class SprintReportController extends AbstractController
{
public function __construct(
private readonly ApiServiceInterface $apiService,
private readonly ProjectTrackerInterface $projectTracker,
private readonly SprintReportService $sprintReportService,
) {
}
Expand All @@ -38,12 +38,12 @@ public function index(Request $request): Response
'csrf_protection' => false,
]);

$projects = $this->apiService->getAllProjects();
$projectCollection = $this->projectTracker->getSprintReportProjects();

$projectChoices = [];

foreach ($projects as $project) {
$projectChoices[$project->name] = $project->key;
foreach ($projectCollection->projects as $project) {
$projectChoices[$project->name] = $project->id;
}

// Override projectId with element with choices.
Expand All @@ -66,11 +66,12 @@ public function index(Request $request): Response
}

if (!empty($requestData['projectId'])) {
$project = $this->apiService->getProject($requestData['projectId']);
$project = $this->projectTracker->getSprintReportProject($requestData['projectId']);
$versionCollection = $this->projectTracker->getSprintReportProjectVersions($requestData['projectId']);

$versionChoices = [];
foreach ($project->versions as $version) {
$versionChoices[$version->name] = $version->id;
foreach ($versionCollection->versions as $version) {
$versionChoices[$version->headline] = $version->id;
}

// Override versionId with element with choices.
Expand All @@ -96,7 +97,7 @@ public function index(Request $request): Response
$versionId = $form->get('versionId')->getData();

if (!empty($projectId) && !empty($versionId)) {
$reportData = $this->apiService->getSprintReportData($projectId, $versionId);
$reportData = $this->projectTracker->getSprintReportData($projectId, $versionId);

$budget = $this->sprintReportService->getBudget($projectId, $versionId);
}
Expand Down Expand Up @@ -138,7 +139,7 @@ public function generatePdf(Request $request)
$projectId = (string) $request->query->get('projectId');
$versionId = (string) $request->query->get('versionId');

$reportData = $this->apiService->getSprintReportData($projectId, $versionId);
$reportData = $this->projectTracker->getSprintReportData($projectId, $versionId);

$html = $this->renderView('sprint_report/pdf.html.twig', [
'report' => $reportData,
Expand Down
15 changes: 15 additions & 0 deletions src/Model/SprintReport/SprintReportProject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Model\SprintReport;

class SprintReportProject
{
public string $id;
public string $name;

public function __construct(string $id, string $name)
{
$this->id = $id;
$this->name = $name;
}
}
16 changes: 16 additions & 0 deletions src/Model/SprintReport/SprintReportProjects.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Model\SprintReport;

use Doctrine\Common\Collections\ArrayCollection;

class SprintReportProjects
{
/** @var ArrayCollection<string, SprintReportProject> */
public ArrayCollection $projects;

public function __construct()
{
$this->projects = new ArrayCollection();
}
}
15 changes: 15 additions & 0 deletions src/Model/SprintReport/SprintReportVersion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Model\SprintReport;

class SprintReportVersion
{
public string $id;
public string $headline;

public function __construct(string $id, string $headline)
{
$this->id = $id;
$this->headline = $headline;
}
}
16 changes: 16 additions & 0 deletions src/Model/SprintReport/SprintReportVersions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Model\SprintReport;

use Doctrine\Common\Collections\ArrayCollection;

class SprintReportVersions
{
/** @var ArrayCollection<string, SprintReportVersion> */
public ArrayCollection $versions;

public function __construct()
{
$this->versions = new ArrayCollection();
}
}
137 changes: 134 additions & 3 deletions src/Service/ApiServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Service;

use App\Exception\ApiServiceException;
use App\Model\Invoices\AccountData;
use App\Model\Invoices\ClientData;
use App\Model\Invoices\IssueData;
Expand All @@ -16,67 +17,197 @@ public function getEndpoints(): array;

public function getProjectTrackerIdentifier(): string;

/**
* Get all accounts.
*
* @throws ApiServiceException
*/
public function getAllAccounts(): mixed;

/**
* Get all accounts.
*
* @throws ApiServiceException
*/
public function getAllCustomers(): mixed;

/**
* @throws ApiServiceException
*/
public function getAllProjectCategories(): mixed;

/**
* Get all projects, including archived.
*
* @throws ApiServiceException
*/
public function getAllProjects(): mixed;

/**
* Get current user permissions.
*
* @throws ApiServiceException
*/
public function getCurrentUserPermissions(): mixed;

/**
* Get list of allowed permissions for current user.
*
* @throws ApiServiceException
*/
public function getPermissionsList(): array;

/**
* Get project.
*
* @param $key
* A project key or id
*
* @throws ApiServiceException
*/
public function getProject($key): mixed;

/**
* Create a jira project.
*
* See https://docs.atlassian.com/software/jira/docs/api/REST/9.3.0/#api/2/project-createProject
*
* @return ?string
*
* @throws ApiServiceException
*/
public function createProject(array $data): ?string;

/**
* Create a jira customer.
*
* @throws ApiServiceException
*/
public function createTimeTrackerCustomer(string $name, string $key): mixed;

/**
* Get tempo account base on key.
*
* @throws ApiServiceException
*/
public function getTimeTrackerAccount(string $key): mixed;

/**
* Create a Jira account.
*
* @throws ApiServiceException
*/
public function createTimeTrackerAccount(string $name, string $key, string $customerKey, string $contactUsername): mixed;

/**
* Create a project link to account.
*
* @param mixed $project
* The project that was created on form submit
* @param mixed $account
* The account that was created on form submit
*
* @throws ApiServiceException
*/
public function addProjectToTimeTrackerAccount(mixed $project, mixed $account): void;

/**
* Create project board.
*
* @throws ApiServiceException
*/
public function createProjectBoard(string $type, mixed $project): void;

/**
* Get account based on id.
*
* @throws ApiServiceException
*/
public function getAccount(string $accountId): mixed;

/**
* @throws ApiServiceException
*/
public function getRateTableByAccount(string $accountId): mixed;

/** @return array<string> */
/**
* @throws ApiServiceException
*/
public function getAccountIdsByProject(string $projectId): array;

/**
* Get all boards.
*
* @throws ApiServiceException
*/
public function getAllBoards(): mixed;

/**
* Get all sprints for a given board.
*
* @param string $boardId board id
* @param string $state sprint state. Defaults to future,active sprints.
*
* @throws ApiServiceException
*/
public function getAllSprints(string $boardId): array;

/**
* Get all issues for given board and sprint.
*
* @param string $boardId id of the jira board to extract issues from
* @param string $sprintId id of the sprint to extract issues for
*
* @return array array of issues
*
* @throws ApiServiceException
*/
public function getIssuesInSprint(string $boardId, string $sprintId): array;

/**
* Create data for planning page.
*
* @throws ApiServiceException
* @throws \Exception
*/
public function getPlanningData(): PlanningData;

/**
* @throws ApiServiceException
* @throws \Exception
*/
public function getSprintReportData(string $projectId, string $versionId): SprintReportData;

/**
* @return array<ClientData>
*
* @throws ApiServiceException
*/
public function getClientDataForProject(string $projectId): array;

/**
* @return array<ProjectData>
*
* @throws ApiServiceException
*/
public function getAllProjectData(): array;

/** @return array<WorklogData> */
/** @return array<WorklogData>
* @throws ApiServiceException
* @throws \Exception
*/
public function getWorklogDataForProject(string $projectId): array;

/** @return array<IssueData> */
/** @return array<IssueData>
* @throws ApiServiceException
* @throws \Exception
*/
public function getIssuesDataForProject(string $projectId): array;

/**
* @return array<AccountData>
*
* @throws ApiServiceException
*/
public function getAllAccountData(): array;
}
Loading

0 comments on commit 34f9c88

Please sign in to comment.