The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate the average time to close a ticket?

Alex
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 Champions.
September 7, 2022

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

TAGS
AUG Leaders

Atlassian Community Events