From b6204c9c417fa14e28d316851256caf9d0fed89f Mon Sep 17 00:00:00 2001 From: slguan Date: Fri, 8 Nov 2019 15:58:12 +0800 Subject: [PATCH] fix grafana bugs --- src/modules/http/src/gcJson.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/modules/http/src/gcJson.c b/src/modules/http/src/gcJson.c index 92ddfaab79..0cb20ec7e1 100644 --- a/src/modules/http/src/gcJson.c +++ b/src/modules/http/src/gcJson.c @@ -92,7 +92,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, return false; } - bool us = taos_result_precision(result) == TSDB_TIME_PRECISION_MICRO; + int precision = taos_result_precision(result); // such as select count(*) from sys.cpu // such as select count(*) from sys.cpu group by ipaddr @@ -151,7 +151,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, snprintf(target, HTTP_GC_TARGET_SIZE, "%s%s", aliasBuffer, (char *)row[groupFields]); break; case TSDB_DATA_TYPE_TIMESTAMP: - if (us) { + if (precision == TSDB_TIME_PRECISION_MILLI) { snprintf(target, HTTP_GC_TARGET_SIZE, "%s%ld", aliasBuffer, *((int64_t *) row[groupFields])); } else { snprintf(target, HTTP_GC_TARGET_SIZE, "%s%ld", aliasBuffer, *((int64_t *) row[groupFields]) / 1000); @@ -210,7 +210,11 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, httpJsonStringForTransMean(jsonBuf, row[i], fields[i].bytes); break; case TSDB_DATA_TYPE_TIMESTAMP: - httpJsonInt64(jsonBuf, *((int64_t *)row[i])); + if (precision == TSDB_TIME_PRECISION_MILLI) { //ms + httpJsonInt64(jsonBuf, *((int64_t *)row[i])); + } else { + httpJsonInt64(jsonBuf, *((int64_t *)row[i]) / 1000); + } break; default: httpJsonString(jsonBuf, "invalidcol", 10); -- GitLab