This is an automated email from the ASF dual-hosted git repository.

qiuxiafan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


The following commit(s) were added to refs/heads/main by this push:
     new d613e588 Fix bugs time query range will not automatically update and 
add some new time query ranges (#757)
d613e588 is described below

commit d613e5882a2f6d702def3152d60d99953eb9b586
Author: peachisai <2581009...@qq.com>
AuthorDate: Sun Sep 7 23:06:01 2025 +0800

    Fix bugs time query range will not automatically update and add some new 
time query ranges (#757)
---
 ui/src/components/common/data.js | 38 +++++++++++++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 7 deletions(-)

diff --git a/ui/src/components/common/data.js b/ui/src/components/common/data.js
index 083182c7..d34f2125 100644
--- a/ui/src/components/common/data.js
+++ b/ui/src/components/common/data.js
@@ -17,27 +17,51 @@
 
 export const Last15Minutes = 900 * 1000;
 
-const LastWeek = 3600 * 1000 * 24 * 7;
+export const Last30Minutes = 1800 * 1000;
 
-const LastMonth = 3600 * 1000 * 24 * 30;
+export const LastHour = 3600 * 1000;
 
-const Last3Months = 3600 * 1000 * 24 * 90;
+export const LastDay = 3600 * 1000 * 24;
+
+export const LastWeek = 3600 * 1000 * 24 * 7;
+
+export const LastMonth = 3600 * 1000 * 24 * 30;
+
+export const Last3Months = 3600 * 1000 * 24 * 90;
 
 export const Shortcuts = [
   {
     text: 'Last 15 minutes',
-    value: [new Date(new Date().getTime() - Last15Minutes), new Date()],
+    value: () => createRange(Last15Minutes),
+  },
+  {
+    text: 'Last 30 minutes',
+    value: () => createRange(Last30Minutes),
+  },
+  {
+    text: 'Last hour',
+    value: () => createRange(LastHour),
+  },
+  {
+    text: 'Last day',
+    value: () => createRange(LastDay),
   },
   {
     text: 'Last week',
-    value: [new Date(new Date().getTime() - LastWeek), new Date()],
+    value: () => createRange(LastWeek),
   },
   {
     text: 'Last month',
-    value: [new Date(new Date().getTime() - LastMonth), new Date()],
+    value: () => createRange(LastMonth),
   },
   {
     text: 'Last 3 months',
-    value: [new Date(new Date().getTime() - Last3Months), new Date()],
+    value: () => createRange(Last3Months),
   },
 ];
+
+function createRange(duration) {
+  const end = new Date();
+  const start = new Date(end.getTime() - duration);
+  return [start, end];
+}

Reply via email to