* tsp-info parts added

This commit is contained in:
Dávid Danyi
2017-09-08 09:44:30 +02:00
parent efc6e7b0c4
commit d10ebb4931
7 changed files with 87 additions and 23 deletions

View File

@@ -31,7 +31,7 @@ class JcatInfoCollectorService
$this->config = $config;
}
public function getTrFlow()
public function getTrFlowErrors()
{
/** @var Config $kanbanBoardUriParams */
$trFlowUri = $this->config->get('url.jcatTrFlow');
@@ -47,8 +47,13 @@ class JcatInfoCollectorService
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);
@@ -62,9 +67,21 @@ class JcatInfoCollectorService
$result = [];
/** @var \DOMElement $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);
}
}

View File

@@ -38,6 +38,9 @@ class LabInfoCollectorService
$this->config = $config;
}
/**
* @return array
*/
public function getLabTemperatureData()
{
/** @var Config $labTemperatureUrl */
@@ -54,6 +57,10 @@ class LabInfoCollectorService
return $this->parseHtml($response->getBody());
}
/**
* @param $html
* @return array
*/
private function parseHtml($html): array
{
$cssToXpathConverter = new CssSelectorConverter();
@@ -77,10 +84,20 @@ class LabInfoCollectorService
if( in_array($sensorName, array_keys($this->tempSensors)) ){
/** @var \DOMNodeList $element */
$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;
}
/**
* @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]));
}
}

View File

@@ -45,7 +45,10 @@ class TrInfoCollectorService
}
/**
* < 700 daily progress
* * weekly
* @return array
* @todo calculate progress late stuff
*/
public function getProgressInfo()
{
@@ -105,10 +108,10 @@ class TrInfoCollectorService
private function caltulatePraBaseDiff($goalCounter): array
{
$praBaseData = $this->config->get('pra.baseData');
$praBaseData = $this->config->get('pra.baseData')->toArray();
foreach ($goalCounter as $mho => &$counters) {
foreach (['A', 'B', 'C'] as $prio) {
$counters[$prio] = $counters[$prio] - $praBaseData[$mho][$prio];
$counters[$prio] = $counters[$prio] - $praBaseData[$prio][$mho];
}
}
return $goalCounter;
@@ -116,25 +119,27 @@ class TrInfoCollectorService
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"])
->setLastProgress($this->getLastProgressInDay($csvRecord))
->setLastProgressInDays($this->getLastProgressInDay($csvRecord))
;
$trProgressList[] = $trProgress;
}
usort($trProgressList, function(TrProgress $a, TrProgress $b){
return $b->getLastProgress() <=> $a->getLastProgress();
return $b->getLastProgressInDays() <=> $a->getLastProgressInDays();
});
return $trProgressList;