Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
style(Admin Panel): replace _ to backspace in render
Browse files Browse the repository at this point in the history
It seems unnecessary to replace _ to backspace by using array_map ,
So we replace it when render those `Variable_name`
  • Loading branch information
Rhilip committed Jan 31, 2019
1 parent ac461b0 commit 857dc20
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
6 changes: 1 addition & 5 deletions apps/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,14 @@ private function infoRedis()
private function infoMysql()
{
$res = app()->pdo->createCommand('SHOW GLOBAL STATUS')->queryAll();
$res = array_map(function ($s) {
$s['Variable_name'] = str_replace('_', ' ', $s['Variable_name']);
return $s;
}, $res);
$serverStatus = array_column($res, 'Value', 'Variable_name');
$startAt = app()->pdo->createCommand('SELECT UNIX_TIMESTAMP() - :uptime')->bindParams([
'uptime' => $serverStatus['Uptime']
])->queryScalar();
$queryStats = [];
$tmp_array = $serverStatus;
foreach ($tmp_array AS $name => $value) {
if (substr($name, 0, 4) == 'Com ') {
if (substr($name, 0, 4) == 'Com_') {
$queryStats[substr($name, 4)] = $value;
unset($serverStatus[$name]);
}
Expand Down
28 changes: 14 additions & 14 deletions apps/views/admin/mysql_status.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
<tbody>
<tr>
<td>Received</td>
<td class="text-right">{{ serverStatus['Bytes received'] | format_bytes }}</td>
<td class="text-right">{{ (serverStatus['Bytes received'] * 3600 / serverStatus['Uptime']) | format_bytes }}</td>
<td class="text-right">{{ serverStatus['Bytes_received'] | format_bytes }}</td>
<td class="text-right">{{ (serverStatus['Bytes_received'] * 3600 / serverStatus['Uptime']) | format_bytes }}</td>
</tr>
<tr>
<td>Sent</td>
<td class="text-right">{{ serverStatus['Bytes sent'] | format_bytes }}</td>
<td class="text-right">{{ (serverStatus['Bytes sent'] * 3600 / serverStatus['Uptime']) | format_bytes }}</td>
<td class="text-right">{{ serverStatus['Bytes_sent'] | format_bytes }}</td>
<td class="text-right">{{ (serverStatus['Bytes_sent'] * 3600 / serverStatus['Uptime']) | format_bytes }}</td>
</tr>
<tr>
<td><b>Total</b></td>
<td class="text-right">{{ (serverStatus['Bytes received'] + serverStatus['Bytes sent']) | format_bytes }}</td>
<td class="text-right">{{ ((serverStatus['Bytes sent'] + serverStatus['Bytes sent']) * 3600 / serverStatus['Uptime']) | format_bytes }}</td>
<td class="text-right">{{ (serverStatus['Bytes_received'] + serverStatus['Bytes_sent']) | format_bytes }}</td>
<td class="text-right">{{ ((serverStatus['Bytes_sent'] + serverStatus['Bytes_sent']) * 3600 / serverStatus['Uptime']) | format_bytes }}</td>
</tr>
</tbody>
</table>
Expand All @@ -55,18 +55,18 @@
<tbody>
<tr>
<td>Failed Attempts</td>
<td class="text-right">{{ serverStatus['Aborted connects'] | number_format(0,'.', ',') }}</td>
<td class="text-right">{{ (serverStatus['Aborted connects'] * 3600 / serverStatus['Uptime']) | number_format(2,'.',',') }}</td>
<td class="text-right">{{ serverStatus['Aborted_connects'] | number_format(0,'.', ',') }}</td>
<td class="text-right">{{ (serverStatus['Aborted_connects'] * 3600 / serverStatus['Uptime']) | number_format(2,'.',',') }}</td>
<td class="text-right">
{% if serverStatus['Connections'] > 0 %}{{ (serverStatus['Aborted connects'] * 100 / serverStatus['Connections']) | number_format(2,'.',',') }} %{% else %}---{% endif %}
{% if serverStatus['Connections'] > 0 %}{{ (serverStatus['Aborted_connects'] * 100 / serverStatus['Connections']) | number_format(2,'.',',') }} %{% else %}---{% endif %}
</td>
</tr>
<tr>
<td>Aborted Clients</td>
<td class="text-right">{{ serverStatus['Aborted clients'] | number_format(0,'.', ',') }}</td>
<td class="text-right">{{ (serverStatus['Aborted clients'] * 3600 / serverStatus['Uptime']) | number_format(2,'.',',') }}</td>
<td class="text-right">{{ serverStatus['Aborted_clients'] | number_format(0,'.', ',') }}</td>
<td class="text-right">{{ (serverStatus['Aborted_clients'] * 3600 / serverStatus['Uptime']) | number_format(2,'.',',') }}</td>
<td class="text-right">
{% if serverStatus['Connections'] > 0 %}{{ (serverStatus['Aborted clients'] * 100 / serverStatus['Connections']) | number_format(2,'.',',') }} %{% else %}---{% endif %}
{% if serverStatus['Connections'] > 0 %}{{ (serverStatus['Aborted_clients'] * 100 / serverStatus['Connections']) | number_format(2,'.',',') }} %{% else %}---{% endif %}
</td>
</tr>
<tr>
Expand Down Expand Up @@ -108,7 +108,7 @@
<tbody>
{% for key, value in rows %}
<tr>
<td>{{ key }}</td>
<td>{{ key|replace({'_':' '}) }}</td>
<td class="text-right">{{ value | number_format(0,'.',',') }}</td>
<td class="text-right">{{ (value * 3600 / serverStatus['Uptime']) | number_format(2,'.',',') }}</td>
<td class="text-right">{{ (value * 100 / (serverStatus['Questions'] - serverStatus['Connections'])) | number_format(2,'.',',') }}</td>
Expand Down Expand Up @@ -139,7 +139,7 @@
<tbody>
{% for key,value in serverStatus %}
<tr>
<td>{{ key }}</td>
<td>{{ key|replace({'_':' '}) }}</td>
<td>{{ value }}</td>
</tr>
{% endfor %}
Expand Down

0 comments on commit 857dc20

Please sign in to comment.