@@ -11,7 +11,7 @@ const getColor = (key) => {
|
||||
return '#' + (num % 16777215).toString(16).padStart(6, '0');
|
||||
};
|
||||
|
||||
const calculateStatusDuration = (transitions) => {
|
||||
const calculateStatusDuration = (transitions, statuses) => {
|
||||
let statusDuration = {};
|
||||
let totalDuration = 0;
|
||||
let summations = [];
|
||||
@@ -64,14 +64,24 @@ const calculateStatusDuration = (transitions) => {
|
||||
|
||||
for (let [status, {value, humanReadable}] of Object.entries(statusDuration)) {
|
||||
if (status !== 'total') {
|
||||
summations.push({status, value, humanReadable, percentage: statusDuration[status].percentage, color: getColor(status), roundedPercentage: `${Math.round(statusDuration[status].percentage)}%`});
|
||||
summations.push({
|
||||
status,
|
||||
value,
|
||||
humanReadable,
|
||||
percentage: statusDuration[status].percentage,
|
||||
color: getColor(status),
|
||||
roundedPercentage: `${Math.round(statusDuration[status].percentage)}%`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const humanReadableTotal = durationToHumanReadable(moment.duration(totalDuration));
|
||||
|
||||
|
||||
return {
|
||||
summations: _.orderBy(summations, ['value'], ['asc']),
|
||||
summations: _.isArray(statuses) && !_.isEmpty(statuses) ? summations.sort((a, b) => {
|
||||
return statuses.indexOf(a.status) - statuses.indexOf(b.status);
|
||||
}) : summations,
|
||||
totalStatuses: summations.length,
|
||||
total: totalDuration,
|
||||
humanReadableTotal
|
||||
|
||||
Reference in New Issue
Block a user