From 9679169e6ff1f1842c06ffee49dcb937507d4041 Mon Sep 17 00:00:00 2001
From: LXW <1264174498@qq.com>
Date: Wed, 6 Dec 2023 18:02:20 +0800
Subject: [PATCH] (improvement)(semantic) Metric homepage download supports
choosing whether to transform (#477)
Co-authored-by: jolunoluo
---
.../mapper/custom/ShowCaseCustomMapper.xml | 7 +-
.../supersonic/common/pojo/DateConf.java | 15 +-
.../src/test/resources/application-local.yaml | 5 +-
.../response/QueryResultWithSchemaResp.java | 22 ++-
.../api/query/request/BatchDownloadReq.java | 2 +
.../api/query/request/DownloadStructReq.java | 14 ++
.../semantic/query/rest/QueryController.java | 13 +-
.../query/service/DownloadService.java | 4 +-
.../query/service/DownloadServiceImpl.java | 185 ++++++++++--------
.../query/utils/DataTransformUtils.java | 6 +-
.../query/utils/DataTransformUtilsTest.java | 4 +-
11 files changed, 172 insertions(+), 105 deletions(-)
create mode 100644 semantic/api/src/main/java/com/tencent/supersonic/semantic/api/query/request/DownloadStructReq.java
diff --git a/chat/core/src/main/resources/mapper/custom/ShowCaseCustomMapper.xml b/chat/core/src/main/resources/mapper/custom/ShowCaseCustomMapper.xml
index 0ec84e7aa..e59bbf1fb 100644
--- a/chat/core/src/main/resources/mapper/custom/ShowCaseCustomMapper.xml
+++ b/chat/core/src/main/resources/mapper/custom/ShowCaseCustomMapper.xml
@@ -61,16 +61,15 @@
from (
select *
from s2_chat_query
- where query_state = 1 and agent_id = ${agentId} and (score is null or score > 1)
+ where query_state = 1 and agent_id = ${agentId} and score = 5
and user_name = #{userName}
- order by score, chat_id desc
+ order by chat_id desc
) a
limit #{start}, #{limit}
) q2 on q1.chat_id = q2.chat_id
- where agent_id = ${agentId} and (score is null or score > 1)
- order by score desc
+ where agent_id = ${agentId} and score = 5
diff --git a/common/src/main/java/com/tencent/supersonic/common/pojo/DateConf.java b/common/src/main/java/com/tencent/supersonic/common/pojo/DateConf.java
index 93d69986c..fca502dfe 100644
--- a/common/src/main/java/com/tencent/supersonic/common/pojo/DateConf.java
+++ b/common/src/main/java/com/tencent/supersonic/common/pojo/DateConf.java
@@ -1,11 +1,13 @@
package com.tencent.supersonic.common.pojo;
-import static java.time.LocalDate.now;
+import com.tencent.supersonic.common.util.DateUtils;
+import lombok.Data;
+import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
-import lombok.Data;
+import static java.time.LocalDate.now;
@Data
public class DateConf {
@@ -44,6 +46,15 @@ public class DateConf {
private boolean isInherited;
+ public List getDateList() {
+ if (!CollectionUtils.isEmpty(dateList)) {
+ return dateList;
+ }
+ String startDateStr = getStartDate();
+ String endDateStr = getEndDate();
+ return DateUtils.getDateList(startDateStr, endDateStr, getPeriod());
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
diff --git a/launchers/standalone/src/test/resources/application-local.yaml b/launchers/standalone/src/test/resources/application-local.yaml
index aecfef6b2..779a8b05e 100644
--- a/launchers/standalone/src/test/resources/application-local.yaml
+++ b/launchers/standalone/src/test/resources/application-local.yaml
@@ -4,8 +4,6 @@ spring:
path: /h2-console/chat
# enabled web
enabled: true
- demo:
- enabled: true
datasource:
driver-class-name: org.h2.Driver
schema: classpath:db/schema-h2.sql
@@ -14,6 +12,9 @@ spring:
username: root
password: semantic
+demo:
+ enabled: true
+
server:
port: 9080
diff --git a/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/response/QueryResultWithSchemaResp.java b/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/response/QueryResultWithSchemaResp.java
index 72ddcd66c..8a5bc5ecb 100644
--- a/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/response/QueryResultWithSchemaResp.java
+++ b/semantic/api/src/main/java/com/tencent/supersonic/semantic/api/model/response/QueryResultWithSchemaResp.java
@@ -1,20 +1,34 @@
package com.tencent.supersonic.semantic.api.model.response;
+import com.google.common.collect.Lists;
import com.tencent.supersonic.common.pojo.QueryAuthorization;
import com.tencent.supersonic.common.pojo.QueryColumn;
+import com.tencent.supersonic.semantic.api.model.enums.SemanticTypeEnum;
import com.tencent.supersonic.semantic.api.model.pojo.QueryResult;
-import java.util.List;
-import java.util.Map;
-
import lombok.Data;
import lombok.ToString;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
@Data
@ToString
public class QueryResultWithSchemaResp extends QueryResult