diff options
author | Simon Rettberg | 2023-11-02 19:08:58 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-11-02 19:08:58 +0100 |
commit | c2d95ffaeaa289752b4c7b6664b6ca112a02e350 (patch) | |
tree | 2c29b0157d14198aadbdbc9f8c18ded0bd4dadcd /modules-available/statistics_reporting | |
parent | [rebootcontrol] Remove API prototype (diff) | |
download | slx-admin-c2d95ffaeaa289752b4c7b6664b6ca112a02e350.tar.gz slx-admin-c2d95ffaeaa289752b4c7b6664b6ca112a02e350.tar.xz slx-admin-c2d95ffaeaa289752b4c7b6664b6ca112a02e350.zip |
Roundup of issues reported by PHPStorm
Mostly redundant checks, logic errors, dead code, etc.
Diffstat (limited to 'modules-available/statistics_reporting')
-rw-r--r-- | modules-available/statistics_reporting/inc/queries.inc.php | 8 | ||||
-rw-r--r-- | modules-available/statistics_reporting/page.inc.php | 6 |
2 files changed, 5 insertions, 9 deletions
diff --git a/modules-available/statistics_reporting/inc/queries.inc.php b/modules-available/statistics_reporting/inc/queries.inc.php index a7e6ce9c..2465e557 100644 --- a/modules-available/statistics_reporting/inc/queries.inc.php +++ b/modules-available/statistics_reporting/inc/queries.inc.php @@ -23,7 +23,7 @@ class Queries foreach ($machines as &$machine) { $machine['medianSessionLength'] = self::calcMedian($machine['sessions']); unset($machine['sessions']); - $machine['clientName'] = $machine['hostname'] ? $machine['hostname'] : $machine['clientip']; + $machine['clientName'] = $machine['hostname'] ?: $machine['clientip']; } return $machines; } @@ -327,22 +327,20 @@ class Queries // User Data: Name, Name(anonymized), Number of Logins public static function getUserStatistics($from, $to, $lowerTimeBound = 0, $upperTimeBound = 24) { - $res = Database::simpleQuery("SELECT username AS name, COUNT(*) AS 'count' + return Database::simpleQuery("SELECT username AS name, COUNT(*) AS 'count' FROM statistic WHERE typeid='.vmchooser-session-name' AND dateline >= $from and dateline <= $to AND FROM_UNIXTIME(dateline, '%H') >= $lowerTimeBound AND FROM_UNIXTIME(dateline, '%H') < $upperTimeBound GROUP BY username"); - return $res; } // Virtual Machine Data: Name, Number of Usages public static function getVMStatistics($from, $to, $lowerTimeBound = 0, $upperTimeBound = 24) { - $res = Database::simpleQuery("SELECT data AS name, COUNT(*) AS 'count' + return Database::simpleQuery("SELECT data AS name, COUNT(*) AS 'count' FROM statistic WHERE typeid='.vmchooser-session-name' AND dateline >= $from and dateline <= $to AND FROM_UNIXTIME(dateline, '%H') >= $lowerTimeBound AND FROM_UNIXTIME(dateline, '%H') < $upperTimeBound GROUP BY data"); - return $res; } public static function getDozmodStats(int $from, int $to) diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php index c3e469fe..36081763 100644 --- a/modules-available/statistics_reporting/page.inc.php +++ b/modules-available/statistics_reporting/page.inc.php @@ -314,8 +314,7 @@ class Page_Statistics_Reporting extends Page } } // correct indexing of array after deletions - $data = array_values($data); - return $data; + return array_values($data); case 'client': $data = GetData::perClient($flags, Request::any('new', false, 'string')); // only show clients from locations which you have permission for @@ -326,8 +325,7 @@ class Page_Statistics_Reporting extends Page } } // correct indexing of array after deletions - $data = array_values($data); - return $data; + return array_values($data); case 'user': return GetData::perUser($flags); case 'vm': |