- human readable dates
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -54,7 +54,9 @@ export function JobLifecycleComponent({bodyshop, job, ...rest}) {
|
||||
'duration',
|
||||
'type',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
'updated_at',
|
||||
'start_readable',
|
||||
'end_readable',
|
||||
];
|
||||
|
||||
const columns = columnKeys.map(key => ({
|
||||
@@ -71,7 +73,7 @@ export function JobLifecycleComponent({bodyshop, job, ...rest}) {
|
||||
const entires = Object
|
||||
.entries(lifecycleData.durations)
|
||||
.filter(([name, value]) => {
|
||||
return value !== 0;
|
||||
return value > 0;
|
||||
})
|
||||
|
||||
return entires.map(([name, value], index) => (
|
||||
@@ -88,7 +90,7 @@ export function JobLifecycleComponent({bodyshop, job, ...rest}) {
|
||||
*/
|
||||
const durationsData = useCallback(() => {
|
||||
return Object.entries(lifecycleData.durations) .filter(([name, value]) => {
|
||||
return value !== 0;
|
||||
return value > 0;
|
||||
}).map(([name, value]) => ({
|
||||
name,
|
||||
value: value / 1000
|
||||
@@ -108,7 +110,7 @@ export function JobLifecycleComponent({bodyshop, job, ...rest}) {
|
||||
<Timeline>
|
||||
{lifecycleData.lifecycle.map((item, index) => (
|
||||
<Timeline.Item key={index} color={item.value === 'Open' ? 'green' : item.value === 'Scheduled' ? 'yellow' : 'red'}>
|
||||
{item.value} - {new Date(item.start).toLocaleString()}
|
||||
{item.value} - {item.start_readable}
|
||||
</Timeline.Item>
|
||||
))}
|
||||
</Timeline>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const _ = require("lodash");
|
||||
const queries = require("../graphql-client/queries");
|
||||
const moment = require("moment");
|
||||
|
||||
const calculateStatusDuration = (transitions) => {
|
||||
let statusDuration = {};
|
||||
@@ -52,17 +53,30 @@ const jobLifecycle = async (req, res) => {
|
||||
|
||||
}
|
||||
|
||||
|
||||
const transitionsByJobId = _.groupBy(resp.transitions, 'jobid');
|
||||
|
||||
const groupedTransitions = {};
|
||||
|
||||
moment.relativeTimeThreshold('m', 30)
|
||||
for (let jobId in transitionsByJobId) {
|
||||
let lifecycle = transitionsByJobId[jobId].map(transition => {
|
||||
if (transition.start) {
|
||||
transition.start_readable = moment(transition.start).fromNow();
|
||||
}
|
||||
if (transition.end) {
|
||||
transition.end_readable = moment(transition.end).fromNow();
|
||||
}
|
||||
return transition;
|
||||
});
|
||||
|
||||
groupedTransitions[jobId] = {
|
||||
lifecycle: transitionsByJobId[jobId],
|
||||
durations: calculateStatusDuration(transitionsByJobId[jobId])
|
||||
lifecycle: lifecycle,
|
||||
durations: calculateStatusDuration(lifecycle)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
console.dir(groupedTransitions, {depth: null});
|
||||
|
||||
return res.status(200).json({
|
||||
jobIDs,
|
||||
transition: groupedTransitions,
|
||||
|
||||
Reference in New Issue
Block a user