Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Need to remove user activity from jira history and activity

As the question...for a specific user using a Jython script

I have tried using the [UserHistoryManager Class|http://docs.atlassian.com/software/jira/docs/api/4.2/com/atlassian/jira/user/UserHistoryManager.html ], but have been unsucessful.

We are using Jira v4.4.5

3 answers

1 vote
David Atlassian Team Aug 13, 2012

This is something that is definitely not recommended. It may be possible to do this via the database access.

Definitely Backup your database first.

I believe the tables you'll want to take a look at are the:

  • changeitem
  • changegroup
  • userhistoryitem

Thanks for your response David. We have a custom field to gather information about about a tree of improvements under a given feature (done via Jython). It makes some time computations in the process via a virtual (not a person) user account. The problem is the flooding of information in the history due to this. Wonder if anyone knows a Jython or Java based solution for this problem, than at database level.

I have already found out the tables affected by the change, but thanks for re-assuring the list.

0 votes

I clean like this

def isPreview = true
/*
    That script clean last view activity,
    just in case it was related to the performance degradation in Jira Service Desk and Jira Software for the 10k+
 */
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.user.UserHistoryItem;
import com.atlassian.jira.user.UserHistoryManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.UserHistoryItem.*;
import com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.jira.bc.user.search.UserSearchParams
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("com.gonchik.scripts.groovy.cleanupLastViewHistoryForInactiveUsers")
log.setLevel(Level.DEBUG)

boolean cleanForActiveUsers = false
// This script shows how to clean up the history items from inactive users
UserSearchService userSearchService = ComponentAccessor.getComponent(UserSearchService.class)
UserSearchParams userSearchParams = (new UserSearchParams.Builder()).allowEmptyQuery(true).includeActive(cleanForActiveUsers).includeInactive(true).maxResults(100000).build()
def userHistoryManager = ComponentAccessor.getComponent(UserHistoryManager.class)
def sb = new StringBuilder()
for (ApplicationUser appUser : userSearchService.findUsers("", userSearchParams)) {
    List<UserHistoryItem> recentUserHistory = userHistoryManager.getHistory(UserHistoryItem.ASSIGNEE, appUser);
    if (!isPreview){
        userHistoryManager.removeHistoryForUser(appUser)
    }
    sb.append("${appUser.name}<br/>\n")
}
return sb.toString()

https://github.com/gonchik/cleanup-scripts/blob/master/groovy/jira/users/cleanUserHistoryLastView.groovy

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you