Created
August 24, 2020 17:28
-
-
Save icelander/d241bb3f90886edc0d716de0522b387a to your computer and use it in GitHub Desktop.
This is a query that gets session diagnostic information from the Mattermost database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Find diagnostic information for a specific user's sessions | |
SELECT u.Id as UserId, | |
u.Username, | |
u.Email, | |
s.Id As SessionId, | |
s.Roles, | |
s.DeviceId, -- For mobile sessions | |
IF (s.ExpiresAt IS NOT NULL && s.ExpiresAt < (UNIX_TIMESTAMP() * 1000), "Expired", "Active") as SessionActive, | |
IF (FROM_UNIXTIME(s.ExpiresAt/1000) IS NULL, "Token", "User") as SessionType, -- Tokens are bot or personal access tokens, User are sessions where the user logged in | |
FROM_UNIXTIME(s.CreateAt/1000) AS SessionCreateDate, | |
FROM_UNIXTIME(s.ExpiresAt/1000) AS SessionExpireDate, | |
FROM_UNIXTIME(s.LastActivityAt/1000) AS SessionLastActivityDate, | |
s.Props | |
FROM Users u | |
JOIN Sessions s ON s.UserId = u.Id | |
WHERE u.Id = '<User Id>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment