From 218743878c935c586b820a43a178581b1bd0d573 Mon Sep 17 00:00:00 2001 From: Rohith Date: Tue, 9 Apr 2024 15:47:09 -0400 Subject: [PATCH] adds additional date ranges for DateRangeParameter --- .../dynamic-parameters/DateRangeParameter.jsx | 48 +++++++++++++++++++ .../services/parameters/DateRangeParameter.js | 34 +++++++++++++ 2 files changed, 82 insertions(+) diff --git a/client/app/components/dynamic-parameters/DateRangeParameter.jsx b/client/app/components/dynamic-parameters/DateRangeParameter.jsx index ea8bf8b1d3..fb83708c31 100644 --- a/client/app/components/dynamic-parameters/DateRangeParameter.jsx +++ b/client/app/components/dynamic-parameters/DateRangeParameter.jsx @@ -61,6 +61,14 @@ const DYNAMIC_DATE_OPTIONS = [ .value()[0] .format("YYYY"), }, + { + name: "Last 2 days", + value: getDynamicDateRangeFromString("d_last_2_days"), + label: () => + getDynamicDateRangeFromString("d_last_2_days") + .value()[0] + .format("MMM D") + " - Today", + }, { name: "Last 7 days", value: getDynamicDateRangeFromString("d_last_7_days"), @@ -109,6 +117,46 @@ const DYNAMIC_DATE_OPTIONS = [ ]; const DYNAMIC_DATETIME_OPTIONS = [ + { + name: "Last 5 minutes", + value: getDynamicDateRangeFromString("d_last_5_minutes"), + label: null + }, + { + name: "Last 15 minutes", + value: getDynamicDateRangeFromString("d_last_15_minutes"), + label: null + }, + { + name: "Last 30 minutes", + value: getDynamicDateRangeFromString("d_last_30_minutes"), + label: null + }, + { + name: "Last hour", + value: getDynamicDateRangeFromString("d_last_hour"), + label: null + }, + { + name: "Last 3 hours", + value: getDynamicDateRangeFromString("d_last_3_hours"), + label: null + }, + { + name: "Last 6 hours", + value: getDynamicDateRangeFromString("d_last_6_hours"), + label: null + }, + { + name: "Last 12 hours", + value: getDynamicDateRangeFromString("d_last_12_hours"), + label: null + }, + { + name: "Last 24 hours", + value: getDynamicDateRangeFromString("d_last_24_hours"), + label: null + }, { name: "Today", value: getDynamicDateRangeFromString("d_today"), diff --git a/client/app/services/parameters/DateRangeParameter.js b/client/app/services/parameters/DateRangeParameter.js index dc284ae29b..2e7130a7a2 100644 --- a/client/app/services/parameters/DateRangeParameter.js +++ b/client/app/services/parameters/DateRangeParameter.js @@ -80,18 +80,52 @@ const DYNAMIC_DATE_RANGES = { .endOf("year"), ], }, + last_5_minutes: { + name: "Last 5 minutes", + value: untilNow(() => moment().subtract(5, "minutes")), + }, + last_15_minutes: { + name: "Last 15 minutes", + value: untilNow(() => moment().subtract(15, "minutes")), + }, + last_30_minutes: { + name: "Last 30 minutes", + value: untilNow(() => moment().subtract(30, "minutes")), + }, last_hour: { name: "Last hour", value: untilNow(() => moment().subtract(1, "hour")), }, + last_3_hours: { + name: "Last 3 hours", + value: untilNow(() => moment().subtract(3, "hour")), + }, + last_6_hours: { + name: "Last 6 hours", + value: untilNow(() => moment().subtract(6, "hour")), + }, last_8_hours: { name: "Last 8 hours", value: untilNow(() => moment().subtract(8, "hour")), }, + last_12_hours: { + name: "Last 12 hours", + value: untilNow(() => moment().subtract(12, "hour")), + }, last_24_hours: { name: "Last 24 hours", value: untilNow(() => moment().subtract(24, "hour")), }, + last_2_days: { + name: "Last 2 days", + value: untilNow( + () => + moment() + .subtract(2, "days") + .startOf("day"), + () => moment().endOf("day") + ), + }, last_7_days: { name: "Last 7 days", value: untilNow(