* team labels added

* cli task added
This commit is contained in:
Dávid Danyi 2018-09-06 15:38:03 +02:00
parent cfc388aa77
commit 9563eae0b1
7 changed files with 139 additions and 2 deletions

16
config/autoload/cli.global.php Executable file
View File

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
return [
'dependencies' => [
'factories' => [
App\Command\UpdatePageCachesCommand::class => App\Command\UpdatePageCachesFactory::class,
],
],
'console' => [
'commands' => [
App\Command\UpdatePageCachesCommand::class,
],
],
];

View File

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace App\Command;
use App\Service\JiraCollectorService;
use App\Service\TeamService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class UpdatePageCachesCommand extends Command
{
/** @var JiraCollectorService */
private $jiraCollectorService;
/** @var TeamService */
private $teamService;
public function __construct(JiraCollectorService $jiraCollectorService, TeamService $teamService)
{
$this->jiraCollectorService = $jiraCollectorService;
$this->teamService = $teamService;
parent::__construct();
}
protected function configure()
{
$this->setName('cache:update')
->setDescription('Updates page-cache data for kanban pages');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$teams = $this->teamService->listTeams();
foreach ($teams as $team) {
set_time_limit(30);
$this->jiraCollectorService->getKanbanBoard($team->getId(),true);
}
}
}

View File

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace App\Command;
use App\Handler\AvatarHandler;
use App\Service\JiraCollectorService;
use App\Service\TeamService;
use Psr\Container\ContainerInterface;
use Zend\Expressive\MiddlewareContainer;
use Zend\Expressive\MiddlewareFactory;
use Zend\Expressive\Router\Route;
use Zend\Expressive\Router\RouterInterface;
class UpdatePageCachesFactory
{
/**
* @param ContainerInterface $container
* @return UpdatePageCachesCommand
*/
public function __invoke(ContainerInterface $container)
{
$middlewareContainer = new MiddlewareContainer($container);
$factory = new MiddlewareFactory($middlewareContainer);
$avatarHandlerMiddleware = $factory->prepare(AvatarHandler::class);
$avatarRoute = new Route(
'/avatars/{signum}',
$avatarHandlerMiddleware,
Route::HTTP_METHOD_ANY,
'avatar.image'
);
/** @var \Zend\Expressive\Router\FastRouteRouter $router */
$router = $container->get(RouterInterface::class);
$router->addRoute($avatarRoute);
$jiraCollectorService = $container->get(JiraCollectorService::class);
$teamService = $container->get(TeamService::class);
return new UpdatePageCachesCommand($jiraCollectorService, $teamService);
}
}

View File

@ -36,6 +36,12 @@ class Team implements JsonSerializable
*/
private $members;
/**
* @ORM\Column(name="labels", type="json", nullable=true)
* @var array
*/
private $labels;
/**
* @ORM\ManyToMany(targetEntity="Slide", mappedBy="teams", cascade={"persist", "remove"})
* @ORM\JoinTable(
@ -104,6 +110,7 @@ class Team implements JsonSerializable
public function __construct()
{
$this->members = new \ArrayObject;
$this->labels = new \ArrayObject;
$this->slides = new ArrayCollection;
$this->backlogColumn = new KanbanColumn();
@ -166,6 +173,24 @@ class Team implements JsonSerializable
return $this;
}
/**
* @return array
*/
public function getLabels()
{
return $this->labels;
}
/**
* @param array $labels
* @return Team
*/
public function setLabels(array $labels): Team
{
$this->labels = $labels;
return $this;
}
/**
* @param Slide $slide
* @return Team
@ -353,6 +378,7 @@ class Team implements JsonSerializable
'id' => $this->getId(),
'name' => $this->getName(),
'members' => $this->getMembers(),
'labels' => $this->getLabels(),
'filterId' => $this->getFilterId(),
'backlogColumn' => $this->getBacklogColumn() ?? new KanbanColumn(),
'inprogressColumn' => $this->getInprogressColumn() ?? new KanbanColumn(),

11
src/App/Form/Team.php Normal file → Executable file
View File

@ -42,6 +42,17 @@ class Team
*/
private $members;
/**
* This is a dummy field, not a text actually. Only used to filter the input
* @Annotation\Type("Zend\Form\Element\Text")
* @Annotation\Required(false)
* @Annotation\Options({
* "label": "Labels"
* })
* @var array
*/
private $labels;
/**
* @Annotation\Type("Zend\Form\Element\Number")
* @Annotation\Required(true)

View File

@ -19,7 +19,6 @@ use Zend\Json\Json;
class JiraCollectorService
{
const CACHE_KEY_KANBANBOARD = 'kanbanBoard';
const BACKLOG_FIELD_DELIMITER = ';';

3
src/App/Service/TeamService.php Normal file → Executable file
View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Service;
use App\Entity\Team;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityNotFoundException;
use Zend\Form\Form;
@ -26,7 +27,7 @@ class TeamService
}
/**
* @return array
* @return Team[]|ArrayCollection
*/
public function listTeams(): array
{