From 728ef630677c527b00173440e56bd5ad8e51f23e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Danyi?= Date: Fri, 25 Aug 2017 11:07:51 +0200 Subject: [PATCH] * daysBlocked feature added * blocked worklog entries are not counted towards spike spent time --- src/App/Entity/KanbanEntry.php | 24 ++++++++++++++++++++++++ src/App/Service/JiraCollectorService.php | 18 ++++++++++++++---- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/App/Entity/KanbanEntry.php b/src/App/Entity/KanbanEntry.php index 8a4e27f..e617a9d 100644 --- a/src/App/Entity/KanbanEntry.php +++ b/src/App/Entity/KanbanEntry.php @@ -117,6 +117,11 @@ class KanbanEntry implements \JsonSerializable */ private $worklog = 0; + /** + * @var int + */ + private $daysBlocked = 0; + /** * KanbanEntry constructor. */ @@ -509,6 +514,24 @@ class KanbanEntry implements \JsonSerializable return $this; } + /** + * @return int + */ + public function getDaysBlocked(): int + { + return $this->daysBlocked; + } + + /** + * @param int $daysBlocked + * @return KanbanEntry + */ + public function setDaysBlocked(int $daysBlocked): KanbanEntry + { + $this->daysBlocked = $daysBlocked; + return $this; + } + /** * @return array */ @@ -535,6 +558,7 @@ class KanbanEntry implements \JsonSerializable 'team' => $this->getTeam(), 'answerCode' => $this->getAnswerCode(), 'worklog' => $this->getWorklog(), + 'daysBlocked' => $this->getDaysBlocked(), ]; } } diff --git a/src/App/Service/JiraCollectorService.php b/src/App/Service/JiraCollectorService.php index 790f8ff..f7c35c4 100644 --- a/src/App/Service/JiraCollectorService.php +++ b/src/App/Service/JiraCollectorService.php @@ -92,11 +92,21 @@ class JiraCollectorService ->setLabels($jsonIssue['fields']['labels']) ; - $timeSpent = 0; - array_map(function($worklog) use (&$timeSpent){ - $timeSpent += $worklog['timeSpentSeconds']; + $spikeTimeSpent = 0; + array_map(function($worklog) use (&$spikeTimeSpent){ + $spikeTimeSpent += strtoupper($worklog['comment']) == 'BLOCKED' + ? 0 + : $worklog['timeSpentSeconds']; }, $jsonIssue['fields']['worklog']['worklogs']); - $kanbanEntry->setWorklog(ceil($timeSpent/3600)); + $kanbanEntry->setWorklog(ceil($spikeTimeSpent/3600)); + + $secondsBlocked = 0; + array_map(function($worklog) use (&$secondsBlocked){ + $secondsBlocked += strtoupper($worklog['comment']) == 'BLOCKED' + ? $worklog['timeSpentSeconds'] + : 0; + }, $jsonIssue['fields']['worklog']['worklogs']); + $kanbanEntry->setDaysBlocked(ceil($secondsBlocked/86400)); // externalId : customfield_10010 if(isset($jsonIssue['fields']['customfield_10010'])) {