Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
Improve readability of pending activities (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
feedmeapples authored Apr 8, 2021
1 parent fe25383 commit b03cea1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions client/helpers/get-key-value-pairs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import moment from 'moment';
import { failureKeys, jsonKeys, preKeys } from '~constants';
import { timestampToDate } from '~helpers';

function failureToString(failure) {
let res = '';
Expand All @@ -22,6 +23,20 @@ function failureToString(failure) {
return res;
}

const scheduledTimeView = time => {
const scheduledTime = timestampToDate(time);
const now = moment.now();
let res = scheduledTime.format('lll');

if (scheduledTime > now) {
const delta = moment.duration(scheduledTime - now);

res = `${res} (in ${delta.format()})`;
}

return res;
};

const getKeyValuePairs = event => {
const kvps = [];
const flatten = (prefix, obj, root) => {
Expand Down Expand Up @@ -84,6 +99,10 @@ const getKeyValuePairs = event => {
},
value,
});
} else if (key === 'scheduledTime') {
kvps.push({ key, value: scheduledTimeView(value) });
} else if (key === 'lastHeartbeatTime') {
kvps.push({ key, value: timestampToDate(value).format('lll') });
} else if (key === 'taskQueue.name' || key === 'Taskqueue') {
kvps.push({
key,
Expand Down
1 change: 1 addition & 0 deletions server/temporal-client/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ function enumTransform(item) {
'archival_state',
'retry_state',
'severity',
'pending_activity_state',
];

const itemL = item.toLowerCase();
Expand Down

0 comments on commit b03cea1

Please sign in to comment.