From 09b2fd2c5fd48582d03da58b121d5551324736f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Danyi?= Date: Thu, 24 Aug 2017 17:14:05 +0200 Subject: [PATCH] * worklog time spent added --- config/autoload/local.php.dist | 1 + src/App/Entity/KanbanEntry.php | 24 ++++++++++++++++++++++++ src/App/Service/JiraCollectorService.php | 6 ++++++ 3 files changed, 31 insertions(+) diff --git a/config/autoload/local.php.dist b/config/autoload/local.php.dist index 42432b6..7c4813e 100644 --- a/config/autoload/local.php.dist +++ b/config/autoload/local.php.dist @@ -21,6 +21,7 @@ return [ 'labels', 'assignee', 'status', + 'worklog', 'customfield_10010', 'customfield_11226', 'customfield_10840', diff --git a/src/App/Entity/KanbanEntry.php b/src/App/Entity/KanbanEntry.php index 06a7602..8a4e27f 100644 --- a/src/App/Entity/KanbanEntry.php +++ b/src/App/Entity/KanbanEntry.php @@ -112,6 +112,11 @@ class KanbanEntry implements \JsonSerializable */ private $answerCode; + /** + * @var int + */ + private $worklog = 0; + /** * KanbanEntry constructor. */ @@ -486,6 +491,24 @@ class KanbanEntry implements \JsonSerializable return $this; } + /** + * @return int + */ + public function getWorklog(): int + { + return $this->worklog; + } + + /** + * @param int $worklog + * @return KanbanEntry + */ + public function setWorklog(int $worklog): KanbanEntry + { + $this->worklog = $worklog; + return $this; + } + /** * @return array */ @@ -511,6 +534,7 @@ class KanbanEntry implements \JsonSerializable 'mhwebExternal' => $this->getMhwebExternal(), 'team' => $this->getTeam(), 'answerCode' => $this->getAnswerCode(), + 'worklog' => $this->getWorklog(), ]; } } diff --git a/src/App/Service/JiraCollectorService.php b/src/App/Service/JiraCollectorService.php index c75a875..790f8ff 100644 --- a/src/App/Service/JiraCollectorService.php +++ b/src/App/Service/JiraCollectorService.php @@ -92,6 +92,12 @@ class JiraCollectorService ->setLabels($jsonIssue['fields']['labels']) ; + $timeSpent = 0; + array_map(function($worklog) use (&$timeSpent){ + $timeSpent += $worklog['timeSpentSeconds']; + }, $jsonIssue['fields']['worklog']['worklogs']); + $kanbanEntry->setWorklog(ceil($timeSpent/3600)); + // externalId : customfield_10010 if(isset($jsonIssue['fields']['customfield_10010'])) { $kanbanEntry->setPrio(intval($jsonIssue['fields']['customfield_10010']));