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

Improve readability of pending activities #304

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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