mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-02 13:43:22 +00:00
Update formatting for duration in application configuration (#20987)
* update formatting for duration in application configuration * fix unit test case * address pr comment
This commit is contained in:
parent
d33e068692
commit
6e9c4a827d
@ -45,7 +45,7 @@ import { getApplicationRuns } from '../../../../rest/applicationAPI';
|
|||||||
import { getStatusTypeForApplication } from '../../../../utils/ApplicationUtils';
|
import { getStatusTypeForApplication } from '../../../../utils/ApplicationUtils';
|
||||||
import {
|
import {
|
||||||
formatDateTime,
|
formatDateTime,
|
||||||
formatDuration,
|
formatDurationToHHMMSS,
|
||||||
getEpochMillisForPastDays,
|
getEpochMillisForPastDays,
|
||||||
getIntervalInMilliseconds,
|
getIntervalInMilliseconds,
|
||||||
} from '../../../../utils/date-time/DateTimeUtils';
|
} from '../../../../utils/date-time/DateTimeUtils';
|
||||||
@ -220,14 +220,14 @@ const AppRunsHistory = forwardRef(
|
|||||||
key: 'executionTime',
|
key: 'executionTime',
|
||||||
render: (_, record: AppRunRecordWithId) => {
|
render: (_, record: AppRunRecordWithId) => {
|
||||||
if (isExternalApp && record.executionTime) {
|
if (isExternalApp && record.executionTime) {
|
||||||
return formatDuration(record.executionTime);
|
return formatDurationToHHMMSS(record.executionTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (record.startTime) {
|
if (record.startTime) {
|
||||||
const endTime = record.endTime || Date.now(); // Use current time in epoch milliseconds if endTime is not present
|
const endTime = record.endTime || Date.now(); // Use current time in epoch milliseconds if endTime is not present
|
||||||
const ms = getIntervalInMilliseconds(record.startTime, endTime);
|
const ms = getIntervalInMilliseconds(record.startTime, endTime);
|
||||||
|
|
||||||
return formatDuration(ms);
|
return formatDurationToHHMMSS(ms);
|
||||||
} else {
|
} else {
|
||||||
return NO_DATA_PLACEHOLDER;
|
return NO_DATA_PLACEHOLDER;
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,10 @@ jest.mock('../../../../utils/date-time/DateTimeUtils', () => ({
|
|||||||
getEpochMillisForPastDays: jest.fn().mockReturnValue('startDay'),
|
getEpochMillisForPastDays: jest.fn().mockReturnValue('startDay'),
|
||||||
getIntervalInMilliseconds: jest.fn().mockReturnValue('interval'),
|
getIntervalInMilliseconds: jest.fn().mockReturnValue('interval'),
|
||||||
formatDuration: jest.fn().mockReturnValue('formatDuration'),
|
formatDuration: jest.fn().mockReturnValue('formatDuration'),
|
||||||
|
formatDurationToHHMMSS: jest.fn().mockImplementation((_ms) => {
|
||||||
|
// Return a consistent formatted duration for all cases
|
||||||
|
return '02:30:15';
|
||||||
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
jest.mock('../../../common/ErrorWithPlaceholder/ErrorPlaceHolder', () =>
|
jest.mock('../../../common/ErrorWithPlaceholder/ErrorPlaceHolder', () =>
|
||||||
|
@ -309,6 +309,9 @@ export const formatDuration = (ms: number) => {
|
|||||||
return pluralize(hours, 'hour');
|
return pluralize(hours, 'hour');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
export const formatDurationToHHMMSS = (ms: number) => {
|
||||||
|
return Duration.fromMillis(ms).toFormat('hh:mm:ss');
|
||||||
|
};
|
||||||
|
|
||||||
export const getStartOfDayInMillis = (timestamp: number) =>
|
export const getStartOfDayInMillis = (timestamp: number) =>
|
||||||
DateTime.fromMillis(timestamp).toUTC().startOf('day').toMillis();
|
DateTime.fromMillis(timestamp).toUTC().startOf('day').toMillis();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user