mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-31 04:14:34 +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 {
|
||||
formatDateTime,
|
||||
formatDuration,
|
||||
formatDurationToHHMMSS,
|
||||
getEpochMillisForPastDays,
|
||||
getIntervalInMilliseconds,
|
||||
} from '../../../../utils/date-time/DateTimeUtils';
|
||||
@ -220,14 +220,14 @@ const AppRunsHistory = forwardRef(
|
||||
key: 'executionTime',
|
||||
render: (_, record: AppRunRecordWithId) => {
|
||||
if (isExternalApp && record.executionTime) {
|
||||
return formatDuration(record.executionTime);
|
||||
return formatDurationToHHMMSS(record.executionTime);
|
||||
}
|
||||
|
||||
if (record.startTime) {
|
||||
const endTime = record.endTime || Date.now(); // Use current time in epoch milliseconds if endTime is not present
|
||||
const ms = getIntervalInMilliseconds(record.startTime, endTime);
|
||||
|
||||
return formatDuration(ms);
|
||||
return formatDurationToHHMMSS(ms);
|
||||
} else {
|
||||
return NO_DATA_PLACEHOLDER;
|
||||
}
|
||||
|
@ -107,6 +107,10 @@ jest.mock('../../../../utils/date-time/DateTimeUtils', () => ({
|
||||
getEpochMillisForPastDays: jest.fn().mockReturnValue('startDay'),
|
||||
getIntervalInMilliseconds: jest.fn().mockReturnValue('interval'),
|
||||
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', () =>
|
||||
|
@ -309,6 +309,9 @@ export const formatDuration = (ms: number) => {
|
||||
return pluralize(hours, 'hour');
|
||||
}
|
||||
};
|
||||
export const formatDurationToHHMMSS = (ms: number) => {
|
||||
return Duration.fromMillis(ms).toFormat('hh:mm:ss');
|
||||
};
|
||||
|
||||
export const getStartOfDayInMillis = (timestamp: number) =>
|
||||
DateTime.fromMillis(timestamp).toUTC().startOf('day').toMillis();
|
||||
|
Loading…
x
Reference in New Issue
Block a user