qiaojialin commented on a change in pull request #2016:
URL: https://github.com/apache/iotdb/pull/2016#discussion_r522578247



##########
File path: 
grafana/src/main/java/org/apache/iotdb/web/grafana/controller/DatabaseConnectController.java
##########
@@ -165,7 +165,7 @@ private void setJsonTable(JsonObject obj, String target,
     for (TimeValues tv : timeValues) {
       JsonArray value = new JsonArray();
       value.add(tv.getTime());
-      values.add(GSON.toJsonTree(tv.getValue()));
+      value.add(GSON.toJsonTree(tv.getValue()));

Review comment:
       this looks reasonable, is this a bug before?

##########
File path: 
grafana/src/main/java/org/apache/iotdb/web/grafana/dao/impl/BasicDaoImpl.java
##########
@@ -133,31 +133,44 @@ public static void setTimestampRadioX(String 
timestampPrecision) {
   }
 
   public List<TimeValues> querySeriesInternal(String s, Pair<ZonedDateTime, 
ZonedDateTime> timeRange, String function) {
-      Long from = zonedCovertToLong(timeRange.left);
+    Long from = zonedCovertToLong(timeRange.left);
     Long to = zonedCovertToLong(timeRange.right);
     final long hours = Duration.between(timeRange.left, 
timeRange.right).toHours();
+
     String sql = String.format("SELECT %s FROM root.%s WHERE time > %d and 
time < %d",
         s.substring(s.lastIndexOf('.') + 1), s.substring(0, 
s.lastIndexOf('.')),
         from * timestampRadioX, to * timestampRadioX);
     String columnName = "root." + s;
-    if (isDownSampling && (hours > 1)) {
-      if (hours < 30 * 24 && hours > 24) {
-        interval = "1h";
-      } else if (hours > 30 * 24) {
-        interval = "1d";
-      }
+
+    String internalLocal = getInternal(hours);

Review comment:
       interval?

##########
File path: grafana/pom.xml
##########
@@ -85,6 +85,12 @@
             <version>${spring-boot.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter</artifactId>
+            <version>RELEASE</version>
+            <scope>test</scope>

Review comment:
       Hi, what's this for?
   I removed this and the test is also passed...

##########
File path: 
grafana/src/test/java/org/apache/iotdb/web/grafana/dao/impl/BasicDaoImplTest.java
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.web.grafana.dao.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.test.util.ReflectionTestUtils;
+
+import static org.junit.Assert.*;
+
+public class BasicDaoImplTest {
+
+
+    @Before
+    public void setUp() throws Exception {
+    }
+
+    @After
+    public void tearDown() throws Exception {
+    }
+
+    @Test
+    public void getInternal() {
+        BasicDaoImpl impl = new BasicDaoImpl(null);
+        ReflectionTestUtils.setField(impl, "isDownSampling", true);
+        ReflectionTestUtils.setField(impl, "interval", "1m");
+
+        String internal1 = impl.getInternal(0);
+        assert internal1.equals("");
+
+        String internal2 = impl.getInternal(3);
+        System.out.println("123");

Review comment:
       please remove the print




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to