diff --git a/application/config/config.sample.php b/application/config/config.sample.php index b00624705..e696c53ee 100644 --- a/application/config/config.sample.php +++ b/application/config/config.sample.php @@ -777,3 +777,14 @@ $config['enable_eqsl_massdownload'] = false; */ $config['max_login_attempts'] = 3; + +/* +|-------------------------------------------------------------------------- +| Disable User QSO Count in User List (Admin Menu) +| Reason for this setting is to prevent performance issues on large installations +| where the QSO count is not needed. Set to true to disable the QSO count. +| This also hides the last Operator for CLubstations. Default is false. +|-------------------------------------------------------------------------- + */ + + $config['disable_user_stats'] = false; \ No newline at end of file diff --git a/application/models/User_model.php b/application/models/User_model.php index e1ee6bda9..1c6c35312 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -688,6 +688,20 @@ class User_Model extends CI_Model { // FUNCTION: object users() // Returns a list of users with additional counts function users($club = '') { + $qsocount_select = ""; + $qsocount_join = ""; + if (!($this->config->item('disable_user_stats') ?? false)) { + $qsocount_select = ", COALESCE(lc.qsocount, 0) AS qsocount, lc.lastqso"; + $qsocount_join = + " LEFT JOIN ( + SELECT sp.user_id, + COUNT(l.col_primary_key) AS qsocount, + MAX(l.COL_TIME_ON) AS lastqso + FROM station_profile sp + JOIN " . $this->config->item('table_name') . " l ON l.station_id = sp.station_id + GROUP BY sp.user_id + ) lc ON lc.user_id = u.user_id"; + } $sql = "SELECT u.user_id, u.user_name, @@ -700,9 +714,8 @@ class User_Model extends CI_Model { u.login_attempts, u.clubstation, COALESCE(sp_count.stationcount, 0) AS stationcount, - COALESCE(sl_count.logbookcount, 0) AS logbookcount, - COALESCE(lc.qsocount, 0) AS qsocount, - lc.lastqso + COALESCE(sl_count.logbookcount, 0) AS logbookcount + ".$qsocount_select." FROM users u LEFT JOIN ( SELECT user_id, COUNT(*) AS stationcount @@ -713,15 +726,8 @@ class User_Model extends CI_Model { SELECT user_id, COUNT(*) AS logbookcount FROM station_logbooks GROUP BY user_id - ) sl_count ON sl_count.user_id = u.user_id - LEFT JOIN ( - SELECT sp.user_id, - COUNT(l.col_primary_key) AS qsocount, - MAX(l.COL_TIME_ON) AS lastqso - FROM station_profile sp - JOIN " . $this->config->item('table_name') . " l ON l.station_id = sp.station_id - GROUP BY sp.user_id - ) lc ON lc.user_id = u.user_id"; + ) sl_count ON sl_count.user_id = u.user_id" + .$qsocount_join; if ($this->config->item('special_callsign')) { if ($club === 'is_club') { @@ -733,13 +739,13 @@ class User_Model extends CI_Model { $result = $this->db->query($sql); if ($this->config->item('special_callsign')) { - if ($club === 'is_club') { + if ($club === 'is_club' && !($this->config->item('disable_user_stats') ?? false)) { foreach ($result->result() as &$row) { $row->lastoperator = $this->get_last_op($row->user_id, $row->lastqso); } } else { foreach ($result->result() as &$row) { - $row->lastoperator = ''; + $row->lastoperator = ''; // Important: If 'disable_user_stats' is set to true, the admin won't see the last operator of a clubstation } } } diff --git a/application/views/user/index.php b/application/views/user/index.php index c14c8f9ff..b9a9e713d 100644 --- a/application/views/user/index.php +++ b/application/views/user/index.php @@ -76,14 +76,16 @@ : stationcount; ?>
: logbookcount; ?> - qsocount > 0) { ?> -
lastqso; ?>"> - qsocount; ?> -
- - "> - qsocount; ?> - + config->item('disable_user_stats') ?? false)) { + if ($row->qsocount > 0) { ?> +
lastqso; ?>"> + qsocount; ?> +
+ + "> + qsocount; ?> + + @@ -150,7 +152,9 @@ - + config->item('disable_user_stats') ?? false)) { ?> + + @@ -164,7 +168,9 @@ user_id; ?>">user_name; ?> user_callsign); ?> user_email; ?> - lastoperator; ?> + config->item('disable_user_stats') ?? false)) { ?> + lastoperator; ?> + last_seen != null) { // if the user never logged in before the value is null. We can show "never" then. $lastSeenTimestamp = strtotime($row->last_seen); @@ -182,10 +188,12 @@ : stationcount; ?>
: logbookcount; ?> - qsocount > 0) { ?> -
lastqso; ?>">qsocount; ?>
- - ">qsocount; ?> + config->item('disable_user_stats') ?? false)) { + if ($row->qsocount > 0) { ?> +
lastqso; ?>">qsocount; ?>
+ + ">qsocount; ?> + diff --git a/install/config/config.php b/install/config/config.php index 5dd56d96d..a1a691d27 100644 --- a/install/config/config.php +++ b/install/config/config.php @@ -776,4 +776,15 @@ $config['enable_eqsl_massdownload'] = false; |-------------------------------------------------------------------------- */ -$config['max_login_attempts'] = 3; + $config['max_login_attempts'] = 3; + + /* + |-------------------------------------------------------------------------- + | Disable User QSO Count in User List (Admin Menu) + | Reason for this setting is to prevent performance issues on large installations + | where the QSO count is not needed. Set to true to disable the QSO count. + | This also hides the last Operator for CLubstations. Default is false. + |-------------------------------------------------------------------------- + */ + + $config['disable_user_stats'] = false;