From 671a9d8a74964fbf2f728103af433e7c45d9b1d8 Mon Sep 17 00:00:00 2001 From: Marco Antonio Ghiani Date: Mon, 6 Mar 2023 15:02:28 +0100 Subject: [PATCH] [Infrastructure UI] Fix Hosts View date picker for some preset values (#152339) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## ๐Ÿ““ Summary Closes #151150 The issue was caused by a missing rounding up when the same string represented dates. ## ๐Ÿงช Testing - Navigates to Hosts View page. - Set date-picker to `Today`. - Verify data are correctly fetched. Repeat the same setting the picker to `This week` https://user-images.githubusercontent.com/34506779/221857418-dbc53fe6-6eca-4645-93cd-b939231e76b0.mov Co-authored-by: Marco Antonio Ghiani --- .../pages/metrics/hosts/hooks/use_unified_search_url_state.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/hooks/use_unified_search_url_state.ts b/x-pack/plugins/infra/public/pages/metrics/hosts/hooks/use_unified_search_url_state.ts index 41e476dbf12c5..2c7eb84dd43bf 100644 --- a/x-pack/plugins/infra/public/pages/metrics/hosts/hooks/use_unified_search_url_state.ts +++ b/x-pack/plugins/infra/public/pages/metrics/hosts/hooks/use_unified_search_url_state.ts @@ -79,7 +79,8 @@ export const useHostsUrlState = () => { const getDateRangeAsTimestamp = useCallback(() => { const from = DateMath.parse(state.dateRange.from)?.valueOf() ?? getDefaultFromTimestamp(); - const to = DateMath.parse(state.dateRange.to)?.valueOf() ?? getDefaultToTimestamp(); + const to = + DateMath.parse(state.dateRange.to, { roundUp: true })?.valueOf() ?? getDefaultToTimestamp(); return { from, to }; }, [state.dateRange]);