Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,361,325
Community Members
 
Community Events
168
Community Groups

How to calculate the average time to close a ticket?

Edited

Hello everyone,I would appreciate any help.

Please tell me, I'm trying to improve my report, and add the average closing time for users from the list there. How can I add this?

 

уцацуац3а.png

ERGREG.png

My report on the scriptrunner :

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.web.bean.PagerFilter;
import com.atlassian.mail.Email;

issueManager = ComponentAccessor.getIssueManager();
customFieldManager = ComponentAccessor.getCustomFieldManager();
regprov_sla = customFieldManager.getCustomFieldObjectByName("SLA_US_Reaction");

// Body
results = '<html><body><h3>Weekly report</h3><br>'
results += '<b> Report project : REGPROV</b>.<br />'
results += '<table><tr><th>Assignee</th><th>Amount ticket</th><th>&nbspAverage task completion time</th></tr>'
jql = 'project = REGPROV AND status = Closed AND resolved >= startOfWeek() '
assignee_jql = ['a.emelyanenko','a.shafranova','o.gorbunova','d.kunitsyna','g.voytovich','e.povaga','a.avramenko','v.vorobeva']

issues = getIssues(jql)


for(assignee in assignee_jql){

    jql2 = jql + ' AND assignee = "'+assignee+'"'
    issues = getIssues(jql2)
    issueSize = issues.size
    Integer avh = 0
    Integer count = 0

for (issue in issues){
    sla_val = issue.getCustomFieldValue(regprov_sla);
    println "TEST recieved $issue: handling $sla_val"
  }
  results += '<tr><th>'+assignee+'</th><th>'+issueSize.toString()+'</th></tr>'
}
results += '</table><br /><br /><br />'
today = new Date().toTimestamp()
results +='<br /><small> DATE REPORT: '+today+'</small>'
results += '</body></html>'

sendEmail('my_mailbox@gmail.com','REPORT', results)
return results

def getIssues(jql)
{
    resultIssues = []
    int start = 0
    int get = 100
    searchService = ComponentAccessor.getComponent(SearchService.class)
    user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
    issueManager = ComponentAccessor.getIssueManager()
    parseResult =  searchService.parseQuery(user, jql)
    exist = true
    while (exist)

    {
        pageFilter = new PagerFilter(start, get)
        searchResult = searchService.search(user, parseResult.getQuery(), pageFilter)
        issues = searchResult.results.collect {issueManager.getIssueObject(it.id)}
        if (!issues) { exist = false }
        resultIssues += issues;
        start += get;

        println "TEST recieved " + resultIssues.size() + " issues for $jql"
    }
    return resultIssues
}

def sendEmail(emailAddr, subject, body) {
mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer();

if (mailServer) {
Email email = new Email(emailAddr);
email.setSubject(subject);
email.setBody(body);
email.addHeader('Content-Type','text/html')
mailServer.send(email);
}
else {
// Problem getting the mail server from JIRA configuration, log this error
}
}

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

An unofficial way to monitor a JSM mail handler for errors

...eturns true if any content is returned for the webResponse.body.data.first s...

714 views 3 20
Read article

Atlassian Community Events