diff --git a/config/autoload/cli.global.php b/config/autoload/cli.global.php new file mode 100755 index 0000000..c721da0 --- /dev/null +++ b/config/autoload/cli.global.php @@ -0,0 +1,16 @@ + [ + 'factories' => [ + App\Command\UpdatePageCachesCommand::class => App\Command\UpdatePageCachesFactory::class, + ], + ], + 'console' => [ + 'commands' => [ + App\Command\UpdatePageCachesCommand::class, + ], + ], +]; diff --git a/src/App/Command/UpdatePageCachesCommand.php b/src/App/Command/UpdatePageCachesCommand.php new file mode 100755 index 0000000..3853c4d --- /dev/null +++ b/src/App/Command/UpdatePageCachesCommand.php @@ -0,0 +1,42 @@ +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); + } + } +} diff --git a/src/App/Command/UpdatePageCachesFactory.php b/src/App/Command/UpdatePageCachesFactory.php new file mode 100755 index 0000000..77e32c0 --- /dev/null +++ b/src/App/Command/UpdatePageCachesFactory.php @@ -0,0 +1,42 @@ +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); + } +} diff --git a/src/App/Entity/Team.php b/src/App/Entity/Team.php index 20afa16..20ffa37 100755 --- a/src/App/Entity/Team.php +++ b/src/App/Entity/Team.php @@ -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(), diff --git a/src/App/Form/Team.php b/src/App/Form/Team.php old mode 100644 new mode 100755 index 4d6335f..9b50c3f --- a/src/App/Form/Team.php +++ b/src/App/Form/Team.php @@ -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) diff --git a/src/App/Service/JiraCollectorService.php b/src/App/Service/JiraCollectorService.php index 7872cd7..0fbf767 100755 --- a/src/App/Service/JiraCollectorService.php +++ b/src/App/Service/JiraCollectorService.php @@ -19,7 +19,6 @@ use Zend\Json\Json; class JiraCollectorService { - const CACHE_KEY_KANBANBOARD = 'kanbanBoard'; const BACKLOG_FIELD_DELIMITER = ';'; diff --git a/src/App/Service/TeamService.php b/src/App/Service/TeamService.php old mode 100644 new mode 100755 index c4d22a9..7a7b6f8 --- a/src/App/Service/TeamService.php +++ b/src/App/Service/TeamService.php @@ -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 {