From 52d1dea9fb0eeb9c51cfc9ab72f47fa5163e3747 Mon Sep 17 00:00:00 2001 From: Lanius-collaris <55432068+Lanius-collaris@users.noreply.github.com> Date: Sun, 7 Jan 2024 04:10:28 +0800 Subject: [PATCH] CustomTooltip: change link to measurements (#884) --- components/aggregation/mat/CustomTooltip.js | 24 ++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/components/aggregation/mat/CustomTooltip.js b/components/aggregation/mat/CustomTooltip.js index 2c27050be..c38a78fbb 100644 --- a/components/aggregation/mat/CustomTooltip.js +++ b/components/aggregation/mat/CustomTooltip.js @@ -41,9 +41,27 @@ export const generateSearchQuery = (data, query) => { // use that value to limit date range on `/search` page if ('measurement_start_day' in data) { sinceFilter = data.measurement_start_day - const untilPlus1 = new Date(Date.parse(sinceFilter)) - untilPlus1.setUTCDate(untilPlus1.getUTCDate() + 1) - untilFilter = untilPlus1.toISOString().split('T')[0] + const untilDateObj = new Date(Date.parse(sinceFilter)) + switch(query.time_grain){ + case 'hour': + untilDateObj.setUTCHours(untilDateObj.getUTCHours() + 1) + break + case 'week': + untilDateObj.setUTCDate(untilDateObj.getUTCDate() + 7) + break + case 'month': + untilDateObj.setUTCMonth(untilDateObj.getUTCMonth() + 1) + break + default: + untilDateObj.setUTCDate(untilDateObj.getUTCDate() + 1) + break + } + untilFilter = untilDateObj.toISOString() + if (query.time_grain !== 'hour') { + untilFilter = untilFilter.split('T')[0] + } else { + untilFilter = untilFilter.split('.')[0] + 'Z' + } } const queryObj = ['probe_cc', 'test_name', 'category_code', 'probe_asn', 'input', 'domain'].reduce((q, k) => {