how do i query the users who doesn't login for last 6 months in Jira?

how to find the users list who didn't login into JIRA for last 6 months

1 answer

Either you need to query DB or use Java code 

public Collection<ApplicationUser> getInactiveUsers(String startDate){
        Collection<ApplicationUser> users = ComponentAccessor.getUserManager().getAllApplicationUsers();
            Collection<ApplicationUser> inActiveUsers = new HashSet<ApplicationUser>();
        try {

            //System.out.println(" ------- USER LAST LOGIN STARTS --------");
            for (ApplicationUser u : users) {
                if (ComponentAccessor.getGroupManager().isUserInGroup(u.getName(), "jira-users")) {
                    String stringDate = ComponentAccessor.getCrowdService().getUserWithAttributes(u.getName()).getValue("login.lastLoginMillis");
                    if(stringDate !=null ){
                    Long l1 = new Long(stringDate);
                    Date lastLoginDate = new Date(l1);
                    Date cutoffDate = (new SimpleDateFormat("yyyyMMdd")).parse(startDate);
                    if (lastLoginDate.getTime() <= cutoffDate.getTime()) {
                        inActiveUsers.add(u);
                    }}
                }
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        return inActiveUsers;
    }

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Fadoua M. Boualem
Published yesterday in Trello

Using Trello to manage events

As a Jira power user, I was at first doubtful that Trello could benefit my workflow. Jira already uses boards (ones you can customize!), so why would I even need to use Trello?! In this post you will...

425 views 5 6
Read article

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