* multiple team kanban board implementation added
* active flag is now working as intended * iframe slide type added * team-slide connection is now many-to-many
This commit is contained in:
parent
c096510b3d
commit
cfc388aa77
27
config/autoload/local.php.dist
Normal file → Executable file
27
config/autoload/local.php.dist
Normal file → Executable file
@ -9,4 +9,31 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'app.config' => [
|
||||
'jira.user' => '',
|
||||
'jira.password' => '',
|
||||
|
||||
'url.jiraAvatar' => 'https://cc-jira.rnd.ki.sw.ericsson.se/secure/useravatar?ownerId=%s',
|
||||
'url.jiraIssue' => 'https://cc-jira.rnd.ki.sw.ericsson.se/rest/api/2/issue/%s?fields=%s',
|
||||
'url.jiraKanbanBoard' => 'https://cc-jira.rnd.ki.sw.ericsson.se/rest/api/2/search?jql=filter=%s&maxResults=1000&fields=%s',
|
||||
'jira.filterFields' => [
|
||||
'summary',
|
||||
'priority',
|
||||
'issuetype',
|
||||
'labels',
|
||||
'assignee',
|
||||
'status',
|
||||
'worklog',
|
||||
'updated',
|
||||
'fixVersions',
|
||||
|
||||
'customfield_11711', // epic link field
|
||||
'customfield_11712', // epic name
|
||||
'customfield_13662', // additional jiraAssignees
|
||||
],
|
||||
|
||||
'http.proxy.enabled' => false,
|
||||
'http.proxy.type' => CURLPROXY_SOCKS5,
|
||||
'http.proxy.url' => "localhost:1080",
|
||||
],
|
||||
];
|
||||
|
||||
3
config/routes.php
Normal file → Executable file
3
config/routes.php
Normal file → Executable file
@ -46,6 +46,5 @@ return function (Application $app, MiddlewareFactory $factory, ContainerInterfac
|
||||
$app->route('/api/slide[/{id:\d+}]', App\Handler\SlideHandler::class)->setName('api.slide');
|
||||
|
||||
$app->get('/avatars/{signum}', App\Handler\AvatarHandler::class,'avatar.image');
|
||||
$app->get('/api/kanban[/{filterId:\d+}]', App\Handler\KanbanHandler::class,'api.team.kanban');
|
||||
|
||||
$app->get('/api/kanban/{teamId:\d+}', App\Handler\KanbanHandler::class,'api.team.kanban');
|
||||
};
|
||||
|
||||
47
src/App/Entity/KanbanEntry.php
Normal file → Executable file
47
src/App/Entity/KanbanEntry.php
Normal file → Executable file
@ -29,6 +29,12 @@ class KanbanEntry implements \JsonSerializable
|
||||
*/
|
||||
private $issueType;
|
||||
|
||||
/**
|
||||
* JIRA: link to parent is in a custom field, parent has the epic name as a custom field
|
||||
* @var string
|
||||
*/
|
||||
private $epicName;
|
||||
|
||||
/**
|
||||
* @var JiraStatus
|
||||
*/
|
||||
@ -40,7 +46,6 @@ class KanbanEntry implements \JsonSerializable
|
||||
private $assignee;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10401
|
||||
* @var JiraAssignee[]
|
||||
*/
|
||||
private $additionalAssignees;
|
||||
@ -66,68 +71,57 @@ class KanbanEntry implements \JsonSerializable
|
||||
private $fixVersions;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_11226
|
||||
* @var int
|
||||
*/
|
||||
private $prio;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_11225
|
||||
* @var string[]|ArrayCollection
|
||||
*/
|
||||
private $functionalAreas;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10010
|
||||
* @var string
|
||||
*/
|
||||
private $externalId;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10850
|
||||
* @var string
|
||||
*/
|
||||
private $externalLink;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10840
|
||||
* @var string
|
||||
*/
|
||||
private $project;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10844
|
||||
* @var string
|
||||
*/
|
||||
private $mhwebStatus;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10847
|
||||
* @var bool
|
||||
*/
|
||||
private $mhwebHot;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10849
|
||||
* @var bool
|
||||
*/
|
||||
private $mhwebExternal = false;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_10904
|
||||
* @var string
|
||||
*/
|
||||
private $team;
|
||||
|
||||
/**
|
||||
* JIRA: customfield_11692
|
||||
* @var string
|
||||
*/
|
||||
private $answerCode;
|
||||
|
||||
/**
|
||||
* ITS OVER 9000!
|
||||
* JIRA: customfield_12500
|
||||
* @var int
|
||||
*/
|
||||
private $taurusPrio = 9001;
|
||||
@ -228,6 +222,24 @@ class KanbanEntry implements \JsonSerializable
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEpicName(): ?string
|
||||
{
|
||||
return $this->epicName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $epicName
|
||||
* @return KanbanEntry
|
||||
*/
|
||||
public function setEpicName(?string $epicName): KanbanEntry
|
||||
{
|
||||
$this->epicName = $epicName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return JiraStatus
|
||||
*/
|
||||
@ -664,22 +676,13 @@ class KanbanEntry implements \JsonSerializable
|
||||
'key' => $this->getKey(),
|
||||
'summary' => $this->getSummary(),
|
||||
'issueType' => $this->getIssueType(),
|
||||
'epicName' => $this->getEpicName(),
|
||||
'status' => $this->getStatus(),
|
||||
'assignee' => $this->getAssignee(),
|
||||
'additionalAssignees' => $this->getAdditionalAssignees()->getValues(),
|
||||
'issuePriority' => $this->getIssuePriority(),
|
||||
'issuePriorityIcon' => $this->getIssuePriorityIcon(),
|
||||
'labels' => $this->getLabels(),
|
||||
'prio' => $this->getPrio(),
|
||||
'functionalArea' => $this->getFunctionalAreas()->getValues(),
|
||||
'externalId' => $this->getExternalId(),
|
||||
'externalLink' => $this->getExternalLink(),
|
||||
'project' => $this->getProject(),
|
||||
'mhwebStatus' => $this->getMhwebStatus(),
|
||||
'mhwebHot' => $this->getMhwebHot(),
|
||||
'mhwebExternal' => $this->getMhwebExternal(),
|
||||
'team' => $this->getTeam(),
|
||||
'answerCode' => $this->getAnswerCode(),
|
||||
'taurusPrio' => $this->getTaurusPrio(),
|
||||
'worklog' => $this->getWorklog(),
|
||||
'daysBlocked' => $this->getDaysBlocked(),
|
||||
|
||||
153
src/App/Entity/Slide.php
Normal file → Executable file
153
src/App/Entity/Slide.php
Normal file → Executable file
@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Gedmo\Mapping\Annotation as Gedmo;
|
||||
use JsonSerializable;
|
||||
@ -15,6 +17,12 @@ use JsonSerializable;
|
||||
*/
|
||||
class Slide implements JsonSerializable
|
||||
{
|
||||
const TYPE_MARKDOWN = 'markdown';
|
||||
const TYPE_IFRAME = 'iframe';
|
||||
|
||||
const VISIBILITY_PUBLIC = 'public';
|
||||
const VISIBILITY_TEAM = 'team';
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
@ -30,18 +38,29 @@ class Slide implements JsonSerializable
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Team", inversedBy="slides")
|
||||
* @ORM\JoinColumn(name="team_id", referencedColumnName="id")
|
||||
* @var Team
|
||||
* @ORM\Column(name="type", type="string", length=50, options={"default" = "markdown"})
|
||||
* @var string
|
||||
*/
|
||||
private $team;
|
||||
private $type = self::TYPE_MARKDOWN;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="slide_data", type="text", nullable=false)
|
||||
* @ORM\Column(name="visibility", type="string", length=50, options={"default" = "public"})
|
||||
* @var string
|
||||
*/
|
||||
private $visibility = self::VISIBILITY_PUBLIC;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="slide_data", type="text", nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $slideData;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="slide_url", type="text", nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $slideUrl;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="is_visible", type="boolean")
|
||||
* @var bool
|
||||
@ -69,6 +88,17 @@ class Slide implements JsonSerializable
|
||||
*/
|
||||
private $position;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Team", inversedBy="slides", cascade={"persist", "remove"})
|
||||
* @var Team[]|ArrayCollection
|
||||
*/
|
||||
private $teams;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->teams = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@ -106,20 +136,38 @@ class Slide implements JsonSerializable
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Team
|
||||
* @return string
|
||||
*/
|
||||
public function getTeam(): ?Team
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->team;
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Team $team
|
||||
* @param string $type
|
||||
* @return Slide
|
||||
*/
|
||||
public function setTeam(?Team $team): Slide
|
||||
public function setType(?string $type): Slide
|
||||
{
|
||||
$this->team = $team;
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVisibility(): ?string
|
||||
{
|
||||
return $this->visibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $visibility
|
||||
* @return Slide
|
||||
*/
|
||||
public function setVisibility(?string $visibility): Slide
|
||||
{
|
||||
$this->visibility = $visibility;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -135,12 +183,30 @@ class Slide implements JsonSerializable
|
||||
* @param string $slideData
|
||||
* @return Slide
|
||||
*/
|
||||
public function setSlideData(string $slideData): Slide
|
||||
public function setSlideData(?string $slideData): Slide
|
||||
{
|
||||
$this->slideData = $slideData;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSlideUrl(): ?string
|
||||
{
|
||||
return $this->slideUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $slideUrl
|
||||
* @return Slide
|
||||
*/
|
||||
public function setSlideUrl(?string $slideUrl): Slide
|
||||
{
|
||||
$this->slideUrl = $slideUrl;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@ -213,6 +279,64 @@ class Slide implements JsonSerializable
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Team $team
|
||||
* @return Slide
|
||||
*/
|
||||
public function addTeam(Team $team): Slide
|
||||
{
|
||||
if (!$this->teams->contains($team)) {
|
||||
$this->teams->add($team);
|
||||
}
|
||||
//$team->addSlide($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Team[] $teams
|
||||
* @return Slide
|
||||
*/
|
||||
public function addTeams($teams): Slide
|
||||
{
|
||||
foreach ($teams as $team) {
|
||||
$this->addTeam($team);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Team[]|Collection
|
||||
*/
|
||||
public function getTeams(): Collection
|
||||
{
|
||||
return $this->teams;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Team $team
|
||||
* @return Slide
|
||||
*/
|
||||
public function removeTeam(Team $team): Slide
|
||||
{
|
||||
if ($this->teams->contains($team)) {
|
||||
$this->teams->removeElement($team);
|
||||
}
|
||||
//$team->removeSlide($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Team[] $teams
|
||||
* @return Slide
|
||||
*/
|
||||
public function removeTeams($teams): Slide
|
||||
{
|
||||
foreach ($teams as $team) {
|
||||
$this->removeTeam($team);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@ -221,8 +345,11 @@ class Slide implements JsonSerializable
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'title' => $this->getTitle(),
|
||||
'team' => $this->getTeam(),
|
||||
'type' => $this->getType(),
|
||||
'visibility' => $this->getVisibility(),
|
||||
'teams' => $this->getTeams()->getValues(),
|
||||
'slideData' => $this->getSlideData(),
|
||||
'slideUrl' => $this->getSlideUrl(),
|
||||
'isVisible' => $this->isVisible(),
|
||||
'createdAt' => $this->getCreatedAt()
|
||||
? $this->getCreatedAt()->format("Y-m-d H:i:s")
|
||||
|
||||
18
src/App/Entity/Team.php
Normal file → Executable file
18
src/App/Entity/Team.php
Normal file → Executable file
@ -37,11 +37,15 @@ class Team implements JsonSerializable
|
||||
private $members;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Slide",
|
||||
* mappedBy="team",
|
||||
* cascade={"persist", "remove"},
|
||||
* orphanRemoval=true
|
||||
* @ORM\ManyToMany(targetEntity="Slide", mappedBy="teams", cascade={"persist", "remove"})
|
||||
* @ORM\JoinTable(
|
||||
* name="team_slides",
|
||||
* joinColumns={
|
||||
* @ORM\JoinColumn(name="team_id", referencedColumnName="id")
|
||||
* },
|
||||
* inverseJoinColumns={
|
||||
* @ORM\JoinColumn(name="slide_id", referencedColumnName="id")
|
||||
* }
|
||||
* )
|
||||
* @var Slide[]|Collection
|
||||
*/
|
||||
@ -166,11 +170,12 @@ class Team implements JsonSerializable
|
||||
* @param Slide $slide
|
||||
* @return Team
|
||||
*/
|
||||
public function addSlides(Slide $slide): Team
|
||||
public function addSlide(Slide $slide): Team
|
||||
{
|
||||
if (!$this->slides->contains($slide)) {
|
||||
$this->slides->removeElement($slide);
|
||||
}
|
||||
//$slide->addTeam($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -191,6 +196,7 @@ class Team implements JsonSerializable
|
||||
if ($this->slides->contains($slide)) {
|
||||
$this->slides->removeElement($slide);
|
||||
}
|
||||
//$slide->removeTeam($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
53
src/App/Form/Slide.php
Normal file → Executable file
53
src/App/Form/Slide.php
Normal file → Executable file
@ -30,9 +30,34 @@ class Slide
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @Annotation\Type("Zend\Form\Element\Text")
|
||||
* @Annotation\Required(true)
|
||||
* @Annotation\InputFilter("Zend\Filter\StringTrim")
|
||||
* @Annotation\Options({
|
||||
* "label": "Slide type"
|
||||
* })
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @Annotation\Type("Zend\Form\Element\Text")
|
||||
* @Annotation\Required(true)
|
||||
* @Annotation\InputFilter("Zend\Filter\StringTrim")
|
||||
* @Annotation\Options({
|
||||
* "label": "Slide visibility"
|
||||
* })
|
||||
* @var string
|
||||
*/
|
||||
private $visibility;
|
||||
|
||||
/**
|
||||
* @Annotation\Type("doctrine.object_select")
|
||||
* @Annotation\Required(false)
|
||||
* @Annotation\Attributes({
|
||||
* "multiple": true
|
||||
* })
|
||||
* @Annotation\Options({
|
||||
* "property": "name",
|
||||
* "label": "Team",
|
||||
@ -48,21 +73,39 @@ class Slide
|
||||
* }
|
||||
* }
|
||||
* })
|
||||
* @var
|
||||
* @var Team[]
|
||||
*/
|
||||
private $team;
|
||||
private $teams;
|
||||
|
||||
/**
|
||||
* @Annotation\Type("Zend\Form\Element\Text")
|
||||
* @Annotation\Required(true)
|
||||
* @Annotation\Required(false)
|
||||
* @Annotation\InputFilter("Zend\Filter\StringTrim")
|
||||
* @Annotation\Options({
|
||||
* "label": "Slide contents"
|
||||
* "label": "Slide contents (type markdown)"
|
||||
* })
|
||||
* @var
|
||||
* @var string
|
||||
*/
|
||||
private $slideData;
|
||||
|
||||
/**
|
||||
* @Annotation\Type("Zend\Form\Element\Text")
|
||||
* @Annotation\Required(false)
|
||||
* @Annotation\InputFilter("Zend\Filter\StringTrim")
|
||||
* @Annotation\Options({
|
||||
* "label": "Slide url (type iframe)"
|
||||
* })
|
||||
* @Annotation\Validator({
|
||||
* "name":"Uri",
|
||||
* "options": {
|
||||
* "allowAbsolute": true,
|
||||
* "allowRelative": false,
|
||||
* }
|
||||
* })
|
||||
* @var string
|
||||
*/
|
||||
private $slideUrl;
|
||||
|
||||
/**
|
||||
* @Annotation\Type("Zend\Form\Element\Checkbox")
|
||||
* @Annotation\Options({
|
||||
|
||||
4
src/App/Handler/KanbanHandler.php
Normal file → Executable file
4
src/App/Handler/KanbanHandler.php
Normal file → Executable file
@ -32,9 +32,9 @@ class KanbanHandler implements RequestHandlerInterface
|
||||
*/
|
||||
public function handle(ServerRequestInterface $request): ResponseInterface
|
||||
{
|
||||
$filterId = $request->getAttribute('filterId');
|
||||
$teamId = (int)$request->getAttribute('teamId');
|
||||
/** @var KanbanBoard $kanbanResult */
|
||||
$kanbanResult = $this->dataCollector->getKanbanBoard($filterId);
|
||||
$kanbanResult = $this->dataCollector->getKanbanBoard($teamId);
|
||||
return new JsonResponse($kanbanResult);
|
||||
}
|
||||
}
|
||||
|
||||
169
src/App/Service/JiraCollectorService.php
Normal file → Executable file
169
src/App/Service/JiraCollectorService.php
Normal file → Executable file
@ -9,6 +9,7 @@ use App\Entity\JiraIssueType;
|
||||
use App\Entity\JiraStatus;
|
||||
use App\Entity\KanbanBoard;
|
||||
use App\Entity\KanbanEntry;
|
||||
use App\Entity\Team;
|
||||
use Zend\Cache\Storage\StorageInterface;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Expressive\Router\RouterInterface;
|
||||
@ -20,6 +21,10 @@ class JiraCollectorService
|
||||
{
|
||||
|
||||
const CACHE_KEY_KANBANBOARD = 'kanbanBoard';
|
||||
const BACKLOG_FIELD_DELIMITER = ';';
|
||||
|
||||
const EPIC_TICKET_LINK = 'customfield_11711';
|
||||
const EPIC_NAME_FIELD = 'customfield_11712';
|
||||
|
||||
/** @var StorageInterface */
|
||||
private $cache;
|
||||
@ -33,39 +38,54 @@ class JiraCollectorService
|
||||
/** @var RouterInterface */
|
||||
private $router;
|
||||
|
||||
/** @var TeamService */
|
||||
private $teamService;
|
||||
|
||||
/** @var array */
|
||||
private $cachedEpics = [];
|
||||
|
||||
/**
|
||||
* JiraClientService constructor.
|
||||
* @param StorageInterface $cache
|
||||
* @param Client $client
|
||||
* @param Config $config
|
||||
* @param RouterInterface $router
|
||||
* @param TeamService $teamService
|
||||
*/
|
||||
public function __construct(StorageInterface $cache, Client $client, Config $config, RouterInterface $router)
|
||||
public function __construct(StorageInterface $cache,
|
||||
Client $client,
|
||||
Config $config,
|
||||
RouterInterface $router,
|
||||
TeamService $teamService)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->router = $router;
|
||||
$this->httpClient = $client;
|
||||
$this->config = $config;
|
||||
$this->teamService = $teamService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $filterId
|
||||
* @param int $teamId
|
||||
* @param bool $forceReload
|
||||
* @return KanbanBoard
|
||||
*/
|
||||
public function getKanbanBoard(int $filterId = null, bool $forceReload = false): KanbanBoard
|
||||
public function getKanbanBoard(int $teamId = null, bool $forceReload = false): KanbanBoard
|
||||
{
|
||||
$kanbanBoard = $this->cache->getItem('kanbanBoard');
|
||||
$team = $this->teamService->getTeam($teamId);
|
||||
$teamName = $team->getName();
|
||||
$kanbanBoard = $this->cache->getItem(sprintf("%s-%s", self::CACHE_KEY_KANBANBOARD, $teamName));
|
||||
if ($forceReload || null === $kanbanBoard) {
|
||||
$user = $this->config->get('jira.user');
|
||||
$password = $this->config->get('jira.password');
|
||||
/** @var Config $kanbanBoardUriParams */
|
||||
$kanbanBoardUriParams = $this->config->get('url.jiraKanbanBoard');
|
||||
$kanbanBoardUri = $this->config->get('url.jiraKanbanBoard');
|
||||
$kanbanBoardFilter = $this->config->get('jira.filterFields')->toArray();
|
||||
|
||||
$kanbanBoardUri = sprintf(
|
||||
$kanbanBoardUriParams['baseUrl'],
|
||||
isset($filterId) ? $filterId : $kanbanBoardUriParams['filterId'],
|
||||
implode(",", $kanbanBoardUriParams['fields']->toArray())
|
||||
$kanbanBoardUri,
|
||||
$team->getFilterId(),
|
||||
implode(",", $kanbanBoardFilter)
|
||||
);
|
||||
|
||||
$response = $this->httpClient
|
||||
@ -79,8 +99,8 @@ class JiraCollectorService
|
||||
|
||||
$parsedJsonData = Decoder::decode($response->getBody(), Json::TYPE_ARRAY);
|
||||
|
||||
$kanbanBoard = $this->hydrateKanbanBoard($parsedJsonData);
|
||||
$this->cache->setItem(self::CACHE_KEY_KANBANBOARD, serialize($kanbanBoard));
|
||||
$kanbanBoard = $this->hydrateKanbanBoard($team, $parsedJsonData);
|
||||
$this->cache->setItem(sprintf("%s-%s", self::CACHE_KEY_KANBANBOARD, $teamName), serialize($kanbanBoard));
|
||||
} else {
|
||||
$kanbanBoard = unserialize($kanbanBoard);
|
||||
}
|
||||
@ -89,22 +109,77 @@ class JiraCollectorService
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $parentKey
|
||||
* @return null|string
|
||||
*/
|
||||
private function getEpicNameFromParent(string $parentKey): ?string
|
||||
{
|
||||
if (array_key_exists($parentKey, $this->cachedEpics)) {
|
||||
return $this->cachedEpics[$parentKey];
|
||||
}
|
||||
|
||||
$user = $this->config->get('jira.user');
|
||||
$password = $this->config->get('jira.password');
|
||||
/** @var Config $kanbanBoardUriParams */
|
||||
$jiraIssueBaseUrl = $this->config->get('url.jiraIssue');
|
||||
$kanbanBoardFilter = $this->config->get('jira.filterFields')->toArray();
|
||||
$kanbanBoardFilterString = implode(",", $kanbanBoardFilter);
|
||||
$jiraIssueUri = sprintf($jiraIssueBaseUrl, $parentKey, $kanbanBoardFilterString);
|
||||
|
||||
$response = $this->httpClient
|
||||
->setUri($jiraIssueUri)
|
||||
->setAuth($user, $password)
|
||||
->send();
|
||||
|
||||
if (!$response->isSuccess()) {
|
||||
throw new \UnexpectedValueException("Bad JIRA result: $jiraIssueUri", $response->getStatusCode());
|
||||
}
|
||||
|
||||
$parsedJsonParentData = Decoder::decode($response->getBody(), Json::TYPE_ARRAY);
|
||||
if ($parsedJsonParentData['fields'][self::EPIC_TICKET_LINK]) {
|
||||
$jiraIssueUri = sprintf(
|
||||
$jiraIssueBaseUrl,
|
||||
$parsedJsonParentData['fields'][self::EPIC_TICKET_LINK],
|
||||
$kanbanBoardFilterString
|
||||
);
|
||||
$response = $this->httpClient
|
||||
->setUri($jiraIssueUri)
|
||||
->setAuth($user, $password)
|
||||
->send();
|
||||
|
||||
if (!$response->isSuccess()) {
|
||||
throw new \UnexpectedValueException("Bad JIRA result", $response->getStatusCode());
|
||||
}
|
||||
|
||||
$parsedJsonEpicData = Decoder::decode($response->getBody(), Json::TYPE_ARRAY);
|
||||
$this->cachedEpics[$parentKey] = $parsedJsonEpicData['fields'][self::EPIC_NAME_FIELD];
|
||||
return $this->cachedEpics[$parentKey];
|
||||
}
|
||||
$this->cachedEpics[$parentKey] = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Team $team
|
||||
* @param $parsedJsonData
|
||||
* @return KanbanBoard
|
||||
* @todo check if avatar has to be locally cached
|
||||
*/
|
||||
private function hydrateKanbanBoard($parsedJsonData): KanbanBoard
|
||||
private function hydrateKanbanBoard(Team $team, $parsedJsonData): KanbanBoard
|
||||
{
|
||||
$kanbanBoard = new KanbanBoard();
|
||||
|
||||
$teamBacklogColumns = explode(self::BACKLOG_FIELD_DELIMITER, $team->getBacklogColumn()["jiraStatusName"]);
|
||||
$teamInprogressColumns = explode(self::BACKLOG_FIELD_DELIMITER, $team->getInprogressColumn()["jiraStatusName"]);
|
||||
$teamVerificationColumns = explode(self::BACKLOG_FIELD_DELIMITER, $team->getVerificationColumn()["jiraStatusName"]);
|
||||
$teamDoneColumns = explode(self::BACKLOG_FIELD_DELIMITER, $team->getDoneColumn()["jiraStatusName"]);
|
||||
|
||||
foreach ($parsedJsonData['issues'] as $jsonIssue) {
|
||||
set_time_limit(30);
|
||||
$kanbanEntry = new KanbanEntry();
|
||||
$kanbanEntry->setId(intval($jsonIssue['id']))
|
||||
->setKey($jsonIssue['key'])
|
||||
->setSummary($jsonIssue['fields']['summary'])
|
||||
->setExternalLink($jsonIssue['fields']['customfield_10850'])
|
||||
->setMhwebStatus($jsonIssue['fields']['customfield_10844'])
|
||||
->setAnswerCode($jsonIssue['fields']['customfield_11692'])
|
||||
->setIssuePriority($jsonIssue['fields']['priority']['name'])
|
||||
->setIssuePriorityIcon($jsonIssue['fields']['priority']['iconUrl'])
|
||||
->setLabels($jsonIssue['fields']['labels'])
|
||||
@ -143,48 +218,13 @@ class JiraCollectorService
|
||||
}
|
||||
}
|
||||
|
||||
// externalId : customfield_10010
|
||||
if (isset($jsonIssue['fields']['customfield_10010'])) {
|
||||
$kanbanEntry->setExternalId($jsonIssue['fields']['customfield_10010']);
|
||||
}
|
||||
|
||||
// prio : customfield_10840
|
||||
if (isset($jsonIssue['fields']['customfield_11226'])) {
|
||||
$kanbanEntry->setPrio($jsonIssue['fields']['customfield_11226']);
|
||||
}
|
||||
|
||||
// functional area : customfield_11225
|
||||
if (isset($jsonIssue['fields']['customfield_11225'])) {
|
||||
foreach ($jsonIssue['fields']['customfield_11225'] as $functionalArea) {
|
||||
$kanbanEntry->addFunctionalArea($functionalArea['value']);
|
||||
}
|
||||
}
|
||||
|
||||
// project : customfield_10840
|
||||
if (isset($jsonIssue['fields']['customfield_10840'])) {
|
||||
$kanbanEntry->setProject($jsonIssue['fields']['customfield_10840']['value']);
|
||||
}
|
||||
|
||||
// mhweb hot : customfield_10847
|
||||
if (isset($jsonIssue['fields']['customfield_10847'])) {
|
||||
$boolVal = $jsonIssue['fields']['customfield_10847'][0]['value'] == 'yes';
|
||||
$kanbanEntry->setMhwebHot($boolVal);
|
||||
}
|
||||
|
||||
// mhweb external : customfield_10849
|
||||
if (isset($jsonIssue['fields']['customfield_10849'])) {
|
||||
$boolVal = $jsonIssue['fields']['customfield_10849'][0]['value'] == 'yes';
|
||||
$kanbanEntry->setMhwebExternal($boolVal);
|
||||
}
|
||||
|
||||
// team : customfield_10904
|
||||
if (isset($jsonIssue['fields']['customfield_10904'])) {
|
||||
$kanbanEntry->setTeam($jsonIssue['fields']['customfield_10904']['value']);
|
||||
}
|
||||
|
||||
// team : customfield_12500
|
||||
if (isset($jsonIssue['fields']['customfield_12500'])) {
|
||||
$kanbanEntry->setTaurusPrio($jsonIssue['fields']['customfield_12500']);
|
||||
// epicName: have to fetch 2 extra records
|
||||
if (isset($jsonIssue['fields'][self::EPIC_TICKET_LINK])) {
|
||||
$epicName = $this->getEpicNameFromParent($jsonIssue['key']);
|
||||
$kanbanEntry->setEpicName($epicName);
|
||||
} elseif (isset($jsonIssue['fields']['parent'])) {
|
||||
$epicName = $this->getEpicNameFromParent($jsonIssue['fields']['parent']['key']);
|
||||
$kanbanEntry->setEpicName($epicName);
|
||||
}
|
||||
|
||||
// jira status
|
||||
@ -222,20 +262,17 @@ class JiraCollectorService
|
||||
}
|
||||
|
||||
$kanbanEntry->setUpdatedAt(new \DateTime($jsonIssue['fields']['updated']));
|
||||
|
||||
switch ($jiraStatus->getName()) {
|
||||
case "Backlog":
|
||||
if (in_array($jiraStatus->getName(), $teamBacklogColumns)) {
|
||||
$kanbanBoard->addInbox($kanbanEntry);
|
||||
break;
|
||||
case "In Progress":
|
||||
}
|
||||
elseif (in_array($jiraStatus->getName(), $teamInprogressColumns)) {
|
||||
$kanbanBoard->addInProgress($kanbanEntry);
|
||||
break;
|
||||
case "Verification":
|
||||
}
|
||||
elseif (in_array($jiraStatus->getName(), $teamVerificationColumns)) {
|
||||
$kanbanBoard->addVerification($kanbanEntry);
|
||||
break;
|
||||
case "Done":
|
||||
}
|
||||
elseif (in_array($jiraStatus->getName(), $teamDoneColumns)) {
|
||||
$kanbanBoard->addDone($kanbanEntry);
|
||||
break;
|
||||
}
|
||||
unset($kanbanEntry);
|
||||
}
|
||||
|
||||
3
src/App/Service/JiraCollectorServiceFactory.php
Normal file → Executable file
3
src/App/Service/JiraCollectorServiceFactory.php
Normal file → Executable file
@ -18,6 +18,7 @@ class JiraCollectorServiceFactory
|
||||
$httpClient = $container->get(Client::class);
|
||||
$config = new Config($configArray['app.config']);
|
||||
$router = $container->get(RouterInterface::class);
|
||||
return new JiraCollectorService($cache,$httpClient, $config, $router);
|
||||
$teamService = $container->get(TeamService::class);
|
||||
return new JiraCollectorService($cache,$httpClient, $config, $router, $teamService);
|
||||
}
|
||||
}
|
||||
|
||||
0
src/App/Service/SlideManager.php
Normal file → Executable file
0
src/App/Service/SlideManager.php
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user