Show names in top clients list from long-term data

Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
Christian König
2022-07-04 20:45:51 +02:00
parent 7acc7d8949
commit 295fbf117a

View File

@@ -158,7 +158,11 @@ if (isset($_GET['topClients']) && $auth)
{
$limit = "WHERE timestamp <= :until";
}
$stmt = $db->prepare('SELECT client,count(client) FROM queries '.$limit.' GROUP by client order by count(client) desc limit 20');
$dbquery= "Select CASE typeof(client) WHEN 'integer' THEN (";
$dbquery .= " SELECT CASE TRIM(name) WHEN '' THEN c.ip ELSE c.name END name FROM client_by_id c WHERE c.id = q.client)";
$dbquery .= " ELSE client END client, count(client) FROM query_storage q ".$limit." GROUP by client order by count(client) desc limit 20";
$stmt = $db->prepare($dbquery);
$stmt->bindValue(":from", intval($_GET['from']), SQLITE3_INTEGER);
$stmt->bindValue(":until", intval($_GET['until']), SQLITE3_INTEGER);
$results = $stmt->execute();