Hi Guys,
Need your help in fixing my script. I am trying to get a Count of the JIRA users last login time of last calendar month. Like User whose last login time between 1st March to 31st March.
Getting this error message :-
groovy.lang.MissingMethodException: No signature of method: java.lang.Long.between() is applicable for argument types: (Date, Date) values: [Wed Mar 01 23:49:00 PST 2023, Fri Mar 31 23:49:00 PDT 2023]
at Script3103$_run_closure1.doCall(Script3103.groovy:27)
at Script3103.run(Script3103.groovy:26)
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.login.LoginManager
import java.text.SimpleDateFormat;
import java.util.Date;
import com.atlassian.jira.user.util.UserUtil
UserUtil userUtil = ComponentAccessor.getUserUtil()
def loginManager = ComponentAccessor.getComponentOfType(LoginManager.class)
def groupManager = ComponentAccessor.getGroupManager()
def adminGroup = groupManager.getUsersInGroup('jira-administrators')
def softwareGroup = groupManager.getUsersInGroup('jira-users')
def users = adminGroup + softwareGroup
users.unique()
// Get the start and end dates of the last calendar month
Calendar cal = Calendar.getInstance()
cal.add(Calendar.MONTH, -1)
cal.set(Calendar.DAY_OF_MONTH, 1)
Date startDate = cal.time
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH))
Date endDate = cal.time
def activeUsersWithLoginLastMonth = users.findAll { user ->
user.isActive() && loginManager.getLoginInfo(user.username)?.getLastLoginTime()?.between(startDate, endDate)
}
def countActiveUsersWithLoginLastMonth = activeUsersWithLoginLastMonth.size()
return countActiveUsersWithLoginLastMonth