Skip to content
Snippets Groups Projects
Commit 7ca84439 authored by Tibo's avatar Tibo
Browse files

handle trigger_label as a regex to show the graph of detectors

parent 881b47cf
No related branches found
No related tags found
No related merge requests found
Pipeline #4518 passed
......@@ -98,22 +98,50 @@ class MarkController extends Controller
public function rankingHome()
{
$activation_graph_elements = [];
$activation = $this->server()->activation();
foreach ($activation as $detector) {
// nodes
$detectors = $this->server()->activation();
// nodes
foreach ($detectors as $detector) {
// node
$activation_graph_elements[] = ["data" => ["id" => $detector->label]];
$activation_graph_elements[] = ["data" => ["id" => $detector->trigger_label]];
// edges
$activation_graph_elements[] = ["data" => [
"id" => rand(),
"source" => $detector->trigger_label,
"target" => $detector->label]];
$sources = $this->findSources($detectors, $detector);
foreach ($sources as $source) {
$activation_graph_elements[] = ["data" => [
"id" => rand(),
"source" => $source,
"target" => $detector->label]];
}
if (count($sources) == 0) {
// the trigger_label for this detector is a data source
// => create node + edge
$activation_graph_elements[] = ["data" => ["id" => $detector->trigger_label]];
$activation_graph_elements[] = ["data" => [
"id" => rand(),
"source" => $detector->trigger_label,
"target" => $detector->label]];
}
}
return view("app.detectors", ["activation_graph_elements" => $activation_graph_elements]);
}
private function findSources(array $all_detectors, $detector)
{
$pattern = '/' . $detector->trigger_label . '/';
$sources = [];
foreach ($all_detectors as $d) {
if (preg_match($pattern, $d->label)) {
$sources[] = $d->label;
}
}
return $sources;
}
public function extractPoints(array $evidences, string $field) : array
{
$points = [];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment