diff --git a/classes/XDAdmin.php b/classes/XDAdmin.php index 9f7f0de143..45ad44f023 100644 --- a/classes/XDAdmin.php +++ b/classes/XDAdmin.php @@ -53,25 +53,16 @@ public function getUserListing($groupFilter = 0) u.first_name, u.last_name, u.account_is_active, - CASE - WHEN ( - SELECT init_time - FROM SessionManager - WHERE user_id = u.id - ORDER BY init_time DESC - LIMIT 1 - ) IS NULL - THEN '0' - ELSE ( - SELECT init_time - FROM SessionManager - WHERE user_id = u.id - ORDER BY init_time DESC - LIMIT 1 - ) - END AS last_logged_in + COALESCE(MAX(sm.init_time), 0) AS last_logged_in FROM Users u + LEFT JOIN SessionManager sm ON sm.user_id = u.id $filterSQL + GROUP BY + u.id, + u.username, + u.first_name, + u.last_name, + u.account_is_active ORDER BY last_logged_in DESC "; diff --git a/configuration/etl/etl.d/xdmod-migration-9_5_0-10_0_0.json b/configuration/etl/etl.d/xdmod-migration-9_5_0-10_0_0.json index ab3d3ddd87..fbfaa3fe18 100644 --- a/configuration/etl/etl.d/xdmod-migration-9_5_0-10_0_0.json +++ b/configuration/etl/etl.d/xdmod-migration-9_5_0-10_0_0.json @@ -365,6 +365,22 @@ "schema": "modw" } } + }, + { + "name": "update-moddb-users", + "description": "Update moddb Users table", + "class": "ManageTables", + "definition_file_list": [ + "xdb/users.json" + ], + "endpoints": { + "destination": { + "type": "mysql", + "name": "XDMoD Data Warehouse", + "config": "datawarehouse", + "schema": "moddb" + } + } } ], "cloud-migration-9-5-0_10-0-0": [ diff --git a/configuration/etl/etl_tables.d/xdb/session-manager.json b/configuration/etl/etl_tables.d/xdb/session-manager.json index 583b91c3e8..952e8f0306 100644 --- a/configuration/etl/etl_tables.d/xdb/session-manager.json +++ b/configuration/etl/etl_tables.d/xdb/session-manager.json @@ -52,6 +52,18 @@ ], "type": "BTREE", "is_unique": true + }, + { + "name": "idx_user_id", + "columns": [ + "user_id" + ] + }, + { + "name": "idx_init_time", + "columns": [ + "init_time" + ] } ], "triggers": [] diff --git a/configuration/etl/etl_tables.d/xdb/users.json b/configuration/etl/etl_tables.d/xdb/users.json index e4033eb99c..6150822976 100644 --- a/configuration/etl/etl_tables.d/xdb/users.json +++ b/configuration/etl/etl_tables.d/xdb/users.json @@ -130,6 +130,12 @@ ], "type": "BTREE", "is_unique": true + }, + { + "name": "idx_user_type", + "columns": [ + "user_type" + ] } ], "triggers": [