mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Search] Fix duration bug (#184110)
## Summary This fixes a bug in connector sync durations where hours would wrap around to 0 after one day.
This commit is contained in:
parent
ce4375f770
commit
123cbca48d
2 changed files with 5 additions and 1 deletions
|
@ -14,6 +14,9 @@ describe('durationToText', () => {
|
|||
it('should correctly turn duration into text', () => {
|
||||
expect(durationToText(moment.duration(11005, 'seconds'))).toEqual('3h 3m 25s');
|
||||
});
|
||||
it('should correctly turn days into hours', () => {
|
||||
expect(durationToText(moment.duration(100980, 'seconds'))).toEqual('28h 3m 0s');
|
||||
});
|
||||
it('should return -- for undefined', () => {
|
||||
expect(durationToText(undefined)).toEqual('--');
|
||||
});
|
||||
|
|
|
@ -17,10 +17,11 @@ export function getSyncJobDuration(syncJob: ConnectorSyncJob): moment.Duration |
|
|||
|
||||
export function durationToText(input?: moment.Duration): string {
|
||||
if (input) {
|
||||
const days = input.days();
|
||||
const hours = input.hours();
|
||||
const minutes = input.minutes();
|
||||
const seconds = input.seconds();
|
||||
return `${hours}h ${minutes}m ${seconds}s`;
|
||||
return `${hours + days * 24}h ${minutes}m ${seconds}s`;
|
||||
} else {
|
||||
return '--';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue