* obsolete code removed
This commit is contained in:
parent
774fa3640f
commit
74651ffc81
@ -4,13 +4,11 @@ return [
|
|||||||
'dependencies' => [
|
'dependencies' => [
|
||||||
'invokables' => [],
|
'invokables' => [],
|
||||||
'factories' => [
|
'factories' => [
|
||||||
App\Command\UpdateLabInfoCommand::class => App\Command\UpdateLabInfoFactory::class,
|
|
||||||
App\Command\UpdatePageCachesCommand::class => App\Command\UpdatePageCachesFactory::class,
|
App\Command\UpdatePageCachesCommand::class => App\Command\UpdatePageCachesFactory::class,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'console' => [
|
'console' => [
|
||||||
'commands' => [
|
'commands' => [
|
||||||
App\Command\UpdateLabInfoCommand::class,
|
|
||||||
App\Command\UpdatePageCachesCommand::class,
|
App\Command\UpdatePageCachesCommand::class,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
@ -31,6 +31,3 @@ $app->get('/api/ping', App\Action\PingAction::class, 'api.ping');
|
|||||||
|
|
||||||
$app->get('/api/kanban', App\Action\KanbanAction::class, 'api.kanban');
|
$app->get('/api/kanban', App\Action\KanbanAction::class, 'api.kanban');
|
||||||
$app->get('/avatars/{signum}', App\Action\AvatarAction::class, 'user.avatar');
|
$app->get('/avatars/{signum}', App\Action\AvatarAction::class, 'user.avatar');
|
||||||
|
|
||||||
$app->get('/api/tsp-info', App\Action\TspInfoAction::class, 'api.tsp-info');
|
|
||||||
$app->get('/api/want-some-fun', App\Action\FunAction::class, 'api.fun');
|
|
||||||
|
|||||||
@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Action;
|
|
||||||
|
|
||||||
use App\Response\JsonCorsResponse;
|
|
||||||
use App\Service\FunService;
|
|
||||||
use Interop\Http\ServerMiddleware\DelegateInterface;
|
|
||||||
use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface;
|
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
|
||||||
|
|
||||||
class FunAction implements ServerMiddlewareInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var FunService
|
|
||||||
*/
|
|
||||||
private $tspInfoService;
|
|
||||||
|
|
||||||
public function __construct(FunService $tspInfoService)
|
|
||||||
{
|
|
||||||
$this->tspInfoService = $tspInfoService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ServerRequestInterface $request
|
|
||||||
* @param DelegateInterface $delegate
|
|
||||||
* @return JsonCorsResponse
|
|
||||||
*/
|
|
||||||
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
|
|
||||||
{
|
|
||||||
return new JsonCorsResponse($this->tspInfoService->getSomeFun());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Action;
|
|
||||||
|
|
||||||
use App\Service\FunService;
|
|
||||||
use Interop\Container\ContainerInterface;
|
|
||||||
|
|
||||||
class FunFactory
|
|
||||||
{
|
|
||||||
public function __invoke(ContainerInterface $container)
|
|
||||||
{
|
|
||||||
$funService = $container->get(FunService::class);
|
|
||||||
return new FunAction($funService);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Action;
|
|
||||||
|
|
||||||
use App\Response\JsonCorsResponse;
|
|
||||||
use App\Service\JcatInfoCollectorService;
|
|
||||||
use App\Service\JiraCollectorService;
|
|
||||||
use App\Service\LabInfoCollectorService;
|
|
||||||
use App\Service\TrInfoCollectorService;
|
|
||||||
use App\Service\TspInfoService;
|
|
||||||
use App\Service\VacationInfoCollectorService;
|
|
||||||
use Interop\Http\ServerMiddleware\DelegateInterface;
|
|
||||||
use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface;
|
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
|
||||||
use Zend\Config\Config;
|
|
||||||
|
|
||||||
class TspInfoAction implements ServerMiddlewareInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var TspInfoService
|
|
||||||
*/
|
|
||||||
private $tspInfoService;
|
|
||||||
|
|
||||||
public function __construct(TspInfoService $tspInfoService)
|
|
||||||
{
|
|
||||||
$this->tspInfoService = $tspInfoService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ServerRequestInterface $request
|
|
||||||
* @param DelegateInterface $delegate
|
|
||||||
* @return JsonCorsResponse
|
|
||||||
*/
|
|
||||||
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
|
|
||||||
{
|
|
||||||
return new JsonCorsResponse($this->tspInfoService->getTspInfo());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Action;
|
|
||||||
|
|
||||||
use App\Service\JcatInfoCollectorService;
|
|
||||||
use App\Service\JiraCollectorService;
|
|
||||||
use App\Service\LabInfoCollectorService;
|
|
||||||
use App\Service\TrInfoCollectorService;
|
|
||||||
use App\Service\TspInfoService;
|
|
||||||
use App\Service\VacationInfoCollectorService;
|
|
||||||
use Interop\Container\ContainerInterface;
|
|
||||||
use Zend\Config\Config;
|
|
||||||
|
|
||||||
class TspInfoFactory
|
|
||||||
{
|
|
||||||
public function __invoke(ContainerInterface $container)
|
|
||||||
{
|
|
||||||
$tspInfoService = $container->get(TspInfoService::class);
|
|
||||||
return new TspInfoAction($tspInfoService);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Command;
|
|
||||||
|
|
||||||
use App\Service\LabInfoCollectorService;
|
|
||||||
use Symfony\Component\Console\Command\Command;
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
|
||||||
|
|
||||||
class UpdateLabInfoCommand extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var LabInfoCollectorService
|
|
||||||
*/
|
|
||||||
private $labInfoService;
|
|
||||||
|
|
||||||
public function __construct(LabInfoCollectorService $labInfoService)
|
|
||||||
{
|
|
||||||
$this->labInfoService = $labInfoService;
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
$this->setName('labinfo:print')
|
|
||||||
->setDescription('Updates cache of jcat packages, streams and active nightly ci configuration');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
|
||||||
{
|
|
||||||
$output->writeln($this->labInfoService->getLabTemperatureData());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Command;
|
|
||||||
|
|
||||||
use App\Service\LabInfoCollectorService;
|
|
||||||
use Interop\Container\ContainerInterface;
|
|
||||||
|
|
||||||
class UpdateLabInfoFactory
|
|
||||||
{
|
|
||||||
public function __invoke(ContainerInterface $container)
|
|
||||||
{
|
|
||||||
/** @var LabInfoCollectorService $labInfoService */
|
|
||||||
$labInfoService = $container->get(LabInfoCollectorService::class);
|
|
||||||
return new UpdateLabInfoCommand($labInfoService);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -3,27 +3,20 @@
|
|||||||
namespace App\Command;
|
namespace App\Command;
|
||||||
|
|
||||||
use App\Service\JiraCollectorService;
|
use App\Service\JiraCollectorService;
|
||||||
use App\Service\TspInfoService;
|
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
class UpdatePageCachesCommand extends Command
|
class UpdatePageCachesCommand extends Command
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var TspInfoService
|
|
||||||
*/
|
|
||||||
private $tspInfoService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var JiraCollectorService
|
* @var JiraCollectorService
|
||||||
*/
|
*/
|
||||||
private $jiraCollectorService;
|
private $jiraCollectorService;
|
||||||
|
|
||||||
public function __construct(TspInfoService $tspInfoService,
|
public function __construct(JiraCollectorService $jiraCollectorService)
|
||||||
JiraCollectorService $jiraCollectorService)
|
|
||||||
{
|
{
|
||||||
$this->tspInfoService = $tspInfoService;
|
|
||||||
$this->jiraCollectorService = $jiraCollectorService;
|
$this->jiraCollectorService = $jiraCollectorService;
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
@ -31,12 +24,11 @@ class UpdatePageCachesCommand extends Command
|
|||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this->setName('cache:update')
|
$this->setName('cache:update')
|
||||||
->setDescription('Updates page-cache data for tspInfo and kanban pages');
|
->setDescription('Updates page-cache data for kanban pages');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$this->tspInfoService->getTspInfo(true);
|
|
||||||
$this->jiraCollectorService->getKanbanBoard(true);
|
$this->jiraCollectorService->getKanbanBoard(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,6 @@ namespace App\Command;
|
|||||||
|
|
||||||
use App\Action\AvatarAction;
|
use App\Action\AvatarAction;
|
||||||
use App\Service\JiraCollectorService;
|
use App\Service\JiraCollectorService;
|
||||||
use App\Service\TspInfoService;
|
|
||||||
use Interop\Container\ContainerInterface;
|
use Interop\Container\ContainerInterface;
|
||||||
use Zend\Expressive\Router\Route;
|
use Zend\Expressive\Router\Route;
|
||||||
use Zend\Expressive\Router\RouterInterface;
|
use Zend\Expressive\Router\RouterInterface;
|
||||||
@ -27,8 +26,7 @@ class UpdatePageCachesFactory
|
|||||||
$router = $container->get(RouterInterface::class);
|
$router = $container->get(RouterInterface::class);
|
||||||
$router->addRoute($avatarRoute);
|
$router->addRoute($avatarRoute);
|
||||||
|
|
||||||
$tspInfoService = $container->get(TspInfoService::class);
|
|
||||||
$jiraCollectorService = $container->get(JiraCollectorService::class);
|
$jiraCollectorService = $container->get(JiraCollectorService::class);
|
||||||
return new UpdatePageCachesCommand($tspInfoService, $jiraCollectorService);
|
return new UpdatePageCachesCommand($jiraCollectorService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,12 +51,7 @@ class ConfigProvider
|
|||||||
|
|
||||||
Service\AvatarService::class => Service\AvatarServiceFactory::class,
|
Service\AvatarService::class => Service\AvatarServiceFactory::class,
|
||||||
Service\JiraCollectorService::class => Service\JiraCollectorServiceFactory::class,
|
Service\JiraCollectorService::class => Service\JiraCollectorServiceFactory::class,
|
||||||
Service\LabInfoCollectorService::class => Service\LabInfoCollectorServiceFactory::class,
|
|
||||||
Service\VacationInfoCollectorService::class => Service\VacationInfoCollectorServiceFactory::class,
|
Service\VacationInfoCollectorService::class => Service\VacationInfoCollectorServiceFactory::class,
|
||||||
Service\TrInfoCollectorService::class => Service\TrInfoCollectorServiceFactory::class,
|
|
||||||
Service\JcatInfoCollectorService::class => Service\JcatInfoCollectorServiceFactory::class,
|
|
||||||
Service\TspInfoService::class => Service\TspInfoServiceFactory::class,
|
|
||||||
Service\FunService::class => Service\FunServiceFactory::class,
|
|
||||||
|
|
||||||
'service.cache' => function(ContainerInterface $container): StorageInterface {
|
'service.cache' => function(ContainerInterface $container): StorageInterface {
|
||||||
$cache = new FilesytemCache();
|
$cache = new FilesytemCache();
|
||||||
|
|||||||
@ -1,114 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
class TrProgress implements \JsonSerializable
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $eriref;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $heading;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $prio;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
private $lastProgressInDays;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getEriref(): string
|
|
||||||
{
|
|
||||||
return $this->eriref;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $eriref
|
|
||||||
* @return TrProgress
|
|
||||||
*/
|
|
||||||
public function setEriref(string $eriref): TrProgress
|
|
||||||
{
|
|
||||||
$this->eriref = $eriref;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getHeading(): string
|
|
||||||
{
|
|
||||||
return $this->heading;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $heading
|
|
||||||
* @return TrProgress
|
|
||||||
*/
|
|
||||||
public function setHeading(string $heading): TrProgress
|
|
||||||
{
|
|
||||||
$this->heading = $heading;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getPrio(): string
|
|
||||||
{
|
|
||||||
return $this->prio;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $prio
|
|
||||||
* @return TrProgress
|
|
||||||
*/
|
|
||||||
public function setPrio(string $prio): TrProgress
|
|
||||||
{
|
|
||||||
$this->prio = $prio;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getLastProgressInDays(): int
|
|
||||||
{
|
|
||||||
return $this->lastProgressInDays;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $lastProgressInDays
|
|
||||||
* @return TrProgress
|
|
||||||
*/
|
|
||||||
public function setLastProgressInDays(int $lastProgressInDays): TrProgress
|
|
||||||
{
|
|
||||||
$this->lastProgressInDays = $lastProgressInDays;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function jsonSerialize()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'eriref' => $this->getEriref(),
|
|
||||||
'heading' => $this->getHeading(),
|
|
||||||
'prio' => $this->getPrio(),
|
|
||||||
'lastProgressInDays' => $this->getLastProgressInDays(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use Zend\Cache\Storage\StorageInterface;
|
|
||||||
use Zend\Config\Config;
|
|
||||||
|
|
||||||
class FunService
|
|
||||||
{
|
|
||||||
|
|
||||||
const CACHE_KEY = 'funPage';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var StorageInterface
|
|
||||||
*/
|
|
||||||
private $cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Config
|
|
||||||
*/
|
|
||||||
private $config;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
StorageInterface $cache,
|
|
||||||
Config $config
|
|
||||||
)
|
|
||||||
{
|
|
||||||
$this->cache = $cache;
|
|
||||||
$this->config = $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param bool $forceReload
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getSomeFun(bool $forceReload = false): array
|
|
||||||
{
|
|
||||||
$tspInfo = $this->cache->getItem(self::CACHE_KEY);
|
|
||||||
if($forceReload || null == $tspInfo) {
|
|
||||||
$tspInfo = [
|
|
||||||
'cameraUrls' => $this->config->get('url.eurestCameras')->toArray(),
|
|
||||||
'animGifs' => [],
|
|
||||||
];
|
|
||||||
$this->cache->setItem(self::CACHE_KEY, serialize($tspInfo));
|
|
||||||
} else {
|
|
||||||
$tspInfo = unserialize($tspInfo);
|
|
||||||
}
|
|
||||||
return $tspInfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use Interop\Container\ContainerInterface;
|
|
||||||
use Zend\Config\Config;
|
|
||||||
|
|
||||||
class FunServiceFactory
|
|
||||||
{
|
|
||||||
public function __invoke(ContainerInterface $container)
|
|
||||||
{
|
|
||||||
$appConfig = $container->get('config')['app.config'];
|
|
||||||
$cache = $container->get('service.cache');
|
|
||||||
return new FunService(
|
|
||||||
$cache,
|
|
||||||
new Config($appConfig)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,87 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use League\Csv\Reader;
|
|
||||||
use League\Csv\Statement;
|
|
||||||
use Zend\Config\Config;
|
|
||||||
use Zend\Http\Client;
|
|
||||||
|
|
||||||
class JcatInfoCollectorService
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Config
|
|
||||||
*/
|
|
||||||
private $config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Client
|
|
||||||
*/
|
|
||||||
private $httpClient;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JiraClientService constructor.
|
|
||||||
* @param Client $client
|
|
||||||
* @param Config $config
|
|
||||||
*/
|
|
||||||
public function __construct(Client $client, Config $config)
|
|
||||||
{
|
|
||||||
$this->httpClient = $client;
|
|
||||||
$this->config = $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTrFlowErrors()
|
|
||||||
{
|
|
||||||
/** @var Config $kanbanBoardUriParams */
|
|
||||||
$trFlowUri = $this->config->get('url.jcatTrFlow');
|
|
||||||
|
|
||||||
$response = $this->httpClient
|
|
||||||
->setUri($trFlowUri)
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if (!$response->isSuccess()) {
|
|
||||||
throw new \UnexpectedValueException("Bad JCAT result", $response->getStatusCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->parseFlowHtmlResult($response->getBody());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $html
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function parseFlowHtmlResult(string $html)
|
|
||||||
{
|
|
||||||
$teamMembers = $this->config->get('team.members')->toArray();
|
|
||||||
$xmlErrorHandling = libxml_use_internal_errors(TRUE);
|
|
||||||
$domDocument = new \DOMDocument();
|
|
||||||
$domDocument->loadHTML($html);
|
|
||||||
libxml_clear_errors();
|
|
||||||
libxml_use_internal_errors($xmlErrorHandling);
|
|
||||||
|
|
||||||
$documentXpath = new \DOMXPath($domDocument);
|
|
||||||
/** @var \DOMNodeList $elements */
|
|
||||||
$elements = $documentXpath->query('//tr/td[1]');
|
|
||||||
|
|
||||||
$result = [];
|
|
||||||
/** @var \DOMElement $element */
|
|
||||||
foreach ($elements as $element) {
|
|
||||||
/** @var \DOMNodeList $ownerElements */
|
|
||||||
$ownerElements = $documentXpath->query('./td[6]', $element->parentNode);
|
|
||||||
$owner = strtolower(trim($ownerElements->item(0)->nodeValue));
|
|
||||||
if (in_array($owner, $teamMembers)) {
|
|
||||||
$result[] = trim($element->nodeValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$errorsCounted = array_count_values($result);
|
|
||||||
|
|
||||||
return array_map(function($type, $count) {
|
|
||||||
return [
|
|
||||||
'label' => $type,
|
|
||||||
'value' => $count,
|
|
||||||
];
|
|
||||||
}, array_keys($errorsCounted), $errorsCounted);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use Interop\Container\ContainerInterface;
|
|
||||||
use Zend\Config\Config;
|
|
||||||
use Zend\Http\Client;
|
|
||||||
|
|
||||||
class JcatInfoCollectorServiceFactory
|
|
||||||
{
|
|
||||||
public function __invoke(ContainerInterface $container)
|
|
||||||
{
|
|
||||||
$configArray = $container->get('config');
|
|
||||||
$httpClient = $container->get(Client::class);
|
|
||||||
$config = new Config($configArray['app.config']);
|
|
||||||
return new JcatInfoCollectorService($httpClient, $config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,103 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use Symfony\Component\CssSelector\CssSelectorConverter;
|
|
||||||
use Zend\Config\Config;
|
|
||||||
use Zend\Http\Client;
|
|
||||||
|
|
||||||
class LabInfoCollectorService
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Config
|
|
||||||
*/
|
|
||||||
private $config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Client
|
|
||||||
*/
|
|
||||||
private $httpClient;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $tempSensors = [
|
|
||||||
'Temp 5' => 'back_left',
|
|
||||||
'Temp 4' => 'back_middle',
|
|
||||||
'Temp 3' => 'back_right',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JiraClientService constructor.
|
|
||||||
* @param Client $client
|
|
||||||
* @param Config $config
|
|
||||||
*/
|
|
||||||
public function __construct(Client $client, Config $config)
|
|
||||||
{
|
|
||||||
$this->httpClient = $client;
|
|
||||||
$this->config = $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getLabTemperatureData()
|
|
||||||
{
|
|
||||||
/** @var Config $labTemperatureUrl */
|
|
||||||
$labTemperatureUrl = $this->config->get('url.labTemperatureUrl');
|
|
||||||
|
|
||||||
$response = $this->httpClient
|
|
||||||
->setUri($labTemperatureUrl)
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if(!$response->isSuccess()) {
|
|
||||||
throw new \UnexpectedValueException("Bad LAB result", $response->getStatusCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->parseHtml($response->getBody());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $html
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function parseHtml($html): array
|
|
||||||
{
|
|
||||||
$cssToXpathConverter = new CssSelectorConverter();
|
|
||||||
$xpathLabelQuery = $cssToXpathConverter->toXPath('a.sensormenu.isnotpaused');
|
|
||||||
$xpathValueQuery = $cssToXpathConverter->toXPath('div.graphlabel2');
|
|
||||||
|
|
||||||
$xmlErrorHandling = libxml_use_internal_errors(TRUE);
|
|
||||||
$domDocument = new \DOMDocument();
|
|
||||||
$domDocument->loadHTML($html);
|
|
||||||
libxml_clear_errors();
|
|
||||||
libxml_use_internal_errors($xmlErrorHandling);
|
|
||||||
|
|
||||||
$documentXpath = new \DOMXPath($domDocument);
|
|
||||||
/** @var \DOMNodeList $element */
|
|
||||||
$element = $documentXpath->query($xpathLabelQuery);
|
|
||||||
|
|
||||||
$thing = [];
|
|
||||||
/** @var \DOMElement $item */
|
|
||||||
foreach($element as $item) {
|
|
||||||
$sensorName = trim($item->nodeValue);
|
|
||||||
if( in_array($sensorName, array_keys($this->tempSensors)) ){
|
|
||||||
/** @var \DOMNodeList $element */
|
|
||||||
$valueElement = $documentXpath->query($xpathValueQuery, $item->parentNode->parentNode);
|
|
||||||
$thing[$this->tempSensors[$sensorName]] = $this->getTempNumber($valueElement->item(0)->nodeValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $thing;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $temperatureString
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
private function getTempNumber(string $temperatureString): float
|
|
||||||
{
|
|
||||||
preg_match('#([0-9,]+) C#msiu', $temperatureString, $temperatureMatches);
|
|
||||||
return floatval(str_replace(",", ".", $temperatureMatches[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use Interop\Container\ContainerInterface;
|
|
||||||
use Zend\Config\Config;
|
|
||||||
use Zend\Http\Client;
|
|
||||||
|
|
||||||
class LabInfoCollectorServiceFactory
|
|
||||||
{
|
|
||||||
public function __invoke(ContainerInterface $container)
|
|
||||||
{
|
|
||||||
$configArray = $container->get('config');
|
|
||||||
$httpClient = $container->get(Client::class);
|
|
||||||
$config = new Config($configArray['app.config']);
|
|
||||||
return new LabInfoCollectorService($httpClient, $config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,187 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use App\Entity\TrProgress;
|
|
||||||
use League\Csv\Reader;
|
|
||||||
use League\Csv\Statement;
|
|
||||||
use Zend\Config\Config;
|
|
||||||
use Zend\Http\Client;
|
|
||||||
|
|
||||||
class TrInfoCollectorService
|
|
||||||
{
|
|
||||||
const UNIT_CORE = 'core';
|
|
||||||
const UNIT_SIG = 'sig';
|
|
||||||
const UNIT_TADE = 'tade';
|
|
||||||
|
|
||||||
const MHO_MAP = [
|
|
||||||
'ETH-TSPCW-D' => self::UNIT_CORE,
|
|
||||||
'ETH-TSPCORE' => self::UNIT_CORE,
|
|
||||||
'XTS-TSP-SIG' => self::UNIT_SIG,
|
|
||||||
'XTS-TSPSIGD' => self::UNIT_SIG,
|
|
||||||
'ETH-TADE-DE' => self::UNIT_TADE,
|
|
||||||
'ETH-TADE-MA' => self::UNIT_TADE,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Config
|
|
||||||
*/
|
|
||||||
private $config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Client
|
|
||||||
*/
|
|
||||||
private $httpClient;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JiraClientService constructor.
|
|
||||||
* @param Client $client
|
|
||||||
* @param Config $config
|
|
||||||
*/
|
|
||||||
public function __construct(Client $client, Config $config)
|
|
||||||
{
|
|
||||||
$this->httpClient = $client;
|
|
||||||
$this->config = $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* < 700 daily progress
|
|
||||||
* * weekly
|
|
||||||
* @return array
|
|
||||||
* @todo calculate progress late stuff
|
|
||||||
*/
|
|
||||||
public function getProgressInfo()
|
|
||||||
{
|
|
||||||
$user = $this->config->get('mhweb.user');
|
|
||||||
$password = $this->config->get('mhweb.password');
|
|
||||||
/** @var string $trProgressUri */
|
|
||||||
$trProgressUri = $this->config->get('url.mhWebTrProgress');
|
|
||||||
|
|
||||||
$response = $this->httpClient
|
|
||||||
->setAuth($user, $password)
|
|
||||||
->setUri($trProgressUri)
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if (!$response->isSuccess()) {
|
|
||||||
throw new \UnexpectedValueException("Bad MHWEB result", $response->getStatusCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
$csvResponse = $response->getBody();
|
|
||||||
$csvReader = Reader::createFromString($csvResponse);
|
|
||||||
$csvReader->setHeaderOffset(0);
|
|
||||||
|
|
||||||
return $this->parseProgressCsvRecords($csvReader);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPraGoals()
|
|
||||||
{
|
|
||||||
$user = $this->config->get('mhweb.user');
|
|
||||||
$password = $this->config->get('mhweb.password');
|
|
||||||
/** @var string $trProgressUri */
|
|
||||||
$trProgressUri = $this->config->get('url.mhWebPraGoals');
|
|
||||||
|
|
||||||
$response = $this->httpClient
|
|
||||||
->setAuth($user, $password)
|
|
||||||
->setUri($trProgressUri)
|
|
||||||
->send();
|
|
||||||
|
|
||||||
if (!$response->isSuccess()) {
|
|
||||||
throw new \UnexpectedValueException("Bad MHWEB result", $response->getStatusCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
$csvResponse = $response->getBody();
|
|
||||||
$csvReader = Reader::createFromString($csvResponse);
|
|
||||||
$csvReader->setHeaderOffset(0);
|
|
||||||
|
|
||||||
$statement = new Statement();
|
|
||||||
$csvRecords = $statement
|
|
||||||
->process($csvReader);
|
|
||||||
|
|
||||||
$goalCounter = $this->initGoalCounter();
|
|
||||||
|
|
||||||
foreach ($csvRecords as $record) {
|
|
||||||
$goalCounter[self::MHO_MAP[$record["mho"]]][$record["prio"]]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->caltulatePraBaseDiff($goalCounter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function caltulatePraBaseDiff($goalCounter): array
|
|
||||||
{
|
|
||||||
$praBaseData = $this->config->get('pra.baseData')->toArray();
|
|
||||||
foreach ($goalCounter as $mho => &$counters) {
|
|
||||||
foreach (['A', 'B', 'C'] as $prio) {
|
|
||||||
$counters[$prio] = $counters[$prio] - $praBaseData[$prio][$mho];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $goalCounter;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function parseProgressCsvRecords(Reader $csvReader)
|
|
||||||
{
|
|
||||||
$teamMembers = $this->config->get('team.members')->toArray();
|
|
||||||
$statement = new Statement();
|
|
||||||
$csvRecords = $statement
|
|
||||||
->where(function($record) use ($teamMembers) {
|
|
||||||
return in_array(strtolower($record['owner']), $teamMembers);
|
|
||||||
})
|
|
||||||
->process($csvReader);
|
|
||||||
|
|
||||||
$trProgressList = [];
|
|
||||||
foreach ($csvRecords as $csvRecord) {
|
|
||||||
$trProgress = new TrProgress();
|
|
||||||
$trProgress->setEriref($csvRecord["eriref"])
|
|
||||||
->setHeading($csvRecord["heading"])
|
|
||||||
->setPrio($csvRecord["prio"])
|
|
||||||
->setLastProgressInDays($this->getLastProgressInDay($csvRecord))
|
|
||||||
;
|
|
||||||
$trProgressList[] = $trProgress;
|
|
||||||
}
|
|
||||||
|
|
||||||
usort($trProgressList, function(TrProgress $a, TrProgress $b){
|
|
||||||
return $b->getLastProgressInDays() <=> $a->getLastProgressInDays();
|
|
||||||
});
|
|
||||||
|
|
||||||
return $trProgressList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $csvRecord
|
|
||||||
* @return int
|
|
||||||
* @todo fix the BS with tuesday or whatever
|
|
||||||
*/
|
|
||||||
private function getLastProgressInDay(array $csvRecord): int
|
|
||||||
{
|
|
||||||
$lastProgressDate = null;
|
|
||||||
$hasNoProgressDate = false;
|
|
||||||
try {
|
|
||||||
$lastProgressDate = new \DateTime(str_replace(" - "," ", $csvRecord["lastprogressdate"]));
|
|
||||||
} catch(\Exception $e) {
|
|
||||||
$hasNoProgressDate = true;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
$lastDesignDate = new \DateTime($csvRecord["lastdesigndate"]);
|
|
||||||
if($hasNoProgressDate || $lastDesignDate > $lastProgressDate) {
|
|
||||||
$lastProgressDate = $lastDesignDate;
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
if($hasNoProgressDate) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$now = new \DateTime();
|
|
||||||
$dateDiff = $now->diff($lastProgressDate);
|
|
||||||
return $dateDiff->days;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function initGoalCounter(): array
|
|
||||||
{
|
|
||||||
$emptyPrios = ['A' => 0, 'B' => 0, 'C' => 0];
|
|
||||||
return [
|
|
||||||
self::UNIT_CORE => $emptyPrios,
|
|
||||||
self::UNIT_SIG => $emptyPrios,
|
|
||||||
self::UNIT_TADE => $emptyPrios,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use Interop\Container\ContainerInterface;
|
|
||||||
use Zend\Config\Config;
|
|
||||||
use Zend\Http\Client;
|
|
||||||
|
|
||||||
class TrInfoCollectorServiceFactory
|
|
||||||
{
|
|
||||||
public function __invoke(ContainerInterface $container)
|
|
||||||
{
|
|
||||||
$configArray = $container->get('config');
|
|
||||||
$httpClient = $container->get(Client::class);
|
|
||||||
$config = new Config($configArray['app.config']);
|
|
||||||
return new TrInfoCollectorService($httpClient, $config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,81 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use Zend\Cache\Storage\StorageInterface;
|
|
||||||
|
|
||||||
class TspInfoService
|
|
||||||
{
|
|
||||||
|
|
||||||
const CACHE_KEY = 'tspInfo';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var StorageInterface
|
|
||||||
*/
|
|
||||||
private $cache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var VacationInfoCollectorService
|
|
||||||
*/
|
|
||||||
private $vacationInfoCollectorService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TrInfoCollectorService
|
|
||||||
*/
|
|
||||||
private $trInfoCollectorService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var JcatInfoCollectorService
|
|
||||||
*/
|
|
||||||
private $jcatInfoCollectorService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var LabInfoCollectorService
|
|
||||||
*/
|
|
||||||
private $labInfoCollectorService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var JiraCollectorService
|
|
||||||
*/
|
|
||||||
private $jiraCollectorService;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
StorageInterface $cache,
|
|
||||||
VacationInfoCollectorService $vacationInfoCollectorService,
|
|
||||||
TrInfoCollectorService $trInfoCollectorService,
|
|
||||||
JcatInfoCollectorService $jcatInfoCollectorService,
|
|
||||||
LabInfoCollectorService $labInfoCollectorService,
|
|
||||||
JiraCollectorService $jiraCollectorService
|
|
||||||
)
|
|
||||||
{
|
|
||||||
$this->cache = $cache;
|
|
||||||
$this->vacationInfoCollectorService = $vacationInfoCollectorService;
|
|
||||||
$this->trInfoCollectorService = $trInfoCollectorService;
|
|
||||||
$this->jcatInfoCollectorService = $jcatInfoCollectorService;
|
|
||||||
$this->labInfoCollectorService = $labInfoCollectorService;
|
|
||||||
$this->jiraCollectorService = $jiraCollectorService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param bool $forceReload
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getTspInfo(bool $forceReload = false): array
|
|
||||||
{
|
|
||||||
$tspInfo = $this->cache->getItem(self::CACHE_KEY);
|
|
||||||
if($forceReload || null == $tspInfo) {
|
|
||||||
$tspInfo = [
|
|
||||||
'praGoals' => $this->trInfoCollectorService->getPraGoals(),
|
|
||||||
'trProgressInfo' => $this->trInfoCollectorService->getProgressInfo(),
|
|
||||||
'trFlowErrors' => $this->jcatInfoCollectorService->getTrFlowErrors(),
|
|
||||||
'expedites' => $this->jiraCollectorService->getExpedites(),
|
|
||||||
// 'isVacationSoon' => $this->vacationInfoCollectorService->isVacationSoon(),
|
|
||||||
// 'labTemperature' => $this->labInfoCollectorService->getLabTemperatureData(),
|
|
||||||
];
|
|
||||||
$this->cache->setItem(self::CACHE_KEY, serialize($tspInfo));
|
|
||||||
} else {
|
|
||||||
$tspInfo = unserialize($tspInfo);
|
|
||||||
}
|
|
||||||
return $tspInfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use Interop\Container\ContainerInterface;
|
|
||||||
use Zend\Config\Config;
|
|
||||||
use Zend\Http\Client;
|
|
||||||
|
|
||||||
class TspInfoServiceFactory
|
|
||||||
{
|
|
||||||
public function __invoke(ContainerInterface $container)
|
|
||||||
{
|
|
||||||
$cache = $container->get('service.cache');
|
|
||||||
$dataCollectorService = $container->get(VacationInfoCollectorService::class);
|
|
||||||
$trInfoCollectorService = $container->get(TrInfoCollectorService::class);
|
|
||||||
$jcatInfoCollectorService = $container->get(JcatInfoCollectorService::class);
|
|
||||||
$labInfoCollectorService = $container->get(LabInfoCollectorService::class);
|
|
||||||
$jiraInfoCollectorService = $container->get(JiraCollectorService::class);
|
|
||||||
return new TspInfoService(
|
|
||||||
$cache,
|
|
||||||
$dataCollectorService,
|
|
||||||
$trInfoCollectorService,
|
|
||||||
$jcatInfoCollectorService,
|
|
||||||
$labInfoCollectorService,
|
|
||||||
$jiraInfoCollectorService
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user