How can I get a list of UserHistoryItem for a specific period of time. Currently our plugin needs that functionality for internal business usage and what we have determined so far is we can call for example:
List<UserHistoryItem> issueHistoryItems = userHistoryManager.getHistory(UserHistoryItem.ISSUE, appUser);
to obtain a list of UserHistoryItem(s) but we can't find out how to restrict the period of time those changes occurred.
User history does not contain data about the date it was created.
What do you exaclty want to achieve. Maybe there is a better approach which will allow you to filter by date.
Hi Boris,
I'd like to obtain user's activity for a specific timespan.
Any references to the API would be appreciated.
Many thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If by activity you mean any issue-related activity you can then use com.atlassian.jira.user.UserHistoryItem.getType() to filter out all items related to issues and the use com.atlassian.jira.user.UserHistoryItem.getEntityId() to collect all issue ids that were affected by a user action. Next use com.atlassian.jira.issue.changehistory.ChangeHistoryManager.getChangeHistoriesForUser(Iterable<Issue>, User) to get all com.atlassian.jira.issue.changehistory.ChangeHistory objects. The ChangeHistory has a getTimePerformed() method which you can use to apply filter by date/time period.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks,
Have you got any idea why all the changeItems fields in the obtianed List<ChangeHistory> are null?
List<UserHistoryItem> issueHistoryItems = userHistoryManager.getHistory(UserHistoryItem.ISSUE, appUser); List<Issue> issuesUserActedOn = new ArrayList<Issue>(); for(UserHistoryItem userHistoryItem : issueHistoryItems){ Issue issueByString = issueManager.getIssueObject(userHistoryItem.getEntityId()); Issue issueByLong = issueManager.getIssueObject(Long.parseLong(userHistoryItem.getEntityId())); issuesUserActedOn.add(issue); } List<ChangeHistory> changeHistories = changeHistoryManager.getChangeHistoriesForUser(issuesUserActedOn, ApplicationUsers.toDirectoryUser(appUser));
Output from the debugger:
... where you can see that changeItems = null;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The change items are lazy loaded so you should call some method and then check rather than just looking at the debugger
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.