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

Commit cb2a5a5

Browse files
committed
Fixed drawing correct data into table by selected time range
1 parent 5ea9b64 commit cb2a5a5

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ All notable changes to this project will be documented in this file.
88
[Changed]
99
- DB commands work with apostrophes in IdP/SP names
1010
- New visual form of the site
11+
- Draw tables without month
12+
13+
[Fixed]
14+
- Draws tables data by selected time range
15+
1116

1217
## [v1.3.0]
1318
[Added]

lib/Auth/Process/DatabaseCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ public static function getAccessCountPerService($days)
160160
$serviceProvidersTableName = $databaseConnector->getServiceProvidersTableName();
161161
$serviceProvidersMapTableName = $databaseConnector->getServiceProvidersMapTableName();
162162
if($days == 0) { // 0 = all time
163-
$stmt = $conn->prepare("SELECT IFNULL(name,service) AS spName, SUM(count) AS count FROM " . $serviceProvidersTableName . " LEFT OUTER JOIN " . $serviceProvidersMapTableName . " ON service = identifier GROUP BY service HAVING service != ''");
163+
$stmt = $conn->prepare("SELECT IFNULL(name,service) AS spName, SUM(count) AS count FROM " . $serviceProvidersTableName . " LEFT OUTER JOIN " . $serviceProvidersMapTableName . " ON service = identifier GROUP BY service HAVING service != '' ORDER BY count DESC");
164164
} else {
165-
$stmt = $conn->prepare("SELECT year, month, day, IFNULL(name,service) AS spName, SUM(count) AS count FROM " . $serviceProvidersTableName . " LEFT OUTER JOIN " . $serviceProvidersMapTableName . " ON service = identifier WHERE CONCAT(year,'-',LPAD(month,2,'00'),'-',LPAD(day,2,'00')) BETWEEN CURDATE() - INTERVAL ".$days." DAY AND CURDATE() GROUP BY service HAVING service != ''");
165+
$stmt = $conn->prepare("SELECT year, month, day, IFNULL(name,service) AS spName, SUM(count) AS count FROM " . $serviceProvidersTableName . " LEFT OUTER JOIN " . $serviceProvidersMapTableName . " ON service = identifier WHERE CONCAT(year,'-',LPAD(month,2,'00'),'-',LPAD(day,2,'00')) BETWEEN CURDATE() - INTERVAL ".$days." DAY AND CURDATE() GROUP BY service HAVING service != '' ORDER BY count DESC");
166166
}
167167
$stmt->execute();
168168
$result = $stmt->get_result();
@@ -180,9 +180,9 @@ public static function getLoginCountPerIdp($days)
180180
$identityProvidersTableName = $databaseConnector->getIdentityProvidersTableName();
181181
$identityProvidersMapTableName = $databaseConnector->getIdentityProvidersMapTableName();
182182
if($days == 0) { // 0 = all time
183-
$stmt = $conn->prepare("SELECT IFNULL(name,sourceIdp) AS idPName, SUM(count) AS count FROM ".$identityProvidersTableName. " LEFT OUTER JOIN " . $identityProvidersMapTableName . " ON sourceIdp = entityId GROUP BY sourceIdp HAVING sourceIdp != ''");
183+
$stmt = $conn->prepare("SELECT IFNULL(name,sourceIdp) AS idPName, SUM(count) AS count FROM ".$identityProvidersTableName. " LEFT OUTER JOIN " . $identityProvidersMapTableName . " ON sourceIdp = entityId GROUP BY sourceIdp HAVING sourceIdp != '' ORDER BY count DESC");
184184
} else {
185-
$stmt = $conn->prepare("SELECT year, month, day, IFNULL(name,sourceIdp) AS idPName, SUM(count) AS count FROM ".$identityProvidersTableName. " LEFT OUTER JOIN " . $identityProvidersMapTableName . " ON sourceIdp = entityId WHERE CONCAT(year,'-',LPAD(month,2,'00'),'-',LPAD(day,2,'00')) BETWEEN CURDATE() - INTERVAL ".$days." DAY AND CURDATE() GROUP BY sourceIdp HAVING sourceIdp != ''");
185+
$stmt = $conn->prepare("SELECT year, month, day, IFNULL(name,sourceIdp) AS idPName, SUM(count) AS count FROM ".$identityProvidersTableName. " LEFT OUTER JOIN " . $identityProvidersMapTableName . " ON sourceIdp = entityId WHERE CONCAT(year,'-',LPAD(month,2,'00'),'-',LPAD(day,2,'00')) BETWEEN CURDATE() - INTERVAL ".$days." DAY AND CURDATE() GROUP BY sourceIdp HAVING sourceIdp != '' ORDER BY count DESC");
186186
}
187187
$stmt->execute();
188188
$result = $stmt->get_result();

templates/identityProviders-tpl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ function drawIdpsChart() {
3232

3333
function drawIdpsTable() {
3434
var data = new google.visualization.DataTable();
35-
data.addColumn('date', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_month}'); ?>');
35+
3636
data.addColumn('string', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_identity_provider}'); ?>');
3737
data.addColumn('number', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/count}'); ?>');
38-
data.addRows([<?php DatabaseCommand::getLoginCountPerDeyPerService()?>]);
38+
data.addRows([<?php DatabaseCommand::getLoginCountPerIdp($lastDays)?>]);
3939

4040
var table = new google.visualization.Table(document.getElementById('idpsTable'));
4141

templates/serviceProviders-tpl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ function drawSpsChart() {
3333

3434
function drawSpsTable() {
3535
var data = new google.visualization.DataTable();
36-
data.addColumn('date', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_month}'); ?>');
36+
3737
data.addColumn('string', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/tables_service_provider}'); ?>');
3838
data.addColumn('number', '<?php echo $this->t('{proxystatistics:Proxystatistics:templates/count}'); ?>');
39-
data.addRows([<?php DatabaseCommand::getAccessToServicesPerMonth()?>]);
39+
data.addRows([<?php DatabaseCommand::getAccessCountPerService($lastDays)?>]);
4040

4141
var table = new google.visualization.Table(document.getElementById('spsTable'));
4242

0 commit comments

Comments
 (0)