Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

MySQL database query to get all users who haven't logged for current date

Srinivas Acharya M August 23, 2018

Hi,
I'm trying to find all the users who haven't logged for the current day.
I need the MySQL query for JIRA to get all such users? 

I have JIRA 7.9.0 and MySQL 5.7

Does anyone know what the query is?

1 answer

0 votes
Sloan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2018

Hi @Srinivas Acharya M

The following Knowledgebase page might help you:

This is the SQL to display all users according to a last login date:

SELECT d.directory_name AS "Directory", 
    u.user_name AS "Username",
    from_unixtime((cast(attribute_value AS UNSIGNED)/1000)) AS "Last Login" 
FROM cwd_user u
JOIN (
    SELECT DISTINCT child_name
    FROM cwd_membership m
    JOIN licenserolesgroup gp ON m.parent_name = gp.GROUP_ID
    ) AS m ON m.child_name = u.user_name
JOIN (
    SELECT * 
    FROM cwd_user_attributes 
    WHERE attribute_name = 'login.lastLoginMillis'
    ) AS a ON a.user_id = u.id
JOIN cwd_directory d ON u.directory_id = d.id
ORDER BY "Last Login" DESC;

Niklas

Sloan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2018

And for users that have never logged in see this:

Note please that the SQL there is for PostgreSQL and might now work without changes on MySQL.

Suggest an answer

Log in or Sign up to answer