From 0617611bd4868757aa57e93276c97dd851deb201 Mon Sep 17 00:00:00 2001 From: "Jeffrey T. Palmer" Date: Fri, 4 Feb 2022 11:58:43 -0500 Subject: [PATCH 1/2] Refactor admin user listing query and add indexes --- classes/XDAdmin.php | 25 ++++++------------- .../etl/etl_tables.d/xdb/session-manager.json | 12 +++++++++ configuration/etl/etl_tables.d/xdb/users.json | 6 +++++ 3 files changed, 26 insertions(+), 17 deletions(-) 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_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": [ From b07f6afb4e60e54fe783332f784305da18bef500 Mon Sep 17 00:00:00 2001 From: "Jeffrey T. Palmer" Date: Fri, 4 Feb 2022 12:46:58 -0500 Subject: [PATCH 2/2] Add migration --- .../etl/etl.d/xdmod-migration-9_5_0-10_0_0.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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": [