Remove filters and filter subscriptions

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2013

We are planning to host a new JIRA instance for one of our teams and we configured that by cloning data from existing dump, cleaned the existing data, users, groups, projects etc. without changing the configuration schemes. As we have removed all the projects from this instance, is it safe to delete SEARCHREQUEST and FILTERNOTIFICATIONS tables for removing the existing filters and subscriptions? If not what is the best way to flush out 16000 filters from this instance.

3 answers

0 votes
Srinivas Patruni August 19, 2013
I had written a groovy script for deleting filters, subscriptions and users and it is working well. I searched the tables SEARCHREQUEST and FILTERNOTIFICATIONS and found no rows after the script gets executed.


if(!ldapInfo.isJiraAdmin(user.getName(), user.getDisplayName()) ){
			boolean hasSubscriptions = false;
			Collection<SearchRequest> filters = searchRequestService.getOwnedFilters(user);
			log.info("Removing User ID: "+user.getName()+" NAME: "+user.getDisplayName()+" Directory ID: "+user.getDirectoryId());
			if(filters != null && filters.size() >0){
				filtersCount = filtersCount + filters.size();
				Iterator<SearchRequest> srIterator = filters.iterator();
				while(srIterator.hasNext()){
					SearchRequest searchRequest = srIterator.next();
					List<GenericValue> subscriptions = subscriptionManager.getAllSubscriptions(searchRequest.getId());
					if(subscriptions != null && subscriptions.size() >0){
						hasSubscriptions = true;
						log.info("Total Filters: "+filters.size()+" Filter Id: "+searchRequest.getId()+" Subscriptions : "+subscriptions.size());					}
				}
				if(hasSubscriptions){
					try {
						subscriptionManager.deleteSubscriptionsForUser(user);
					} catch (Exception e) {
					log.error("Exception while removing Subscriptions for user: "+user.getDisplayName());
					}
				}
				searchRequestService.deleteAllFiltersForUser(jsc, user);
			}
			userUtil.removeUser(ComponentManager.getInstance().getJiraAuthenticationContext().getLoggedInUser(), user);
			log.info("Removed subscriptions, filters and user...");
		}

OsmanA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 19, 2013

I don't think it picks up filters which aren't associated with a project. For example if you create project 'test' and have a filter 'filter1' which is the query project = "TEST" if you delete the project 'test' it will not delete the filter. Running integrity check will also not delete or even detect the filter.

0 votes
richie_gee
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 16, 2013

Run integrity checked, it should be deleting those is no long associated with anything.

https://confluence.atlassian.com/display/JIRA/Using+the+Database+Integrity+Checker

Hope this helps :)

0 votes
Raju KC
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 16, 2013

Deletion of the filters and subscriptions will need to be done at the database level. There is no other ways.

Thanks!

Suggest an answer

Log in or Sign up to answer