diff --git a/config/autoload/local.php.dist b/config/autoload/local.php.dist index 7c4813e..39379d9 100644 --- a/config/autoload/local.php.dist +++ b/config/autoload/local.php.dist @@ -22,6 +22,7 @@ return [ 'assignee', 'status', 'worklog', + 'updated', 'customfield_10010', 'customfield_11226', 'customfield_10840', diff --git a/src/App/Entity/KanbanBoard.php b/src/App/Entity/KanbanBoard.php index e933440..47a96a4 100644 --- a/src/App/Entity/KanbanBoard.php +++ b/src/App/Entity/KanbanBoard.php @@ -228,6 +228,18 @@ class KanbanBoard implements \JsonSerializable return $toSort; } + /** + * @param KanbanEntry[] $toSort + * @return KanbanEntry[] + */ + private function updatedAtReverseSort(array $toSort): array + { + usort($toSort, function(KanbanEntry $a, KanbanEntry $b){ + return $b->getUpdatedAt() <=> $a->getUpdatedAt(); + }); + return $toSort; + } + /** * @return array */ @@ -237,7 +249,7 @@ class KanbanBoard implements \JsonSerializable 'inbox' => $this->prioSort($this->inbox->getValues()), 'inProgress' => $this->prioSort($this->inProgress->getValues()), 'verification' => $this->prioSort($this->verification->getValues()), - 'done' => $this->prioSort($this->done->getValues()), + 'done' => $this->updatedAtReverseSort($this->done->getValues()), ]; } } diff --git a/src/App/Entity/KanbanEntry.php b/src/App/Entity/KanbanEntry.php index e617a9d..c900d2f 100644 --- a/src/App/Entity/KanbanEntry.php +++ b/src/App/Entity/KanbanEntry.php @@ -122,6 +122,11 @@ class KanbanEntry implements \JsonSerializable */ private $daysBlocked = 0; + /** + * @var \DateTime + */ + private $updatedAt; + /** * KanbanEntry constructor. */ @@ -532,6 +537,24 @@ class KanbanEntry implements \JsonSerializable return $this; } + /** + * @return \DateTime + */ + public function getUpdatedAt(): ?\DateTime + { + return $this->updatedAt; + } + + /** + * @param \DateTime $updatedAt + * @return KanbanEntry + */ + public function setUpdatedAt(?\DateTime $updatedAt): KanbanEntry + { + $this->updatedAt = $updatedAt; + return $this; + } + /** * @return array */ @@ -559,6 +582,7 @@ class KanbanEntry implements \JsonSerializable 'answerCode' => $this->getAnswerCode(), 'worklog' => $this->getWorklog(), 'daysBlocked' => $this->getDaysBlocked(), + 'updatedAt' => $this->getUpdatedAt(), ]; } } diff --git a/src/App/Service/JiraCollectorService.php b/src/App/Service/JiraCollectorService.php index 8e10f1d..621f15f 100644 --- a/src/App/Service/JiraCollectorService.php +++ b/src/App/Service/JiraCollectorService.php @@ -182,6 +182,8 @@ class JiraCollectorService unset($jiraIssueType); } + $kanbanEntry->setUpdatedAt(new \DateTime($jsonIssue['fields']['updated'])); + switch($jiraStatus->getName()) { case "Backlog": $kanbanBoard->addInbox($kanbanEntry);