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:
Shrushti Polekar 2025-04-29 10:55:59 +05:30 committed by GitHub
parent d33e068692
commit 6e9c4a827d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View File

@ -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;
}

View File

@ -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', () =>

View File

@ -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();