We need to reduce total count of fields in-use in a project.
Need to find out under-utilized fields. Maybe this is possible by finding out if a field has not been updated since long time, by looking up in change history of only in those issues where intended field is not empty ?
Or maybe there's any other ways ?
Any possibilities/ideas much appreciated.
Thanks much
Able to get something working for a field as follows
{code}
import com.atlassian.core.util.DateUtils
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.web.bean.PagerFilter
import java.time.ZoneOffset
def searchService = ComponentAccessor.getComponent(SearchService)
def issueManager = ComponentAccessor.issueManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
//get recent issues in reverse order of creation
def jql = /project = 'ProjectA' and 'Field1' is not EMPTY order by Created desc/
def parseResult = searchService.parseQuery(currentUser, jql)
assert parseResult.isValid(): "The following JQL was not valid: $jql"
def results = searchService.search(currentUser, parseResult.query, PagerFilter.unlimitedFilter)
def latestIssue = results.getResults().head()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeItems = changeHistoryManager.getChangeItemsForField(latestIssue, 'Field1')
if (changeItems?.size() > 0) {
def lastupdated = DateUtils.getDurationString((new Date().getTime() - changeItems.created.head().getTime()) / 1000 as Long)
log.debug(lastupdated)
}
{code}
Where as foll. doesn't, as it is another version with additional one more field, to find out for many fields in same script
{code}
import com.atlassian.core.util.DateUtils
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.web.bean.PagerFilter
import java.time.ZoneOffset
def searchService = ComponentAccessor.getComponent(SearchService)
def issueManager = ComponentAccessor.issueManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
//get recent issues in reverse order of creation
def myFieldList = ['Field1']
for (myFieldName in myFieldList) {
def jql = /project = 'ProjectA' and '$myFieldName' is not EMPTY order by Created desc/
def parseResult = searchService.parseQuery(currentUser, jql)
assert parseResult.isValid(): "The following JQL was not valid: $jql"
def results = searchService.search(currentUser, parseResult.query, PagerFilter.unlimitedFilter)
def latestIssue = results.getResults().head()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeItems = changeHistoryManager.getChangeItemsForField(latestIssue, '$myFieldName')
if (changeItems?.size() > 0) {
def lastupdated = DateUtils.getDurationString((new Date().getTime() - changeItems.created.head().getTime()) / 1000 as Long)
log.debug(lastupdated)
}
{code}
Comparison as follows
Not sure why it doesn't seem to return anything.
Any clue, much appreciated
Thanks.
For volume of fields used, you can run JQL such as "<field> is not empty" - if it returns 3, you can say people aren't using the field much, if it returns 30,000, you know they are!
If you do get a large result, it might also be worth looking at the actual usage - if it's a select list, you'll probably want to consider a field unused if every usage of it is the same. And then there's people who've done silly things like default text in text fields so 99% of your issues have a description filled with a default.
Recently updated is a bit more difficult, but @Ismael Jimoh covered it (changeitem and changegroup are the right names!)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can narrow this down also with a JQL search of custom field is not empty AnD updated within specific date Order By updated.
Though this doesn’t give you exactly what you want, you still get all issues which match your preferences and it lets you see if the field has been updated recently via issue history.
For something more concrete you need to dig this from your database as you rightly mentioned. Check the changegroup and changeitem tables(please double check the names again as they may not be 100% correct).
Regards.
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.