I need to get login history of all users from database.

Hi,

I want to get login details of all users from database. I got below query from atlassian Example SQL query,

SELECT
u.username AS username ,
psname.propertyvalue AS FullName ,
psemail.propertyvalue AS email,
pslogincount.propertyvalue AS logincount,
to_timestamp(pslastlogin.propertyvalue::numeric /1000) AS lastlogin
FROM
userbase u
JOIN
(
SELECT
id,
entity_id
FROM
propertyentry
WHERE
property_key = 'fullName'
)
entityName
ON
u.id = entityName.entity_id
JOIN
(
SELECT
id,
entity_id
FROM
propertyentry
WHERE
property_key = 'email'
)
entityEmail
ON
u.id = entityEmail.entity_id
left JOIN
(
SELECT
id,
entity_id
FROM
propertyentry
WHERE
property_key = 'login.count'
)
loginCount
ON
u.id = loginCount.entity_id
left JOIN
(
SELECT
id,
entity_id
FROM
propertyentry
WHERE
property_key = 'login.previousLoginMillis'
)
lastLogin
ON
u.id = lastLogin.entity_id
JOIN propertystring psname
ON
entityName.id=psname.id
JOIN propertystring psemail
ON
entityEmail.id = psemail.id
left JOIN propertystring pslogincount
ON
loginCount.id=pslogincount.id
left JOIN propertystring pslastlogin
ON
lastLogin.id = pslastlogin.id
ORDER BY username;

After executing, I m getting ORA-00907: "missing right parenthesis error".

Could you please assist me on this?

If there is any other way to get details of login history of users, then please let me know.

Jira version is 4.2.3

Thanks,

Niyas

2 answers

On this KB it has examples for MySQL, PostgreSQL and MSSQL. If you're using Oracle, maybe, you can create a similar query based on these ones.

https://confluence.atlassian.com/display/JIRAKB/Retrieve+last+login+dates+for+users+from+the+database

Hi Niyas,

Oracle has a problem with :: in this line

to_timestamp(pslastlogin.propertyvalue::numeric /1000) AS lastlogin

I'm not sure about the user information in JIRA 4.2.3. Is it in the table userbase or as in my case in cwd_users?

However to get the last login date I use following query

select cwd_user.*, 
to_date('01.01.1970','dd.mm.yyyy') + to_number(cwd_user_attributes.attribute_value)/1000/60/60/24 as last_login 
from cwd_user, cwd_user_attributes 
where cwd_user.id = cwd_user_attributes.user_id
and cwd_user_attributes.attribute_name ='login.lastLoginMillis';

You would probably need to rewrite this for other attributes you want to obtain (see the original query) and if it is userbase and not cwd_users to replace the "from" and join clause.

Hope I could help,

Udo

Thanks Udo. This helped

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,311 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot