Reformat all project files to use the prettier config file.
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
* @type {string[]}
|
||||
*/
|
||||
const adminEmail = [
|
||||
"patrick@imex.dev",
|
||||
//"patrick@imex.test",
|
||||
"patrick@imex.prod",
|
||||
"patrick@imexsystems.ca",
|
||||
"patrick@thinkimex.com",
|
||||
"patrick@imex.dev",
|
||||
//"patrick@imex.test",
|
||||
"patrick@imex.prod",
|
||||
"patrick@imexsystems.ca",
|
||||
"patrick@thinkimex.com"
|
||||
];
|
||||
|
||||
module.exports = adminEmail;
|
||||
module.exports = adminEmail;
|
||||
|
||||
@@ -4,79 +4,84 @@ const getLifecycleStatusColor = require("./getLifecycleStatusColor");
|
||||
const _ = require("lodash");
|
||||
|
||||
const calculateStatusDuration = (transitions, statuses) => {
|
||||
let statusDuration = {};
|
||||
let totalDuration = 0;
|
||||
let totalCurrentStatusDuration = null;
|
||||
let summations = [];
|
||||
let statusDuration = {};
|
||||
let totalDuration = 0;
|
||||
let totalCurrentStatusDuration = null;
|
||||
let summations = [];
|
||||
|
||||
transitions.forEach((transition, index) => {
|
||||
let duration = transition.duration;
|
||||
totalDuration += duration;
|
||||
if (transition.start && !transition.end) {
|
||||
const startMoment = moment(transition.start);
|
||||
const nowMoment = moment();
|
||||
const duration = moment.duration(nowMoment.diff(startMoment));
|
||||
totalCurrentStatusDuration = {
|
||||
value: duration.asMilliseconds(),
|
||||
humanReadable: durationToHumanReadable(duration)
|
||||
};
|
||||
}
|
||||
|
||||
if (!transition.prev_value) {
|
||||
statusDuration[transition.value] = {
|
||||
value: duration,
|
||||
humanReadable: durationToHumanReadable(moment.duration(duration))
|
||||
};
|
||||
} else {
|
||||
if (statusDuration[transition.value]) {
|
||||
statusDuration[transition.value].value += duration;
|
||||
statusDuration[transition.value].humanReadable = durationToHumanReadable(moment.duration(statusDuration[transition.value].value));
|
||||
} else {
|
||||
statusDuration[transition.value] = {
|
||||
value: duration,
|
||||
humanReadable: durationToHumanReadable(moment.duration(duration))
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Calculate the percentage for each status
|
||||
// Calculate the percentage for each status
|
||||
let totalPercentage = 0;
|
||||
const statusKeys = Object.keys(statusDuration);
|
||||
statusKeys.forEach((status, index) => {
|
||||
if (index !== statusKeys.length - 1) {
|
||||
const percentage = (statusDuration[status].value / totalDuration) * 100;
|
||||
totalPercentage += percentage;
|
||||
statusDuration[status].percentage = percentage;
|
||||
} else {
|
||||
statusDuration[status].percentage = 100 - totalPercentage;
|
||||
}
|
||||
});
|
||||
|
||||
for (let [status, {value, humanReadable}] of Object.entries(statusDuration)) {
|
||||
if (status !== 'total') {
|
||||
summations.push({
|
||||
status,
|
||||
value,
|
||||
humanReadable,
|
||||
percentage: statusDuration[status].percentage,
|
||||
color: getLifecycleStatusColor(status),
|
||||
roundedPercentage: `${Math.round(statusDuration[status].percentage)}%`
|
||||
});
|
||||
}
|
||||
transitions.forEach((transition, index) => {
|
||||
let duration = transition.duration;
|
||||
totalDuration += duration;
|
||||
if (transition.start && !transition.end) {
|
||||
const startMoment = moment(transition.start);
|
||||
const nowMoment = moment();
|
||||
const duration = moment.duration(nowMoment.diff(startMoment));
|
||||
totalCurrentStatusDuration = {
|
||||
value: duration.asMilliseconds(),
|
||||
humanReadable: durationToHumanReadable(duration)
|
||||
};
|
||||
}
|
||||
|
||||
const humanReadableTotal = durationToHumanReadable(moment.duration(totalDuration));
|
||||
if (!transition.prev_value) {
|
||||
statusDuration[transition.value] = {
|
||||
value: duration,
|
||||
humanReadable: durationToHumanReadable(moment.duration(duration))
|
||||
};
|
||||
} else {
|
||||
if (statusDuration[transition.value]) {
|
||||
statusDuration[transition.value].value += duration;
|
||||
statusDuration[transition.value].humanReadable = durationToHumanReadable(
|
||||
moment.duration(statusDuration[transition.value].value)
|
||||
);
|
||||
} else {
|
||||
statusDuration[transition.value] = {
|
||||
value: duration,
|
||||
humanReadable: durationToHumanReadable(moment.duration(duration))
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
summations: _.isArray(statuses) && !_.isEmpty(statuses) ? summations.sort((a, b) => {
|
||||
// Calculate the percentage for each status
|
||||
// Calculate the percentage for each status
|
||||
let totalPercentage = 0;
|
||||
const statusKeys = Object.keys(statusDuration);
|
||||
statusKeys.forEach((status, index) => {
|
||||
if (index !== statusKeys.length - 1) {
|
||||
const percentage = (statusDuration[status].value / totalDuration) * 100;
|
||||
totalPercentage += percentage;
|
||||
statusDuration[status].percentage = percentage;
|
||||
} else {
|
||||
statusDuration[status].percentage = 100 - totalPercentage;
|
||||
}
|
||||
});
|
||||
|
||||
for (let [status, { value, humanReadable }] of Object.entries(statusDuration)) {
|
||||
if (status !== "total") {
|
||||
summations.push({
|
||||
status,
|
||||
value,
|
||||
humanReadable,
|
||||
percentage: statusDuration[status].percentage,
|
||||
color: getLifecycleStatusColor(status),
|
||||
roundedPercentage: `${Math.round(statusDuration[status].percentage)}%`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const humanReadableTotal = durationToHumanReadable(moment.duration(totalDuration));
|
||||
|
||||
return {
|
||||
summations:
|
||||
_.isArray(statuses) && !_.isEmpty(statuses)
|
||||
? summations.sort((a, b) => {
|
||||
return statuses.indexOf(a.status) - statuses.indexOf(b.status);
|
||||
}) : summations,
|
||||
totalStatuses: summations.length,
|
||||
total: totalDuration,
|
||||
totalCurrentStatusDuration,
|
||||
humanReadableTotal
|
||||
};
|
||||
}
|
||||
module.exports = calculateStatusDuration;
|
||||
})
|
||||
: summations,
|
||||
totalStatuses: summations.length,
|
||||
total: totalDuration,
|
||||
totalCurrentStatusDuration,
|
||||
humanReadableTotal
|
||||
};
|
||||
};
|
||||
module.exports = calculateStatusDuration;
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const durationToHumanReadable = (duration) => {
|
||||
if (!duration) return 'N/A';
|
||||
if (!duration) return "N/A";
|
||||
|
||||
let parts = [];
|
||||
let parts = [];
|
||||
|
||||
let years = duration.years();
|
||||
let months = duration.months();
|
||||
let days = duration.days();
|
||||
let hours = duration.hours();
|
||||
let minutes = duration.minutes();
|
||||
let seconds = duration.seconds();
|
||||
let years = duration.years();
|
||||
let months = duration.months();
|
||||
let days = duration.days();
|
||||
let hours = duration.hours();
|
||||
let minutes = duration.minutes();
|
||||
let seconds = duration.seconds();
|
||||
|
||||
if (years) parts.push(years + ' year' + (years > 1 ? 's' : ''));
|
||||
if (months) parts.push(months + ' month' + (months > 1 ? 's' : ''));
|
||||
if (days) parts.push(days + ' day' + (days > 1 ? 's' : ''));
|
||||
if (hours) parts.push(hours + ' hour' + (hours > 1 ? 's' : ''));
|
||||
if (minutes) parts.push(minutes + ' minute' + (minutes > 1 ? 's' : ''));
|
||||
if (seconds) parts.push(seconds + ' second' + (seconds > 1 ? 's' : ''));
|
||||
if (years) parts.push(years + " year" + (years > 1 ? "s" : ""));
|
||||
if (months) parts.push(months + " month" + (months > 1 ? "s" : ""));
|
||||
if (days) parts.push(days + " day" + (days > 1 ? "s" : ""));
|
||||
if (hours) parts.push(hours + " hour" + (hours > 1 ? "s" : ""));
|
||||
if (minutes) parts.push(minutes + " minute" + (minutes > 1 ? "s" : ""));
|
||||
if (seconds) parts.push(seconds + " second" + (seconds > 1 ? "s" : ""));
|
||||
|
||||
return parts.join(', ');
|
||||
}
|
||||
module.exports = durationToHumanReadable;
|
||||
return parts.join(", ");
|
||||
};
|
||||
module.exports = durationToHumanReadable;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const crypto = require('crypto');
|
||||
const crypto = require("crypto");
|
||||
|
||||
const getLifecycleStatusColor = (key) => {
|
||||
const hash = crypto.createHash('sha256');
|
||||
hash.update(key);
|
||||
const hashedKey = hash.digest('hex');
|
||||
const num = parseInt(hashedKey, 16);
|
||||
return '#' + (num % 16777215).toString(16).padStart(6, '0');
|
||||
const hash = crypto.createHash("sha256");
|
||||
hash.update(key);
|
||||
const hashedKey = hash.digest("hex");
|
||||
const num = parseInt(hashedKey, 16);
|
||||
return "#" + (num % 16777215).toString(16).padStart(6, "0");
|
||||
};
|
||||
|
||||
module.exports = getLifecycleStatusColor;
|
||||
module.exports = getLifecycleStatusColor;
|
||||
|
||||
@@ -12,18 +12,17 @@ function InstanceManager({ args, instance, debug, executeFunction, rome, promana
|
||||
let propToReturn = null;
|
||||
|
||||
switch (instance || process.env.INSTANCE) {
|
||||
case 'IMEX':
|
||||
case "IMEX":
|
||||
propToReturn = imex;
|
||||
break;
|
||||
case 'ROME':
|
||||
case "ROME":
|
||||
propToReturn = rome; //TODO:AIO Implement USE_IMEX
|
||||
break;
|
||||
case 'PROMANAGER':
|
||||
case "PROMANAGER":
|
||||
//Return the rome prop if USE_ROME.
|
||||
//If not USE_ROME, we want to default back to the rome prop if it's undefined.
|
||||
//If null, we might want to show nothing, so make sure we return null.
|
||||
propToReturn =
|
||||
promanager === 'USE_ROME' ? rome : promanager !== undefined ? promanager : rome;
|
||||
propToReturn = promanager === "USE_ROME" ? rome : promanager !== undefined ? promanager : rome;
|
||||
break;
|
||||
default:
|
||||
propToReturn = imex;
|
||||
@@ -31,17 +30,17 @@ function InstanceManager({ args, instance, debug, executeFunction, rome, promana
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
console.log('InstanceRenderManager Debugger');
|
||||
console.log('=========================');
|
||||
console.log("InstanceRenderManager Debugger");
|
||||
console.log("=========================");
|
||||
console.log({ executeFunction, rome, promanager, imex, debug, propToReturn });
|
||||
console.log('=========================');
|
||||
console.log("=========================");
|
||||
}
|
||||
|
||||
//Checking to see if we need to default to another one.
|
||||
if (propToReturn === 'imex') {
|
||||
if (propToReturn === "imex") {
|
||||
propToReturn = imex;
|
||||
}
|
||||
if (executeFunction && typeof propToReturn === 'function') return propToReturn(...args);
|
||||
if (executeFunction && typeof propToReturn === "function") return propToReturn(...args);
|
||||
return propToReturn === undefined ? null : propToReturn;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
const graylog2 = require("graylog2");
|
||||
|
||||
const logger = new graylog2.graylog({
|
||||
servers: [{host: "logs.bodyshop.app", port: 12201}],
|
||||
servers: [{ host: "logs.bodyshop.app", port: 12201 }]
|
||||
});
|
||||
|
||||
function log(message, type, user, record, object) {
|
||||
if (type !== "ioevent")
|
||||
console.log(message, {
|
||||
type,
|
||||
env: process.env.NODE_ENV || "development",
|
||||
user,
|
||||
record,
|
||||
...object,
|
||||
});
|
||||
logger.log(message, message, {
|
||||
type,
|
||||
env: process.env.NODE_ENV || "development",
|
||||
user,
|
||||
record,
|
||||
...object,
|
||||
if (type !== "ioevent")
|
||||
console.log(message, {
|
||||
type,
|
||||
env: process.env.NODE_ENV || "development",
|
||||
user,
|
||||
record,
|
||||
...object
|
||||
});
|
||||
logger.log(message, message, {
|
||||
type,
|
||||
env: process.env.NODE_ENV || "development",
|
||||
user,
|
||||
record,
|
||||
...object
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {log};
|
||||
module.exports = { log };
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
exports.servertime = (req, res) => {
|
||||
res.status(200).send(new Date());
|
||||
res.status(200).send(new Date());
|
||||
};
|
||||
|
||||
exports.jsrAuth = async (req, res) => {
|
||||
res.send(
|
||||
"Basic " +
|
||||
Buffer.from(
|
||||
`${process.env.JSR_USER}:${process.env.JSR_PASSWORD}`
|
||||
).toString("base64")
|
||||
);
|
||||
res.send("Basic " + Buffer.from(`${process.env.JSR_USER}:${process.env.JSR_PASSWORD}`).toString("base64"));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user