-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AO] Reuse overview bucket size in AlertSummaryWidget (#150453)
Resolves #150290 ## Summary - Reuse the overview bucket size in AlertSummaryWidget. - Use `scaled date format` setting instead of `niceTimeFormatter` in observability overview charts Before ![image](https://user-images.githubusercontent.com/12370520/217490029-06fa183e-c2f2-4d86-a09d-bde77ac45e07.png) After ![image](https://user-images.githubusercontent.com/12370520/217492571-207c27eb-e7a0-4d90-998f-7f79beca4c02.png)
- Loading branch information
1 parent
3ae7d70
commit 6e58c2d
Showing
13 changed files
with
162 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...lity/public/pages/overview/containers/overview_page/helpers/calculate_bucket_size.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { TimeBuckets } from '@kbn/data-plugin/common'; | ||
import { calculateTimeRangeBucketSize } from './calculate_bucket_size'; | ||
|
||
describe('calculateTimeRangeBucketSize', () => { | ||
const timeBucketConfig = { | ||
'histogram:maxBars': 4, | ||
'histogram:barTarget': 3, | ||
dateFormat: 'YYYY-MM-DD', | ||
'dateFormat:scaled': [ | ||
['', 'HH:mm:ss.SSS'], | ||
['PT1S', 'HH:mm:ss'], | ||
['PT1M', 'HH:mm'], | ||
['PT1H', 'YYYY-MM-DD HH:mm'], | ||
['P1DT', 'YYYY-MM-DD'], | ||
['P1YT', 'YYYY'], | ||
], | ||
}; | ||
const timeBuckets = new TimeBuckets(timeBucketConfig); | ||
|
||
it.each([ | ||
// 15 minutes | ||
['2023-01-09T12:07:54.441Z', '2023-01-09T12:22:54.441Z', 60, '60s', 'HH:mm'], | ||
['now-15m', 'now', 60, '60s', 'HH:mm'], | ||
// 30 minutes | ||
['2023-01-09T11:53:43.605Z', '2023-01-09T12:23:43.605Z', 60, '60s', 'HH:mm'], | ||
// 1 hour | ||
['2023-01-09T11:22:05.728Z', '2023-01-09T12:22:05.728Z', 60, '60s', 'HH:mm'], | ||
// 24 hours | ||
['2023-01-08T12:00:00.000Z', '2023-01-09T12:24:30.853Z', 600, '600s', 'HH:mm'], | ||
// 7 days | ||
['2023-01-01T23:00:00.000Z', '2023-01-09T12:29:38.101Z', 3600, '3600s', 'YYYY-MM-DD HH:mm'], | ||
// 30 days | ||
['2022-12-09T23:00:00.000Z', '2023-01-09T12:30:13.717Z', 43200, '43200s', 'YYYY-MM-DD HH:mm'], | ||
// 90 days | ||
['2022-10-10T22:00:00.000Z', '2023-01-09T12:32:11.537Z', 43200, '43200s', 'YYYY-MM-DD HH:mm'], | ||
// 1 year | ||
['2022-01-08T23:00:00.000Z', '2023-01-09T12:33:09.906Z', 86400, '86400s', 'YYYY-MM-DD'], | ||
])( | ||
`Input: [%s, %s], Output: bucketSize: %s, intervalString: %s, dateFormat: %s `, | ||
(from, to, bucketSize, intervalString, dateFormat) => { | ||
expect(calculateTimeRangeBucketSize({ from, to }, timeBuckets)).toEqual({ | ||
bucketSize, | ||
intervalString, | ||
dateFormat, | ||
}); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.