* tsp-info parts added
This commit is contained in:
parent
efc6e7b0c4
commit
d10ebb4931
@ -15,6 +15,17 @@ return [
|
|||||||
'mhweb.user' => '...',
|
'mhweb.user' => '...',
|
||||||
'mhweb.password' => '...',
|
'mhweb.password' => '...',
|
||||||
|
|
||||||
|
'team.members' => [
|
||||||
|
'ebalcse',
|
||||||
|
'edvidan',
|
||||||
|
'efersip',
|
||||||
|
'emakazi',
|
||||||
|
'enorsos',
|
||||||
|
'epetfid',
|
||||||
|
'eroroba',
|
||||||
|
'esndkov',
|
||||||
|
],
|
||||||
|
|
||||||
'pra.baseData' => [
|
'pra.baseData' => [
|
||||||
'A' => [
|
'A' => [
|
||||||
TrInfo::UNIT_CORE => 0,
|
TrInfo::UNIT_CORE => 0,
|
||||||
@ -70,7 +81,10 @@ return [
|
|||||||
'url.vacation' => 'https://rhp.common.hu.eld.ericsson.se/vacation.php?action=groupview&dm_h=2&dm_v=1&group_id=478',
|
'url.vacation' => 'https://rhp.common.hu.eld.ericsson.se/vacation.php?action=groupview&dm_h=2&dm_v=1&group_id=478',
|
||||||
'url.jcatTrFlow' => "http://jcat.tsp.eth.ericsson.se:8080/Trweb/trflow/reader.php?query=SELECT+*+FROM+trinfo+where+validationerrors+!=+''",
|
'url.jcatTrFlow' => "http://jcat.tsp.eth.ericsson.se:8080/Trweb/trflow/reader.php?query=SELECT+*+FROM+trinfo+where+validationerrors+!=+''",
|
||||||
|
|
||||||
'url.eurestCamera2' => 'https://auto:auto@91.82.89.112:8443/mjpg/video.mjpg',
|
'url.eurestCameras' => [
|
||||||
|
'https://user:user@91.82.89.112/mjpg/video.mjpg',
|
||||||
|
'https://user:user@91.82.89.112:8443/mjpg/video.mjpg',
|
||||||
|
],
|
||||||
|
|
||||||
'http.proxy.enabled' => false,
|
'http.proxy.enabled' => false,
|
||||||
'http.proxy.type' => CURLPROXY_SOCKS5,
|
'http.proxy.type' => CURLPROXY_SOCKS5,
|
||||||
|
|||||||
@ -11,9 +11,15 @@ use App\Service\VacationInfoCollectorService;
|
|||||||
use Interop\Http\ServerMiddleware\DelegateInterface;
|
use Interop\Http\ServerMiddleware\DelegateInterface;
|
||||||
use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface;
|
use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Zend\Config\Config;
|
||||||
|
|
||||||
class TspInfoAction implements ServerMiddlewareInterface
|
class TspInfoAction implements ServerMiddlewareInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var Config
|
||||||
|
*/
|
||||||
|
private $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var VacationInfoCollectorService
|
* @var VacationInfoCollectorService
|
||||||
*/
|
*/
|
||||||
@ -39,12 +45,14 @@ class TspInfoAction implements ServerMiddlewareInterface
|
|||||||
*/
|
*/
|
||||||
private $jiraCollectorService;
|
private $jiraCollectorService;
|
||||||
|
|
||||||
public function __construct(VacationInfoCollectorService $vacationInfoCollectorService,
|
public function __construct(Config $config,
|
||||||
|
VacationInfoCollectorService $vacationInfoCollectorService,
|
||||||
TrInfoCollectorService $trInfoCollectorService,
|
TrInfoCollectorService $trInfoCollectorService,
|
||||||
JcatInfoCollectorService $jcatInfoCollectorService,
|
JcatInfoCollectorService $jcatInfoCollectorService,
|
||||||
LabInfoCollectorService $labInfoCollectorService,
|
LabInfoCollectorService $labInfoCollectorService,
|
||||||
JiraCollectorService $jiraCollectorService)
|
JiraCollectorService $jiraCollectorService)
|
||||||
{
|
{
|
||||||
|
$this->config = $config;
|
||||||
$this->vacationInfoCollectorService = $vacationInfoCollectorService;
|
$this->vacationInfoCollectorService = $vacationInfoCollectorService;
|
||||||
$this->trInfoCollectorService = $trInfoCollectorService;
|
$this->trInfoCollectorService = $trInfoCollectorService;
|
||||||
$this->jcatInfoCollectorService = $jcatInfoCollectorService;
|
$this->jcatInfoCollectorService = $jcatInfoCollectorService;
|
||||||
@ -56,17 +64,17 @@ class TspInfoAction implements ServerMiddlewareInterface
|
|||||||
* @param ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param DelegateInterface $delegate
|
* @param DelegateInterface $delegate
|
||||||
* @return JsonCorsResponse
|
* @return JsonCorsResponse
|
||||||
* @todo lab temperature data
|
|
||||||
*/
|
*/
|
||||||
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
|
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
|
||||||
{
|
{
|
||||||
return new JsonCorsResponse([
|
return new JsonCorsResponse([
|
||||||
|
'cameraUrls' => $this->config->get('url.eurestCameras')->toArray(),
|
||||||
'animGifs' => [],
|
'animGifs' => [],
|
||||||
'praGoals' => $this->trInfoCollectorService->getPraGoals(),
|
'praGoals' => $this->trInfoCollectorService->getPraGoals(),
|
||||||
'trProgress' => $this->trInfoCollectorService->getProgressInfo(),
|
'trProgressInfo' => $this->trInfoCollectorService->getProgressInfo(),
|
||||||
'trFlow' => $this->jcatInfoCollectorService->getTrFlow(),
|
'trFlowErrors' => $this->jcatInfoCollectorService->getTrFlowErrors(),
|
||||||
'expedites' => $this->jiraCollectorService->getExpedites(),
|
'expedites' => $this->jiraCollectorService->getExpedites(),
|
||||||
'vacationInfo' => $this->vacationInfoCollectorService->isVacationSoon(),
|
'isVacationSoon' => $this->vacationInfoCollectorService->isVacationSoon(),
|
||||||
'labTemperature' => $this->labInfoCollectorService->getLabTemperatureData(),
|
'labTemperature' => $this->labInfoCollectorService->getLabTemperatureData(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,11 +8,13 @@ use App\Service\LabInfoCollectorService;
|
|||||||
use App\Service\TrInfoCollectorService;
|
use App\Service\TrInfoCollectorService;
|
||||||
use App\Service\VacationInfoCollectorService;
|
use App\Service\VacationInfoCollectorService;
|
||||||
use Interop\Container\ContainerInterface;
|
use Interop\Container\ContainerInterface;
|
||||||
|
use Zend\Config\Config;
|
||||||
|
|
||||||
class TspInfoFactory
|
class TspInfoFactory
|
||||||
{
|
{
|
||||||
public function __invoke(ContainerInterface $container)
|
public function __invoke(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
|
$appConfig = $container->get('config')['app.config'];
|
||||||
$dataCollectorService = $container->get(VacationInfoCollectorService::class);
|
$dataCollectorService = $container->get(VacationInfoCollectorService::class);
|
||||||
$trInfoCollectorService = $container->get(TrInfoCollectorService::class);
|
$trInfoCollectorService = $container->get(TrInfoCollectorService::class);
|
||||||
$jcatInfoCollectorService = $container->get(JcatInfoCollectorService::class);
|
$jcatInfoCollectorService = $container->get(JcatInfoCollectorService::class);
|
||||||
@ -20,6 +22,7 @@ class TspInfoFactory
|
|||||||
$jiraInfoCollectorService = $container->get(JiraCollectorService::class);
|
$jiraInfoCollectorService = $container->get(JiraCollectorService::class);
|
||||||
|
|
||||||
return new TspInfoAction(
|
return new TspInfoAction(
|
||||||
|
new Config($appConfig),
|
||||||
$dataCollectorService,
|
$dataCollectorService,
|
||||||
$trInfoCollectorService,
|
$trInfoCollectorService,
|
||||||
$jcatInfoCollectorService,
|
$jcatInfoCollectorService,
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class TrProgress implements \JsonSerializable
|
|||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $lastProgress;
|
private $lastProgressInDays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
@ -82,18 +82,18 @@ class TrProgress implements \JsonSerializable
|
|||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getLastProgress(): int
|
public function getLastProgressInDays(): int
|
||||||
{
|
{
|
||||||
return $this->lastProgress;
|
return $this->lastProgressInDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $lastProgress
|
* @param int $lastProgressInDays
|
||||||
* @return TrProgress
|
* @return TrProgress
|
||||||
*/
|
*/
|
||||||
public function setLastProgress(int $lastProgress): TrProgress
|
public function setLastProgressInDays(int $lastProgressInDays): TrProgress
|
||||||
{
|
{
|
||||||
$this->lastProgress = $lastProgress;
|
$this->lastProgressInDays = $lastProgressInDays;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ class TrProgress implements \JsonSerializable
|
|||||||
'eriref' => $this->getEriref(),
|
'eriref' => $this->getEriref(),
|
||||||
'heading' => $this->getHeading(),
|
'heading' => $this->getHeading(),
|
||||||
'prio' => $this->getPrio(),
|
'prio' => $this->getPrio(),
|
||||||
'lastProgress' => $this->getLastProgress(),
|
'lastProgressInDays' => $this->getLastProgressInDays(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class JcatInfoCollectorService
|
|||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTrFlow()
|
public function getTrFlowErrors()
|
||||||
{
|
{
|
||||||
/** @var Config $kanbanBoardUriParams */
|
/** @var Config $kanbanBoardUriParams */
|
||||||
$trFlowUri = $this->config->get('url.jcatTrFlow');
|
$trFlowUri = $this->config->get('url.jcatTrFlow');
|
||||||
@ -47,8 +47,13 @@ class JcatInfoCollectorService
|
|||||||
return $this->parseFlowHtmlResult($response->getBody());
|
return $this->parseFlowHtmlResult($response->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $html
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
private function parseFlowHtmlResult(string $html)
|
private function parseFlowHtmlResult(string $html)
|
||||||
{
|
{
|
||||||
|
$teamMembers = $this->config->get('team.members')->toArray();
|
||||||
$xmlErrorHandling = libxml_use_internal_errors(TRUE);
|
$xmlErrorHandling = libxml_use_internal_errors(TRUE);
|
||||||
$domDocument = new \DOMDocument();
|
$domDocument = new \DOMDocument();
|
||||||
$domDocument->loadHTML($html);
|
$domDocument->loadHTML($html);
|
||||||
@ -62,9 +67,21 @@ class JcatInfoCollectorService
|
|||||||
$result = [];
|
$result = [];
|
||||||
/** @var \DOMElement $element */
|
/** @var \DOMElement $element */
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
$result[] = trim($element->nodeValue);
|
/** @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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_count_values($result);
|
$errorsCounted = array_count_values($result);
|
||||||
|
|
||||||
|
return array_map(function($type, $count) {
|
||||||
|
return [
|
||||||
|
'label' => $type,
|
||||||
|
'value' => $count,
|
||||||
|
];
|
||||||
|
}, array_keys($errorsCounted), $errorsCounted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,9 @@ class LabInfoCollectorService
|
|||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getLabTemperatureData()
|
public function getLabTemperatureData()
|
||||||
{
|
{
|
||||||
/** @var Config $labTemperatureUrl */
|
/** @var Config $labTemperatureUrl */
|
||||||
@ -54,6 +57,10 @@ class LabInfoCollectorService
|
|||||||
return $this->parseHtml($response->getBody());
|
return $this->parseHtml($response->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $html
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
private function parseHtml($html): array
|
private function parseHtml($html): array
|
||||||
{
|
{
|
||||||
$cssToXpathConverter = new CssSelectorConverter();
|
$cssToXpathConverter = new CssSelectorConverter();
|
||||||
@ -77,10 +84,20 @@ class LabInfoCollectorService
|
|||||||
if( in_array($sensorName, array_keys($this->tempSensors)) ){
|
if( in_array($sensorName, array_keys($this->tempSensors)) ){
|
||||||
/** @var \DOMNodeList $element */
|
/** @var \DOMNodeList $element */
|
||||||
$valueElement = $documentXpath->query($xpathValueQuery, $item->parentNode->parentNode);
|
$valueElement = $documentXpath->query($xpathValueQuery, $item->parentNode->parentNode);
|
||||||
$thing[$this->tempSensors[$sensorName]] = $valueElement->item(0)->nodeValue;
|
$thing[$this->tempSensors[$sensorName]] = $this->getTempNumber($valueElement->item(0)->nodeValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $thing;
|
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]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,10 @@ class TrInfoCollectorService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* < 700 daily progress
|
||||||
|
* * weekly
|
||||||
* @return array
|
* @return array
|
||||||
|
* @todo calculate progress late stuff
|
||||||
*/
|
*/
|
||||||
public function getProgressInfo()
|
public function getProgressInfo()
|
||||||
{
|
{
|
||||||
@ -105,10 +108,10 @@ class TrInfoCollectorService
|
|||||||
|
|
||||||
private function caltulatePraBaseDiff($goalCounter): array
|
private function caltulatePraBaseDiff($goalCounter): array
|
||||||
{
|
{
|
||||||
$praBaseData = $this->config->get('pra.baseData');
|
$praBaseData = $this->config->get('pra.baseData')->toArray();
|
||||||
foreach ($goalCounter as $mho => &$counters) {
|
foreach ($goalCounter as $mho => &$counters) {
|
||||||
foreach (['A', 'B', 'C'] as $prio) {
|
foreach (['A', 'B', 'C'] as $prio) {
|
||||||
$counters[$prio] = $counters[$prio] - $praBaseData[$mho][$prio];
|
$counters[$prio] = $counters[$prio] - $praBaseData[$prio][$mho];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $goalCounter;
|
return $goalCounter;
|
||||||
@ -116,25 +119,27 @@ class TrInfoCollectorService
|
|||||||
|
|
||||||
private function parseProgressCsvRecords(Reader $csvReader)
|
private function parseProgressCsvRecords(Reader $csvReader)
|
||||||
{
|
{
|
||||||
|
$teamMembers = $this->config->get('team.members')->toArray();
|
||||||
$statement = new Statement();
|
$statement = new Statement();
|
||||||
$csvRecords = $statement
|
$csvRecords = $statement
|
||||||
|
->where(function($record) use ($teamMembers) {
|
||||||
|
return in_array(strtolower($record['owner']), $teamMembers);
|
||||||
|
})
|
||||||
->process($csvReader);
|
->process($csvReader);
|
||||||
|
|
||||||
$trProgressList = [];
|
$trProgressList = [];
|
||||||
|
|
||||||
foreach ($csvRecords as $csvRecord) {
|
foreach ($csvRecords as $csvRecord) {
|
||||||
$trProgress = new TrProgress();
|
$trProgress = new TrProgress();
|
||||||
$trProgress->setEriref($csvRecord["eriref"])
|
$trProgress->setEriref($csvRecord["eriref"])
|
||||||
->setHeading($csvRecord["heading"])
|
->setHeading($csvRecord["heading"])
|
||||||
->setPrio($csvRecord["prio"])
|
->setPrio($csvRecord["prio"])
|
||||||
->setLastProgress($this->getLastProgressInDay($csvRecord))
|
->setLastProgressInDays($this->getLastProgressInDay($csvRecord))
|
||||||
;
|
;
|
||||||
|
|
||||||
$trProgressList[] = $trProgress;
|
$trProgressList[] = $trProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
usort($trProgressList, function(TrProgress $a, TrProgress $b){
|
usort($trProgressList, function(TrProgress $a, TrProgress $b){
|
||||||
return $b->getLastProgress() <=> $a->getLastProgress();
|
return $b->getLastProgressInDays() <=> $a->getLastProgressInDays();
|
||||||
});
|
});
|
||||||
|
|
||||||
return $trProgressList;
|
return $trProgressList;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user