- Progress Update

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-01-26 12:57:06 -05:00
parent b0f4ad7e4f
commit 89224e871c
6 changed files with 425 additions and 64 deletions

View File

@@ -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