Days for assignee custom field

hello eazybi team,

i imported the custom field “days for assignee” in eazybi and have some doubts that the outcome is correct.
i need in fact the following:
if an issues is created it goes through some states until it is closed. inbetween the assignees’ change also within the states (means status = new but assignee might change from A to B and back to A and so on). what i need is the cummulated time an issue was assigned to a specific user until a ticket is solved or even better the time until now.
when i use the days for assignee custom field it evaluates only the “solved” tickets and the numbers are not correct, there are to less issues listed.
can someone help me here or is there another way to show what i need?

the following code i used for the custom field:

[jira.customfield_days_for_assignee]
name = “Days for assignee”
data_type = “decimal”
measure = true
multiple_dimensions = [“Time”,“Assignee”]
javascript_code = ‘’’
var assigneehistory = new Array();
var datefrom = issue.fields.created;
var assignee = null;
resolution = false;

issue.changelog.histories.forEach(function(history){
history.items.forEach(function(historyItem){
if (historyItem.field == “assignee” && ! resolution) {
assignee = historyItem.from;
dateto = history.created;
if(assignee){
duration = (Date.parse(dateto) - Date.parse(datefrom)) / 1000 / 60 / 60 / 24;
assigneehistory.push(dateto.toString().substr(0,10) + “,” + assignee + “,” + duration);
}
datefrom = dateto;
assignee = historyItem.to;
}
if (historyItem.field == “resolution”) {
if (historyItem.to) resolution = true;
else resolution = false;
}
});
});

if (issue.fields.resolutiondate && (issue.fields.assignee || assignee)) {
if (!assignee) assignee = issue.fields.assignee.name;
duration = (Date.parse(issue.fields.resolutiondate) - Date.parse(datefrom)) / 1000 / 60 / 60 / 24;
assigneehistory.push(issue.fields.resolutiondate.toString().substr(0,10) + “,” + assignee + “,” + duration);
}

issue.fields.customfield_days_for_assignee = assigneehistory.join("\n");
‘’’

thanks in advance,

philipp