From ffef667deae0f9de0b4b0ce9632ad3916771ceac Mon Sep 17 00:00:00 2001 From: Samuel Greene Date: Thu, 7 Mar 2024 18:03:25 -0800 Subject: [PATCH 1/3] Update datemath expressions for better caching (and fix subtle bugs) Signed-off-by: Samuel Greene --- .../src/utils/dateUtil.js | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/provider-elasticsearch/src/utils/dateUtil.js b/packages/provider-elasticsearch/src/utils/dateUtil.js index ac66d38af..c5694e83b 100644 --- a/packages/provider-elasticsearch/src/utils/dateUtil.js +++ b/packages/provider-elasticsearch/src/utils/dateUtil.js @@ -27,21 +27,22 @@ let quarterToOffset = { } // https://www.elastic.co/guide/en/elasticsearch/reference/7.x/common-options.html#date-math +// -1ms is because ranges use `<=` and not `<` export let rangeToDatemath = { - last1Hour: { from: 'now-1h', to: 'now' }, - last1Day: { from: 'now-1d', to: 'now' }, - last3Days: { from: 'now-3d', to: 'now' }, - last7Days: { from: 'now-7d', to: 'now' }, - last30Days: { from: 'now-30d', to: 'now' }, - last90Days: { from: 'now-90d', to: 'now' }, - last180Days: { from: 'now-180d', to: 'now' }, - last12Months: { from: 'now/d-12M', to: 'now' }, - last15Months: { from: 'now/d-15M', to: 'now' }, - last18Months: { from: 'now/d-18M', to: 'now' }, - last24Months: { from: 'now/d-24M', to: 'now' }, - last36Months: { from: 'now/d-36M', to: 'now' }, - last48Months: { from: 'now/d-48M', to: 'now' }, - last60Months: { from: 'now/d-60M', to: 'now' }, + last1Hour: { from: 'now/h-1h', to: 'now/h-1ms' }, + last1Day: { from: 'now/d-1d', to: 'now/d-1ms' }, + last3Days: { from: 'now/d-3d', to: 'now/d-1ms' }, + last7Days: { from: 'now/d-7d', to: 'now/d-1ms' }, + last30Days: { from: 'now/d-30d', to: 'now/d-1ms' }, + last90Days: { from: 'now/d-90d', to: 'now/d-1ms' }, + last180Days: { from: 'now/d-180d', to: 'now/d-1ms' }, + last12Months: { from: 'now/d-12M', to: 'now/d-1ms' }, + last15Months: { from: 'now/d-15M', to: 'now/d-1ms' }, + last18Months: { from: 'now/d-18M', to: 'now/d-1ms' }, + last24Months: { from: 'now/d-24M', to: 'now/d-1ms' }, + last36Months: { from: 'now/d-36M', to: 'now/d-1ms' }, + last48Months: { from: 'now/d-48M', to: 'now/d-1ms' }, + last60Months: { from: 'now/d-60M', to: 'now/d-1ms' }, lastCalendarMonth: { from: 'now-1M/M', to: 'now/M-1ms' }, lastCalendarYear: { from: 'now-1y/y', to: 'now/y-1ms' }, thisCalendarMonth: { from: 'now/M', to: 'now+1M/M-1ms' }, From 15a6881fe439893e545c68cb2845e0cd6b8e21d7 Mon Sep 17 00:00:00 2001 From: Samuel Greene Date: Thu, 7 Mar 2024 18:06:09 -0800 Subject: [PATCH 2/3] Add changeset Signed-off-by: Samuel Greene --- .changeset/young-fireants-compete.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/young-fireants-compete.md diff --git a/.changeset/young-fireants-compete.md b/.changeset/young-fireants-compete.md new file mode 100644 index 000000000..ad23d50af --- /dev/null +++ b/.changeset/young-fireants-compete.md @@ -0,0 +1,5 @@ +--- +"contexture-elasticsearch": patch +--- + + Fixes date math expressions that were missing rounding and 1ms offset. Should improve caching and fix subtle bugs. From a18af87f3ca59dc440686e045013283defc9de22 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Fri, 8 Mar 2024 02:06:28 +0000 Subject: [PATCH 3/3] Fix code style issues with Prettier --- .changeset/young-fireants-compete.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/young-fireants-compete.md b/.changeset/young-fireants-compete.md index ad23d50af..a52f31293 100644 --- a/.changeset/young-fireants-compete.md +++ b/.changeset/young-fireants-compete.md @@ -1,5 +1,5 @@ --- -"contexture-elasticsearch": patch +'contexture-elasticsearch': patch --- - Fixes date math expressions that were missing rounding and 1ms offset. Should improve caching and fix subtle bugs. +Fixes date math expressions that were missing rounding and 1ms offset. Should improve caching and fix subtle bugs.