diff --git a/README.md b/README.md index 56590355c..6740582ec 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ NOTE: PDO may not support all the features of XHGui, see [#320]. > db.results.ensureIndex( { 'profile.main().cpu' : -1 } ) > db.results.ensureIndex( { 'meta.url' : 1 } ) > db.results.ensureIndex( { 'meta.simple_url' : 1 } ) + > db.results.ensureIndex( { 'meta.SERVER.SERVER_NAME' : 1 } ) ``` 7. Install dependencies with composer @@ -271,11 +272,13 @@ storage.) | Searcher::getAllWatches() | ✓ | ✓ [#435] | | Searcher::truncateWatches() | ✓ | ✓ [#435] | | Searcher::stats() | ✗ [#305] | ✓ | +| Searcher::getAllServerNames() | ✓ [#460] | ✗ | [#305]: https://github.com/perftools/xhgui/pull/305 [#384]: https://github.com/perftools/xhgui/pull/384 [#435]: https://github.com/perftools/xhgui/pull/435 [#436]: https://github.com/perftools/xhgui/pull/436 +[#460]: https://github.com/perftools/xhgui/pull/460 # Releases / Changelog diff --git a/mongo.init.d/xhgui.js b/mongo.init.d/xhgui.js index c386fca36..09472b510 100644 --- a/mongo.init.d/xhgui.js +++ b/mongo.init.d/xhgui.js @@ -3,3 +3,4 @@ db.results.ensureIndex( { 'profile.main().wt' : -1 } ); db.results.ensureIndex( { 'profile.main().mu' : -1 } ); db.results.ensureIndex( { 'profile.main().cpu' : -1 } ); db.results.ensureIndex( { 'meta.url' : 1 } ); +db.results.ensureIndex( { 'meta.SERVER.SERVER_NAME' : 1 } ); diff --git a/src/Controller/RunController.php b/src/Controller/RunController.php index c7db7a244..14def25de 100644 --- a/src/Controller/RunController.php +++ b/src/Controller/RunController.php @@ -47,6 +47,8 @@ public function index(Request $request): void 'projection' => true, ])); + $serverNames = $this->searcher->getAllServerNames(); + $title = 'Recent runs'; $titleMap = [ 'wt' => 'Longest wall time', @@ -71,6 +73,7 @@ public function index(Request $request): void 'search' => $search, 'has_search' => implode('', $search) !== '', 'title' => $title, + 'server_names' => $serverNames, ]); } diff --git a/src/Searcher/MongoSearcher.php b/src/Searcher/MongoSearcher.php index e5bcd9a30..39229297c 100644 --- a/src/Searcher/MongoSearcher.php +++ b/src/Searcher/MongoSearcher.php @@ -364,4 +364,12 @@ public function stats(): array 'bytes' => 0, ]; } + + /** + * {@inheritdoc} + */ + public function getAllServerNames(): ?array + { + return $this->_collection->distinct('meta.SERVER.SERVER_NAME'); + } } diff --git a/src/Searcher/PdoSearcher.php b/src/Searcher/PdoSearcher.php index 836208a42..617248f05 100644 --- a/src/Searcher/PdoSearcher.php +++ b/src/Searcher/PdoSearcher.php @@ -226,6 +226,14 @@ public function stats() return $row; } + /** + * {@inheritdoc} + */ + public function getAllServerNames(): ?array + { + return null; + } + /** * {@inheritdoc} */ diff --git a/src/Searcher/SearcherInterface.php b/src/Searcher/SearcherInterface.php index 8444204f6..f71dfcba9 100644 --- a/src/Searcher/SearcherInterface.php +++ b/src/Searcher/SearcherInterface.php @@ -140,4 +140,11 @@ public function truncateWatches(); * @return array array of stats */ public function stats(); + + /** + * Get all the known server names. + * + * @return array|null array of server names or null if not supported + */ + public function getAllServerNames(): ?array; } diff --git a/templates/runs/list.twig b/templates/runs/list.twig index 90e763988..95ad82192 100644 --- a/templates/runs/list.twig +++ b/templates/runs/list.twig @@ -30,7 +30,16 @@