Would love to add a time function to my Groovy script? Help?

Kurt Newcomb December 8, 2014

Hey all,

 

Been trying to figure out how to modify this script to make it so that i'm able to add a date range to this Script, or a "since" field where i can add a date – running it as is we are returning too many results:

package eventim.scripts

import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.web.bean.PagerFilter
 
jqlQuery = 'project = DEV'
fromProject = 'PUP'
result = ''

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()

getFilterResult(jqlQuery,log).each{ Issue issue ->
    oldKeys = changeHistoryManager.getPreviousIssueKeys(issue.id)
    oldKeys.findAll{it==~/$fromProject.*/}.each{
        result += "$it -> ${issue.key}\n"
    }
}
return result

List<Issue> getFilterResult(String jqlSearch, log) {
    def searchService = ComponentAccessor.getComponent(SearchService.class);
    def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
    List<Issue> issues = null

    def parseResult =  searchService.parseQuery(user, jqlSearch);
    if (parseResult.isValid()) {
        def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
        issues = searchResult.issues
    } else {
        log.error("Invalid JQL: " + jqlSearch);
    }
    return issues
}

1 answer

0 votes
Verve Admin April 13, 2015

Change your jql to include your date ranges... replace the dates with the date range you are looking to search for.

 

jqlQuery = 'project = DEV and resolved >= 2015-04-01 AND resolved <= 2015-04-12'
fromProject = 'PUP'
result = ''

Suggest an answer

Log in or Sign up to answer