How to calculate issue resolution time per assignee (not using hours spent)

Hi,

I would like to calculate issue resolution time per each assignee involved and display it report where rows have assignees and columns have months.  

I created a custom field "Time per assignee" and added Javascript code to calculate measure values :

[jira.customfield_time_per_assignee]
name = "Time per assignee"
data_type = "decimal"
measure = true
multiple_dimensions = ["Time","Assignee"]
javascript_code = '''
var divider = 1000 * 60 * 60;
var assigneehistory = new Array();
var datefrom = issue.fields.created;
var assignee = "unassigned";
var assigneeItem = null;
var resolutionItem = null;
var resolution = null;
var resolutionDate = null;

issue.changelog.histories.forEach(function(history)
{
dateto = history.created;
history.items.forEach(function(historyItem)
{
if (historyItem.field == "assignee") {
assigneeItem = historyItem;
}
else if (historyItem.field == "resolution") {
resolutionItem = historyItem;
}
});
if (assigneeItem)
{
if ((!resolutionItem || resolutionItem.to) && !resolution)
{
assignee = assigneeItem.from ? assigneeItem.from : "unassigned";
duration = (Date.parse(dateto) - Date.parse(datefrom)) / divider;
assigneehistory.push(assignee + "," + duration);
}
datefrom = dateto;
assignee = assigneeItem.to ? assigneeItem.to : "unassigned";
}
if (resolutionItem)
{
if (!assigneeItem)
{
if (resolutionItem.to && !resolution)
{
duration = (Date.parse(dateto) - Date.parse(datefrom)) / divider;
assigneehistory.push(assignee + "," + duration);
}
datefrom = dateto;
}
resolution = resolutionItem ? resolutionItem.to : null;
resolutionDate = dateto;
}
resolutionItem = null;
assigneeItem = null;
});
for(i = 0; i < assigneehistory.length; i++) {
assigneehistory[i] = resolutionDate.toString().substr(0,10) + "," + assigneehistory[i];
}
issue.fields.customfield_time_per_assignee = assigneehistory.join("\n");
'''

This woks when issue has assignee, but unfortunately, my issues doesn't... Adding custom field something like "Resolved by" and using it instead of  Assignee (multiple_dimensions = ["Time","Resolved by"]) doesn't help, because the cube import throws an error telling that "Resolved by" cannot be used in multiple dimensions...

How could i solve this ? Is there an esier way to calculate how much time some  user was the assignee of an issue?

 

Thanks

0 answers

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

39 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you