Skip to content

Instantly share code, notes, and snippets.

@jechlin-adaptavist
Created May 19, 2020 16:52
Show Gist options
  • Save jechlin-adaptavist/18f9d7f2dd6a44c5d58ca05c33e2cd28 to your computer and use it in GitHub Desktop.
Save jechlin-adaptavist/18f9d7f2dd6a44c5d58ca05c33e2cd28 to your computer and use it in GitHub Desktop.
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.builder.JqlQueryBuilder
import com.atlassian.jira.util.thread.JiraThreadLocalUtils
def searchService = ComponentAccessor.getComponent(SearchService)
def customFieldManager = ComponentAccessor.customFieldManager
def storyPointsCf = customFieldManager.getCustomFieldObjectByName('Story Points')
def issue = event.issue
Thread.start {
sleep(1_000)
JiraThreadLocalUtils.preCall()
try {
def builder = JqlQueryBuilder.newBuilder()
def query = builder.where().issue(issue.key).and().customField(storyPointsCf.idAsLong).notEq(0).buildQuery()
def count = searchService.searchCountOverrideSecurity(event.user, query)
if (count > 0) {
log.error("Issue: ${issue.key} was not indexed properly", new Exception('indexing failure'))
}
}
finally {
JiraThreadLocalUtils.postCall(log, null)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment