From 6e823bc0ea791b0559bafdc2beb04376dda4b5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Danyi?= Date: Wed, 29 Mar 2017 14:26:51 +0200 Subject: [PATCH] * result reformatted to new style in nightly --- src/App/Action/NightlyByStreamsAction.php | 2 +- src/App/Service/CiExecutorService.php | 26 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/App/Action/NightlyByStreamsAction.php b/src/App/Action/NightlyByStreamsAction.php index e475526..5ab827d 100644 --- a/src/App/Action/NightlyByStreamsAction.php +++ b/src/App/Action/NightlyByStreamsAction.php @@ -22,6 +22,6 @@ class NightlyByStreamsAction extends AbstractAction public function getList(ServerRequestInterface $request, ResponseInterface $response, callable $next = null) { - return new JsonCorsResponse($this->ciExecutorService->getActiveNightlyConfiguration()); + return new JsonCorsResponse($this->ciExecutorService->getActiveNightlyConfigurationByStream()); } } diff --git a/src/App/Service/CiExecutorService.php b/src/App/Service/CiExecutorService.php index 451ad03..ef43e53 100644 --- a/src/App/Service/CiExecutorService.php +++ b/src/App/Service/CiExecutorService.php @@ -696,16 +696,36 @@ class CiExecutorService public function getActiveNightlyConfigurationByNode(bool $forceReload = false) { $activeNightlyByStream = $this->getActiveNightlyConfiguration($forceReload); - $configByNodes = []; + $reorderedConfig = []; foreach ($activeNightlyByStream as $stream => $nodes) { foreach($nodes as $node) { - if(!isset($configByNodes[$node])) { $configByNodes[$node] = []; } - array_push($configByNodes[$node], $stream); + if(!isset($reorderedConfig[$node])) { $reorderedConfig[$node] = []; } + array_push($reorderedConfig[$node], $stream); } } + $configByNodes = []; + foreach ($reorderedConfig as $node => $streams) { + $configByNodes[] = [ + 'node' => $node, + 'streams' => $streams, + ]; + } return $configByNodes; } + public function getActiveNightlyConfigurationByStream(bool $forceReload = false) + { + $activeNightlyByStream = $this->getActiveNightlyConfiguration($forceReload); + $configByStream = []; + foreach ($activeNightlyByStream as $stream => $nodes) { + $configByStream[] = [ + 'stream' => $stream, + 'nodes' => $nodes, + ]; + } + return $configByStream; + } + public function getActiveNightlyConfiguration(bool $forceReload = false) { $cache = $this->getCache(self::NIGHTLY_CACHE_KEY);