List of active users (who login/update/view JIRA frequently) from JIRA 4.2.2 db table.

Hi there,

We are intrested in sending out JIRA notifications to only those users who are actually active in JIRA. For that I want to pull out list of active users (who login/update/view JIRA frequently) from JIRA 4.2.2 db table. I tried to run the below SQL in SQL developer (got from: https://confluence.atlassian.com/display/JIRACOM/Example+SQL+queries+for+JIRA) but it throws "Missing IN or OUT parameter at index:: 1" error.

Can you please assist me in what I am missing?

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;
Any assistance is highly appreciated.
Thanks! Ash

4 answers

This widget could not be displayed.

I think the error lies within your to_timestamp function. See here.

I'm not sure if this works (most information you are looking for I found in CWD_USER and CWD_USER_ATTRIBUTES) but I'm on 5.1.2

This widget could not be displayed.

I think you need to add 1357554646231 milli seconds to the date 01/01/1970.

This widget could not be displayed.

Yes, you are right! On the DB side, it is the ATTRIBUTE_VALUE from CWD_USER_ATTRIBUTES table which stores last login information (ATTRIBUTE_NAME = login.lastLoginMillis) but this value seems to be in a different format.

Not sure how to read this value?

<th>ATTRIBUTE_NAME</th>
ATTRIBUTE_VALUE
login.lastLoginMillis 1357554646231
This widget could not be displayed.

here is the SQL transformation of the last login date

select 

to_date('01011970','ddmmyyyy') + round(to_number(ua.attribute_value)/24/60/60/1000,0) last_login_date

from cwd_user_attributes ua 

where ua.user_id = 10000 

and ua.attribute_name ='login.previousLoginMillis'

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

155 views 2 0
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