* 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);
}
}