Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add selectbox for server name #460

Merged
merged 1 commit into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions mongo.init.d/xhgui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } );
3 changes: 3 additions & 0 deletions src/Controller/RunController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public function index(Request $request): void
'projection' => true,
]));

$serverNames = $this->searcher->getAllServerNames();

$title = 'Recent runs';
$titleMap = [
'wt' => 'Longest wall time',
Expand All @@ -71,6 +73,7 @@ public function index(Request $request): void
'search' => $search,
'has_search' => implode('', $search) !== '',
'title' => $title,
'server_names' => $serverNames,
]);
}

Expand Down
8 changes: 8 additions & 0 deletions src/Searcher/MongoSearcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,12 @@ public function stats(): array
'bytes' => 0,
];
}

/**
* {@inheritdoc}
*/
public function getAllServerNames(): ?array
{
return $this->_collection->distinct('meta.SERVER.SERVER_NAME');
}
}
8 changes: 8 additions & 0 deletions src/Searcher/PdoSearcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ public function stats()
return $row;
}

/**
* {@inheritdoc}
*/
public function getAllServerNames(): ?array
{
return null;
}

/**
* {@inheritdoc}
*/
Expand Down
7 changes: 7 additions & 0 deletions src/Searcher/SearcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
11 changes: 10 additions & 1 deletion templates/runs/list.twig
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@
<div class="control-group span4">
<label class="control-label" for="server-name">Server Name</label>
<div class="controls">
<input type="text" id="server-name" name="server_name" value="{{ search.server_name }}">
{% if server_names is iterable %}
<select id="server-name" name="server_name">
{% for server_name in server_names %}
<option></option>
<option value="{{ server_name }}"{% if server_name == search.server_name %} selected{% endif %}>{{ server_name }}</option>
glensc marked this conversation as resolved.
Show resolved Hide resolved
{% endfor %}
</select>
{% else %}
<input type="text" id="server-name" name="server_name" value="{{ search.server_name }}">
{% endif %}
</div>
<label class="control-label" for="url">URL</label>
<div class="controls">
Expand Down
8 changes: 8 additions & 0 deletions tests/Searcher/MongoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,12 @@ public function testTruncateWatchesPreserveIndexes(): void
$this->assertEquals($options['name'], $name);
}
}

public function testGetAllServerNames(): void
{
$result = $this->mongo->getAllServerNames();
$this->assertCount(2, $result);
$this->assertContains('localhost', $result);
$this->assertContains('foo', $result);
}
}
20 changes: 20 additions & 0 deletions tests/fixtures/normalized.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,25 @@
"pmu": 0
}
}
},
{
"_id": "aaaaaaaaaaaaaaaaaaaaaab2",
"meta": {
"url": "/bar",
"simple_url": "/bar",
"get": [],
"env": [],
"SERVER": {"REQUEST_TIME": 1358614812, "SERVER_NAME": "foo", "REQUEST_METHOD": "GET"},
"request_ts_micro": {"sec": 1358614812, "usec": 123456}
},
"profile": {
"main()": {
"ct": 1,
"wt": 10,
"cpu": 12,
"mu": 3000,
"pmu": 3001
}
}
}
]