Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 90ca7ac

Browse files
vyskocilpavelpajavyskocil
authored andcommitted
Changed the summary table
* Now you can see average and maximal count of logins per day
1 parent b62111f commit 90ca7ac

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cesnet/simplesamlphp-module-proxystatistics",
33
"description": "A SimpleSAMLPHP module for statistics",
4-
"version": "1.0.0-rc",
4+
"version": "1.1.0-rc",
55
"type": "simplesamlphp-module",
66
"keywords": ["statistics","simplesamlphp"],
77
"license": "BSD-2",

lib/Auth/Process/DatabaseCommand.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,42 @@ public static function getCountOfAccesedServices()
180180
}
181181
echo $count;
182182
}
183+
184+
public static function getAverageLoginCountPerDay()
185+
{
186+
$databaseConnector = new DatabaseConnector();
187+
$conn = $databaseConnector->getConnection();
188+
assert($conn != NULL);
189+
$table_name = $databaseConnector->getServiceProvidersTableName();
190+
$sql = "SELECT AVG(count) as avg_count FROM (SELECT year, month, day, SUM(count) AS count FROM " . $table_name . " GROUP BY year,month,day ) AS average_count;";
191+
$result = $conn->query($sql);
192+
while($row = $result->fetch_assoc()) {
193+
$avg_count = $row["avg_count"];
194+
}
195+
$conn->close();
196+
if ($avg_count === null)
197+
{
198+
$avg_count = 0;
199+
}
200+
echo round($avg_count);
201+
}
202+
203+
public static function getMaxLoginCountPerDay()
204+
{
205+
$databaseConnector = new DatabaseConnector();
206+
$conn = $databaseConnector->getConnection();
207+
assert($conn != NULL);
208+
$table_name = $databaseConnector->getServiceProvidersTableName();
209+
$sql = "SELECT MAX(count) as max_count FROM (SELECT year, month, day, SUM(count) AS count FROM " . $table_name . " GROUP BY year,month,day ) AS maximal_count;";
210+
$result = $conn->query($sql);
211+
while($row = $result->fetch_assoc()) {
212+
$max_count = $row["max_count"];
213+
}
214+
$conn->close();
215+
if ($max_count === null)
216+
{
217+
$max_count = 0;
218+
}
219+
echo $max_count;
220+
}
183221
}

www/summary.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ function drawTable() {
2020
['Overall number of logins', <?php DatabaseCommand::getCountOfAllLogins()?> ],
2121
['Total number of accessed service providers', <?php DatabaseCommand::getCountOfAccesedServices()?>],
2222
['Total number of used identity providers', <?php DatabaseCommand::getCountOfUsedIdp()?>],
23-
['Number of logins for today', <?php DatabaseCommand::getCountOfAllLoginsForToday()?>]
23+
['Number of logins for today', <?php DatabaseCommand::getCountOfAllLoginsForToday()?>],
24+
['Average number of logins per day', <?php DatabaseCommand::getAverageLoginCountPerDay()?>],
25+
['Maximal number of logins per day', <?php DatabaseCommand::getMaxLoginCountPerDay()?>]
2426
]);
2527

2628
var table = new google.visualization.Table(document.getElementById('summaryTable'));

0 commit comments

Comments
 (0)