mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-15 14:36:47 +00:00
(improvement)(headless) Remove redundant user dimensions in demo data (#663)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -31,10 +31,6 @@ import com.tencent.supersonic.common.pojo.SysParameter;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.common.service.SysParameterService;
|
||||
import com.tencent.supersonic.common.util.JsonUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -43,6 +39,11 @@ import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@Order(3)
|
||||
@@ -185,7 +186,7 @@ public class ChatDemoLoader implements CommandLineRunner {
|
||||
|
||||
ChatDetailConfigReq chatDetailConfig = new ChatDetailConfigReq();
|
||||
ChatDefaultConfigReq chatDefaultConfigDetail = new ChatDefaultConfigReq();
|
||||
List<Long> dimensionIds0 = Collections.singletonList(3L);
|
||||
List<Long> dimensionIds0 = new ArrayList<>();
|
||||
List<Long> metricIds0 = Arrays.asList(1L, 2L);
|
||||
chatDefaultConfigDetail.setDimensionIds(dimensionIds0);
|
||||
chatDefaultConfigDetail.setMetricIds(metricIds0);
|
||||
@@ -198,7 +199,7 @@ public class ChatDemoLoader implements CommandLineRunner {
|
||||
|
||||
ChatAggConfigReq chatAggConfig = new ChatAggConfigReq();
|
||||
ChatDefaultConfigReq chatDefaultConfigAgg = new ChatDefaultConfigReq();
|
||||
List<Long> dimensionIds1 = Arrays.asList(3L);
|
||||
List<Long> dimensionIds1 = new ArrayList<>();
|
||||
List<Long> metricIds1 = Arrays.asList(1L, 2L);
|
||||
chatDefaultConfigAgg.setDimensionIds(dimensionIds1);
|
||||
chatDefaultConfigAgg.setMetricIds(metricIds1);
|
||||
@@ -224,8 +225,8 @@ public class ChatDemoLoader implements CommandLineRunner {
|
||||
|
||||
ChatDetailConfigReq chatDetailConfig = new ChatDetailConfigReq();
|
||||
ChatDefaultConfigReq chatDefaultConfigDetail = new ChatDefaultConfigReq();
|
||||
List<Long> dimensionIds0 = Arrays.asList(4L, 5L);
|
||||
List<Long> metricIds0 = Arrays.asList(3L);
|
||||
List<Long> dimensionIds0 = Collections.singletonList(3L);
|
||||
List<Long> metricIds0 = Collections.singletonList(4L);
|
||||
chatDefaultConfigDetail.setDimensionIds(dimensionIds0);
|
||||
chatDefaultConfigDetail.setMetricIds(metricIds0);
|
||||
chatDefaultConfigDetail.setUnit(7);
|
||||
@@ -237,8 +238,8 @@ public class ChatDemoLoader implements CommandLineRunner {
|
||||
|
||||
ChatAggConfigReq chatAggConfig = new ChatAggConfigReq();
|
||||
ChatDefaultConfigReq chatDefaultConfigAgg = new ChatDefaultConfigReq();
|
||||
List<Long> dimensionIds1 = Arrays.asList(4L, 5L);
|
||||
List<Long> metricIds1 = Arrays.asList(3L);
|
||||
List<Long> dimensionIds1 = Collections.singletonList(3L);
|
||||
List<Long> metricIds1 = Collections.singletonList(4L);
|
||||
chatDefaultConfigAgg.setDimensionIds(dimensionIds1);
|
||||
chatDefaultConfigAgg.setMetricIds(metricIds1);
|
||||
chatDefaultConfigAgg.setUnit(7);
|
||||
@@ -263,8 +264,8 @@ public class ChatDemoLoader implements CommandLineRunner {
|
||||
|
||||
ChatDetailConfigReq chatDetailConfig = new ChatDetailConfigReq();
|
||||
ChatDefaultConfigReq chatDefaultConfigDetail = new ChatDefaultConfigReq();
|
||||
List<Long> dimensionIds0 = Arrays.asList(6L, 7L, 8L, 9L);
|
||||
List<Long> metricIds0 = Arrays.asList(4L);
|
||||
List<Long> dimensionIds0 = Arrays.asList(4L, 5L, 6L, 7L);
|
||||
List<Long> metricIds0 = Arrays.asList(5L);
|
||||
chatDefaultConfigDetail.setDimensionIds(dimensionIds0);
|
||||
chatDefaultConfigDetail.setMetricIds(metricIds0);
|
||||
chatDefaultConfigDetail.setUnit(7);
|
||||
@@ -276,8 +277,8 @@ public class ChatDemoLoader implements CommandLineRunner {
|
||||
|
||||
ChatAggConfigReq chatAggConfig = new ChatAggConfigReq();
|
||||
ChatDefaultConfigReq chatDefaultConfigAgg = new ChatDefaultConfigReq();
|
||||
List<Long> dimensionIds1 = Arrays.asList(6L, 7L, 8L, 9L);
|
||||
List<Long> metricIds1 = Arrays.asList(4L);
|
||||
List<Long> dimensionIds1 = Arrays.asList(4L, 4L, 6L, 7L);
|
||||
List<Long> metricIds1 = Arrays.asList(5L);
|
||||
chatDefaultConfigAgg.setDimensionIds(dimensionIds1);
|
||||
chatDefaultConfigAgg.setMetricIds(metricIds1);
|
||||
chatDefaultConfigAgg.setUnit(7);
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.tencent.supersonic.headless.api.enums.MetricDefineType;
|
||||
import com.tencent.supersonic.headless.api.enums.SemanticType;
|
||||
import com.tencent.supersonic.headless.api.pojo.Dim;
|
||||
import com.tencent.supersonic.headless.api.pojo.DimensionTimeTypeParams;
|
||||
import com.tencent.supersonic.headless.api.pojo.DrillDownDimension;
|
||||
import com.tencent.supersonic.headless.api.pojo.Field;
|
||||
import com.tencent.supersonic.headless.api.pojo.FieldParam;
|
||||
import com.tencent.supersonic.headless.api.pojo.Identify;
|
||||
@@ -29,6 +30,7 @@ import com.tencent.supersonic.headless.api.pojo.MetricDefineByMeasureParams;
|
||||
import com.tencent.supersonic.headless.api.pojo.MetricDefineByMetricParams;
|
||||
import com.tencent.supersonic.headless.api.pojo.MetricParam;
|
||||
import com.tencent.supersonic.headless.api.pojo.ModelDetail;
|
||||
import com.tencent.supersonic.headless.api.pojo.RelateDimension;
|
||||
import com.tencent.supersonic.headless.api.request.DatabaseReq;
|
||||
import com.tencent.supersonic.headless.api.request.DimensionReq;
|
||||
import com.tencent.supersonic.headless.api.request.DomainReq;
|
||||
@@ -88,6 +90,7 @@ public class ModelDemoDataLoader {
|
||||
addModel_4();
|
||||
updateDimension();
|
||||
updateMetric();
|
||||
updateMetric_pv();
|
||||
addAuthGroup_1();
|
||||
addAuthGroup_2();
|
||||
} catch (Exception e) {
|
||||
@@ -140,7 +143,7 @@ public class ModelDemoDataLoader {
|
||||
modelReq.setAdminOrgs(Collections.emptyList());
|
||||
ModelDetail modelDetail = new ModelDetail();
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
identifiers.add(new Identify("用户", IdentifyType.primary.name(), "user_name"));
|
||||
identifiers.add(new Identify("用户", IdentifyType.primary.name(), "user_name", 1));
|
||||
modelDetail.setIdentifiers(identifiers);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
@@ -171,7 +174,7 @@ public class ModelDemoDataLoader {
|
||||
modelReq.setAdminOrgs(Collections.emptyList());
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
ModelDetail modelDetail = new ModelDetail();
|
||||
identifiers.add(new Identify("用户名", IdentifyType.primary.name(), "s2_pv_uv_statis_user_name"));
|
||||
identifiers.add(new Identify("用户名", IdentifyType.primary.name(), "user_name", 0));
|
||||
modelDetail.setIdentifiers(identifiers);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
@@ -189,13 +192,13 @@ public class ModelDemoDataLoader {
|
||||
measures.add(measure2);
|
||||
modelDetail.setMeasures(measures);
|
||||
List<Field> fields = Lists.newArrayList();
|
||||
fields.add(Field.builder().fieldName("s2_pv_uv_statis_user_name").dataType("Varchar").build());
|
||||
fields.add(Field.builder().fieldName("user_name").dataType("Varchar").build());
|
||||
fields.add(Field.builder().fieldName("imp_date").dataType("Date").build());
|
||||
fields.add(Field.builder().fieldName("page").dataType("Varchar").build());
|
||||
fields.add(Field.builder().fieldName("pv").dataType("Long").build());
|
||||
fields.add(Field.builder().fieldName("user_id").dataType("Varchar").build());
|
||||
modelDetail.setFields(fields);
|
||||
modelDetail.setSqlQuery("SELECT imp_date, user_name as s2_pv_uv_statis_user_name, page, 1 as pv, "
|
||||
modelDetail.setSqlQuery("SELECT imp_date, user_name, page, 1 as pv, "
|
||||
+ "user_name as user_id FROM s2_pv_uv_statis");
|
||||
modelDetail.setQueryType("sql_query");
|
||||
modelReq.setDomainId(1L);
|
||||
@@ -215,7 +218,7 @@ public class ModelDemoDataLoader {
|
||||
modelReq.setAdminOrgs(Collections.emptyList());
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
ModelDetail modelDetail = new ModelDetail();
|
||||
identifiers.add(new Identify("用户名称", IdentifyType.primary.name(), "stay_hours_user_name"));
|
||||
identifiers.add(new Identify("用户", IdentifyType.primary.name(), "user_name", 0));
|
||||
modelDetail.setIdentifiers(identifiers);
|
||||
|
||||
List<Dim> dimensions = new ArrayList<>();
|
||||
@@ -232,13 +235,12 @@ public class ModelDemoDataLoader {
|
||||
measures.add(measure1);
|
||||
modelDetail.setMeasures(measures);
|
||||
List<Field> fields = Lists.newArrayList();
|
||||
fields.add(Field.builder().fieldName("stay_hours_user_name").dataType("Varchar").build());
|
||||
fields.add(Field.builder().fieldName("user_name").dataType("Varchar").build());
|
||||
fields.add(Field.builder().fieldName("imp_date").dataType("Date").build());
|
||||
fields.add(Field.builder().fieldName("page").dataType("Varchar").build());
|
||||
fields.add(Field.builder().fieldName("stay_hours").dataType("Double").build());
|
||||
modelDetail.setFields(fields);
|
||||
modelDetail.setSqlQuery(
|
||||
"select imp_date,user_name as stay_hours_user_name,stay_hours,page from s2_stay_time_statis");
|
||||
modelDetail.setSqlQuery("select imp_date,user_name,stay_hours,page from s2_stay_time_statis");
|
||||
modelDetail.setQueryType("sql_query");
|
||||
modelReq.setDomainId(1L);
|
||||
modelReq.setModelDetail(modelDetail);
|
||||
@@ -247,7 +249,7 @@ public class ModelDemoDataLoader {
|
||||
|
||||
public void addModelRela_1() {
|
||||
List<JoinCondition> joinConditions = Lists.newArrayList();
|
||||
joinConditions.add(new JoinCondition("user_name", "s2_pv_uv_statis_user_name", FilterOperatorEnum.EQUALS));
|
||||
joinConditions.add(new JoinCondition("user_name", "user_name", FilterOperatorEnum.EQUALS));
|
||||
ModelRela modelRelaReq = new ModelRela();
|
||||
modelRelaReq.setDomainId(1L);
|
||||
modelRelaReq.setFromModelId(1L);
|
||||
@@ -259,7 +261,7 @@ public class ModelDemoDataLoader {
|
||||
|
||||
public void addModelRela_2() {
|
||||
List<JoinCondition> joinConditions = Lists.newArrayList();
|
||||
joinConditions.add(new JoinCondition("user_name", "stay_hours_user_name", FilterOperatorEnum.EQUALS));
|
||||
joinConditions.add(new JoinCondition("user_name", "user_name", FilterOperatorEnum.EQUALS));
|
||||
ModelRela modelRelaReq = new ModelRela();
|
||||
modelRelaReq.setDomainId(1L);
|
||||
modelRelaReq.setFromModelId(1L);
|
||||
@@ -295,7 +297,7 @@ public class ModelDemoDataLoader {
|
||||
modelReq.setAdminOrgs(Collections.emptyList());
|
||||
ModelDetail modelDetail = new ModelDetail();
|
||||
List<Identify> identifiers = new ArrayList<>();
|
||||
Identify identify = new Identify("歌手名", IdentifyType.primary.name(), "singer_name");
|
||||
Identify identify = new Identify("歌手名", IdentifyType.primary.name(), "singer_name", 1);
|
||||
identify.setEntityNames(Lists.newArrayList("歌手", "艺人"));
|
||||
identifiers.add(identify);
|
||||
modelDetail.setIdentifiers(identifiers);
|
||||
@@ -325,9 +327,8 @@ public class ModelDemoDataLoader {
|
||||
|
||||
public void updateDimension() throws Exception {
|
||||
DimensionReq dimensionReq = new DimensionReq();
|
||||
dimensionReq.setModelId(1L);
|
||||
dimensionReq.setType(DimensionType.categorical.name());
|
||||
dimensionReq.setId(4L);
|
||||
dimensionReq.setId(3L);
|
||||
dimensionReq.setName("页面");
|
||||
dimensionReq.setBizName("page");
|
||||
dimensionReq.setModelId(3L);
|
||||
@@ -359,6 +360,26 @@ public class ModelDemoDataLoader {
|
||||
metricTypeParams.setMeasures(measures);
|
||||
metricReq.setMetricDefineByMeasureParams(metricTypeParams);
|
||||
metricReq.setMetricDefineType(MetricDefineType.MEASURE);
|
||||
metricReq.setRelateDimension(getRelateDimension(Lists.newArrayList(1L, 2L)));
|
||||
metricService.updateMetric(metricReq, user);
|
||||
}
|
||||
|
||||
public void updateMetric_pv() throws Exception {
|
||||
MetricReq metricReq = new MetricReq();
|
||||
metricReq.setModelId(2L);
|
||||
metricReq.setId(1L);
|
||||
metricReq.setName("访问次数");
|
||||
metricReq.setBizName("pv");
|
||||
MetricDefineByMeasureParams metricTypeParams = new MetricDefineByMeasureParams();
|
||||
metricTypeParams.setExpr("s2_pv_uv_statis_pv");
|
||||
List<MeasureParam> measures = new ArrayList<>();
|
||||
MeasureParam measure = new MeasureParam("s2_pv_uv_statis_pv",
|
||||
"", AggOperatorEnum.SUM.getOperator());
|
||||
measures.add(measure);
|
||||
metricTypeParams.setMeasures(measures);
|
||||
metricReq.setMetricDefineByMeasureParams(metricTypeParams);
|
||||
metricReq.setMetricDefineType(MetricDefineType.MEASURE);
|
||||
metricReq.setRelateDimension(getRelateDimension(Lists.newArrayList(1L, 2L)));
|
||||
metricService.updateMetric(metricReq, user);
|
||||
}
|
||||
|
||||
@@ -373,10 +394,15 @@ public class ModelDemoDataLoader {
|
||||
MetricDefineByFieldParams metricTypeParams = new MetricDefineByFieldParams();
|
||||
metricTypeParams.setExpr("count(distinct user_id)");
|
||||
List<FieldParam> fieldParams = new ArrayList<>();
|
||||
fieldParams.add(FieldParam.builder().fieldName("user_id").build());
|
||||
fieldParams.add(new FieldParam("user_id"));
|
||||
metricTypeParams.setFields(fieldParams);
|
||||
RelateDimension relateDimension = new RelateDimension();
|
||||
relateDimension.setDrillDownDimensions(Lists.newArrayList(
|
||||
new DrillDownDimension(1L)));
|
||||
metricReq.setRelateDimension(relateDimension);
|
||||
metricReq.setMetricDefineByFieldParams(metricTypeParams);
|
||||
metricReq.setMetricDefineType(MetricDefineType.FIELD);
|
||||
metricReq.setRelateDimension(getRelateDimension(Lists.newArrayList(1L)));
|
||||
metricService.createMetric(metricReq, user);
|
||||
}
|
||||
|
||||
@@ -399,6 +425,7 @@ public class ModelDemoDataLoader {
|
||||
metricTypeParams.setMetrics(metrics);
|
||||
metricReq.setMetricDefineByMetricParams(metricTypeParams);
|
||||
metricReq.setMetricDefineType(MetricDefineType.METRIC);
|
||||
metricReq.setRelateDimension(getRelateDimension(Lists.newArrayList(1L)));
|
||||
metricService.createMetric(metricReq, user);
|
||||
}
|
||||
|
||||
@@ -431,11 +458,19 @@ public class ModelDemoDataLoader {
|
||||
authRules.add(authRule);
|
||||
|
||||
authGroupReq.setAuthRules(authRules);
|
||||
authGroupReq.setDimensionFilters(Collections.singletonList("department in ('sales')"));
|
||||
authGroupReq.setDimensionFilterDescription("部门 in [sales]");
|
||||
authGroupReq.setDimensionFilters(Collections.singletonList("user_name = 'tom'"));
|
||||
authGroupReq.setDimensionFilterDescription("用户名='tom'");
|
||||
authGroupReq.setAuthorizedUsers(Collections.singletonList("tom"));
|
||||
authGroupReq.setAuthorizedDepartmentIds(Collections.emptyList());
|
||||
authService.addOrUpdateAuthGroup(authGroupReq);
|
||||
}
|
||||
|
||||
private RelateDimension getRelateDimension(List<Long> dimensionIds) {
|
||||
RelateDimension relateDimension = new RelateDimension();
|
||||
for (Long id : dimensionIds) {
|
||||
relateDimension.getDrillDownDimensions().add(new DrillDownDimension(id));
|
||||
}
|
||||
return relateDimension;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,14 +5,14 @@ dean _1_2 36
|
||||
john _1_2 50
|
||||
jack _1_2 38
|
||||
admin _1_2 70
|
||||
周杰伦 _4_9 100
|
||||
陈奕迅 _4_9 100
|
||||
林俊杰 _4_9 100
|
||||
张碧晨 _4_9 100
|
||||
程响 _4_9 100
|
||||
Taylor#Swift _4_9 100
|
||||
内地 _4_6 100
|
||||
欧美 _4_6 100
|
||||
港台 _4_6 100
|
||||
流行 _4_8 100
|
||||
国风 _4_8 100
|
||||
周杰伦 _4_7 100
|
||||
陈奕迅 _4_7 100
|
||||
林俊杰 _4_7 100
|
||||
张碧晨 _4_7 100
|
||||
程响 _4_7 100
|
||||
Taylor#Swift _4_7 100
|
||||
内地 _4_4 100
|
||||
欧美 _4_4 100
|
||||
港台 _4_4 100
|
||||
流行 _4_6 100
|
||||
国风 _4_6 100
|
||||
@@ -1,6 +1,6 @@
|
||||
p1 _3_4 52
|
||||
p2 _3_4 47
|
||||
p3 _3_4 31
|
||||
p4 _3_4 36
|
||||
p5 _3_4 50
|
||||
p6 _3_4 38
|
||||
p1 _3_3 52
|
||||
p2 _3_3 47
|
||||
p3 _3_3 31
|
||||
p4 _3_3 36
|
||||
p5 _3_3 50
|
||||
p6 _3_3 38
|
||||
@@ -1,9 +1,9 @@
|
||||
周杰伦 _4_9 9000
|
||||
周深 _4_9 8000
|
||||
周传雄 _4_9 7000
|
||||
周华建 _4_9 6000
|
||||
陈奕迅 _4_9 8000
|
||||
林俊杰 _4_9 7000
|
||||
张碧晨 _4_9 7000
|
||||
程响 _4_9 7000
|
||||
Taylor#Swift _4_9 7000
|
||||
周杰伦 _4_7 9000
|
||||
周深 _4_7 8000
|
||||
周传雄 _4_7 7000
|
||||
周华建 _4_7 6000
|
||||
陈奕迅 _4_7 8000
|
||||
林俊杰 _4_7 7000
|
||||
张碧晨 _4_7 7000
|
||||
程响 _4_7 7000
|
||||
Taylor#Swift _4_7 7000
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _5_10 1
|
||||
加拿大 _5_10 1
|
||||
锡尔赫特、吉大港、库斯蒂亚 _5_10 1
|
||||
孟加拉国 _5_10 3
|
||||
美国 _5_8 1
|
||||
加拿大 _5_8 1
|
||||
锡尔赫特、吉大港、库斯蒂亚 _5_8 1
|
||||
孟加拉国 _5_8 3
|
||||
@@ -1,6 +1,6 @@
|
||||
现代 _5_11 1
|
||||
tagore _5_11 1
|
||||
蓝调 _5_11 1
|
||||
流行 _5_11 1
|
||||
民间 _5_11 1
|
||||
nazrul _5_11 1
|
||||
现代 _5_9 1
|
||||
tagore _5_9 1
|
||||
蓝调 _5_9 1
|
||||
流行 _5_9 1
|
||||
民间 _5_9 1
|
||||
nazrul _5_9 1
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _6_12 1
|
||||
印度 _6_12 2
|
||||
英国 _6_12 1
|
||||
孟加拉国 _6_12 2
|
||||
美国 _6_10 1
|
||||
印度 _6_10 2
|
||||
英国 _6_10 1
|
||||
孟加拉国 _6_10 2
|
||||
@@ -1,2 +1,2 @@
|
||||
男性 _6_13 3
|
||||
女性 _6_13 3
|
||||
男性 _6_11 3
|
||||
女性 _6_11 3
|
||||
@@ -1,2 +1,2 @@
|
||||
mp4 _7_16 4
|
||||
mp3 _7_16 2
|
||||
mp4 _7_14 4
|
||||
mp3 _7_14 2
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _8_18 1
|
||||
印度 _8_18 2
|
||||
英国 _8_18 1
|
||||
孟加拉国 _8_18 2
|
||||
美国 _8_16 1
|
||||
印度 _8_16 2
|
||||
英国 _8_16 1
|
||||
孟加拉国 _8_16 2
|
||||
@@ -1,2 +1,2 @@
|
||||
英文 _8_19 2
|
||||
孟加拉语 _8_19 4
|
||||
英文 _8_17 2
|
||||
孟加拉语 _8_17 4
|
||||
@@ -1,6 +1,6 @@
|
||||
阿米·奥帕尔·霍伊 _8_21 1
|
||||
我的爱 _8_21 1
|
||||
打败它 _8_21 1
|
||||
阿杰伊阿卡什 _8_21 1
|
||||
Tumi#长袍#尼罗布 _8_21 1
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _8_21 1
|
||||
阿米·奥帕尔·霍伊 _8_19 1
|
||||
我的爱 _8_19 1
|
||||
打败它 _8_19 1
|
||||
阿杰伊阿卡什 _8_19 1
|
||||
Tumi#长袍#尼罗布 _8_19 1
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _8_19 1
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.tencent.supersonic.integration;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.SUM;
|
||||
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.ParseResp;
|
||||
@@ -15,13 +12,17 @@ import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.util.DataUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.SUM;
|
||||
|
||||
|
||||
public class MetricQueryTest extends BaseQueryTest {
|
||||
@@ -39,6 +40,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
|
||||
expectedParseInfo.getDimensionFilters().add(DataUtils.getFilter("user_name",
|
||||
FilterOperatorEnum.EQUALS, "alice", "用户", 2L));
|
||||
@@ -73,7 +75,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
expectedParseInfo.setDateInfo(DataUtils.getDateConf(DateConf.DateMode.RECENT, unit, period, startDay, endDay));
|
||||
expectedParseInfo.setQueryType(QueryType.METRIC);
|
||||
|
||||
@@ -102,6 +104,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("部门"));
|
||||
|
||||
expectedParseInfo.setDateInfo(DataUtils.getDateConf(DateConf.DateMode.RECENT, unit, period, startDay, endDay));
|
||||
@@ -122,7 +125,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedResult.setQueryMode(MetricFilterQuery.QUERY_MODE);
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("alice");
|
||||
list.add("lucy");
|
||||
@@ -147,9 +150,9 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(SUM);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问用户数"));
|
||||
expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("用户"));
|
||||
expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("用户名"));
|
||||
expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("用户名称"));
|
||||
|
||||
expectedParseInfo.setDateInfo(DataUtils.getDateConf(3, DateConf.DateMode.RECENT, "DAY"));
|
||||
expectedParseInfo.setQueryType(QueryType.METRIC);
|
||||
@@ -168,6 +171,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(SUM);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
expectedParseInfo.getDimensions().add(DataUtils.getSchemaElement("部门"));
|
||||
|
||||
expectedParseInfo.setDateInfo(DataUtils.getDateConf(DateConf.DateMode.RECENT, unit, period, startDay, endDay));
|
||||
@@ -193,7 +197,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("访问次数"));
|
||||
|
||||
expectedParseInfo.getMetrics().add(DataUtils.getSchemaElement("人均访问次数"));
|
||||
expectedParseInfo.getDimensionFilters().add(DataUtils.getFilter("user_name",
|
||||
FilterOperatorEnum.EQUALS, "alice", "用户", 2L));
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.tencent.supersonic.integration;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
|
||||
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||
@@ -13,15 +11,19 @@ import com.tencent.supersonic.common.pojo.DateConf.DateMode;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.util.DataUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
|
||||
public class TagQueryTest extends BaseQueryTest {
|
||||
|
||||
@Test
|
||||
public void queryTest_metric_tag_query() throws Exception {
|
||||
QueryResult actualResult = submitNewChat("艺人周杰伦的播放量", null);
|
||||
MockConfiguration.mockTagAgent(agentService);
|
||||
QueryResult actualResult = submitNewChat("艺人周杰伦的播放量", DataUtils.tagAgentId);
|
||||
|
||||
QueryResult expectedResult = new QueryResult();
|
||||
SemanticParseInfo expectedParseInfo = new SemanticParseInfo();
|
||||
@@ -30,7 +32,7 @@ public class TagQueryTest extends BaseQueryTest {
|
||||
expectedResult.setQueryMode(MetricTagQuery.QUERY_MODE);
|
||||
expectedParseInfo.setAggType(NONE);
|
||||
|
||||
QueryFilter dimensionFilter = DataUtils.getFilter("singer_name", FilterOperatorEnum.EQUALS, "周杰伦", "歌手名", 9L);
|
||||
QueryFilter dimensionFilter = DataUtils.getFilter("singer_name", FilterOperatorEnum.EQUALS, "周杰伦", "歌手名", 7L);
|
||||
expectedParseInfo.getDimensionFilters().add(dimensionFilter);
|
||||
|
||||
SchemaElement metric = SchemaElement.builder().name("播放量").build();
|
||||
@@ -44,7 +46,8 @@ public class TagQueryTest extends BaseQueryTest {
|
||||
|
||||
@Test
|
||||
public void queryTest_tag_list_filter() throws Exception {
|
||||
QueryResult actualResult = submitNewChat("爱情、流行类型的艺人", null);
|
||||
MockConfiguration.mockTagAgent(agentService);
|
||||
QueryResult actualResult = submitNewChat("爱情、流行类型的艺人", DataUtils.tagAgentId);
|
||||
|
||||
QueryResult expectedResult = new QueryResult();
|
||||
SemanticParseInfo expectedParseInfo = new SemanticParseInfo();
|
||||
@@ -56,7 +59,7 @@ public class TagQueryTest extends BaseQueryTest {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("流行");
|
||||
QueryFilter dimensionFilter = DataUtils.getFilter("genre", FilterOperatorEnum.EQUALS,
|
||||
"流行", "风格", 8L);
|
||||
"流行", "风格", 6L);
|
||||
expectedParseInfo.getDimensionFilters().add(dimensionFilter);
|
||||
|
||||
SchemaElement metric = SchemaElement.builder().name("播放量").build();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.tencent.supersonic.integration.mapper;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
|
||||
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||
@@ -9,21 +7,23 @@ import com.tencent.supersonic.chat.api.pojo.request.QueryReq;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.QueryResult;
|
||||
import com.tencent.supersonic.chat.core.query.rule.metric.MetricTagQuery;
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.integration.BaseQueryTest;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.util.DataUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum.NONE;
|
||||
|
||||
public class MapperTest extends BaseQueryTest {
|
||||
|
||||
@Test
|
||||
public void hanlp() throws Exception {
|
||||
|
||||
QueryReq queryContextReq = DataUtils.getQueryContextReq(10, "艺人周杰伦的播放量");
|
||||
queryContextReq.setAgentId(1);
|
||||
queryContextReq.setAgentId(DataUtils.tagAgentId);
|
||||
|
||||
QueryResult actualResult = submitNewChat("艺人周杰伦的播放量", 1);
|
||||
QueryResult actualResult = submitNewChat("艺人周杰伦的播放量", DataUtils.tagAgentId);
|
||||
|
||||
QueryResult expectedResult = new QueryResult();
|
||||
SemanticParseInfo expectedParseInfo = new SemanticParseInfo();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.tencent.supersonic.util;
|
||||
|
||||
import static java.time.LocalDate.now;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
@@ -16,6 +14,8 @@ import com.tencent.supersonic.chat.core.agent.RuleParserTool;
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum;
|
||||
|
||||
import static java.time.LocalDate.now;
|
||||
|
||||
public class DataUtils {
|
||||
|
||||
public static final Integer metricAgentId = 1;
|
||||
@@ -106,7 +106,6 @@ public class DataUtils {
|
||||
agent.setDescription("标签圈选");
|
||||
AgentConfig agentConfig = new AgentConfig();
|
||||
agentConfig.getTools().add(getRuleQueryTool());
|
||||
agentConfig.getTools().add(getPluginTool());
|
||||
agent.setAgentConfig(JSONObject.toJSONString(agentConfig));
|
||||
return agent;
|
||||
}
|
||||
@@ -114,8 +113,8 @@ public class DataUtils {
|
||||
private static RuleParserTool getRuleQueryTool() {
|
||||
RuleParserTool ruleQueryTool = new RuleParserTool();
|
||||
ruleQueryTool.setType(AgentToolType.NL2SQL_RULE);
|
||||
ruleQueryTool.setModelIds(Lists.newArrayList(1L, 2L));
|
||||
ruleQueryTool.setQueryModes(Lists.newArrayList("METRIC_ENTITY", "METRIC_FILTER", "METRIC_MODEL",
|
||||
ruleQueryTool.setModelIds(Lists.newArrayList(-1L));
|
||||
ruleQueryTool.setQueryModes(Lists.newArrayList("METRIC_TAG", "METRIC_FILTER", "METRIC_MODEL",
|
||||
"TAG_DETAIL", "TAG_LIST_FILTER", "TAG_ID"));
|
||||
return ruleQueryTool;
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ dean _1_2 36
|
||||
john _1_2 50
|
||||
jack _1_2 38
|
||||
admin _1_2 70
|
||||
周杰伦 _4_9 100
|
||||
陈奕迅 _4_9 100
|
||||
林俊杰 _4_9 100
|
||||
张碧晨 _4_9 100
|
||||
程响 _4_9 100
|
||||
Taylor#Swift _4_9 100
|
||||
内地 _4_6 100
|
||||
欧美 _4_6 100
|
||||
港台 _4_6 100
|
||||
流行 _4_8 100
|
||||
国风 _4_8 100
|
||||
周杰伦 _4_7 100
|
||||
陈奕迅 _4_7 100
|
||||
林俊杰 _4_7 100
|
||||
张碧晨 _4_7 100
|
||||
程响 _4_7 100
|
||||
Taylor#Swift _4_7 100
|
||||
内地 _4_4 100
|
||||
欧美 _4_4 100
|
||||
港台 _4_4 100
|
||||
流行 _4_6 100
|
||||
国风 _4_6 100
|
||||
@@ -1,6 +1,6 @@
|
||||
p1 _3_4 52
|
||||
p2 _3_4 47
|
||||
p3 _3_4 31
|
||||
p4 _3_4 36
|
||||
p5 _3_4 50
|
||||
p6 _3_4 38
|
||||
p1 _3_3 52
|
||||
p2 _3_3 47
|
||||
p3 _3_3 31
|
||||
p4 _3_3 36
|
||||
p5 _3_3 50
|
||||
p6 _3_3 38
|
||||
@@ -1,9 +1,9 @@
|
||||
周杰伦 _4_9 9000
|
||||
周深 _4_9 8000
|
||||
周传雄 _4_9 7000
|
||||
周华建 _4_9 6000
|
||||
陈奕迅 _4_9 8000
|
||||
林俊杰 _4_9 7000
|
||||
张碧晨 _4_9 7000
|
||||
程响 _4_9 7000
|
||||
Taylor#Swift _4_9 7000
|
||||
周杰伦 _4_7 9000
|
||||
周深 _4_7 8000
|
||||
周传雄 _4_7 7000
|
||||
周华建 _4_7 6000
|
||||
陈奕迅 _4_7 8000
|
||||
林俊杰 _4_7 7000
|
||||
张碧晨 _4_7 7000
|
||||
程响 _4_7 7000
|
||||
Taylor#Swift _4_7 7000
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _5_10 1
|
||||
加拿大 _5_10 1
|
||||
锡尔赫特、吉大港、库斯蒂亚 _5_10 1
|
||||
孟加拉国 _5_10 3
|
||||
美国 _5_8 1
|
||||
加拿大 _5_8 1
|
||||
锡尔赫特、吉大港、库斯蒂亚 _5_8 1
|
||||
孟加拉国 _5_8 3
|
||||
@@ -1,6 +1,6 @@
|
||||
现代 _5_11 1
|
||||
tagore _5_11 1
|
||||
蓝调 _5_11 1
|
||||
流行 _5_11 1
|
||||
民间 _5_11 1
|
||||
nazrul _5_11 1
|
||||
现代 _5_9 1
|
||||
tagore _5_9 1
|
||||
蓝调 _5_9 1
|
||||
流行 _5_9 1
|
||||
民间 _5_9 1
|
||||
nazrul _5_9 1
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _6_12 1
|
||||
印度 _6_12 2
|
||||
英国 _6_12 1
|
||||
孟加拉国 _6_12 2
|
||||
美国 _6_10 1
|
||||
印度 _6_10 2
|
||||
英国 _6_10 1
|
||||
孟加拉国 _6_10 2
|
||||
@@ -1,2 +1,2 @@
|
||||
男性 _6_13 3
|
||||
女性 _6_13 3
|
||||
男性 _6_11 3
|
||||
女性 _6_11 3
|
||||
@@ -1,2 +1,2 @@
|
||||
mp4 _7_16 4
|
||||
mp3 _7_16 2
|
||||
mp4 _7_14 4
|
||||
mp3 _7_14 2
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _8_18 1
|
||||
印度 _8_18 2
|
||||
英国 _8_18 1
|
||||
孟加拉国 _8_18 2
|
||||
美国 _8_16 1
|
||||
印度 _8_16 2
|
||||
英国 _8_16 1
|
||||
孟加拉国 _8_16 2
|
||||
@@ -1,2 +1,2 @@
|
||||
英文 _8_19 2
|
||||
孟加拉语 _8_19 4
|
||||
英文 _8_17 2
|
||||
孟加拉语 _8_17 4
|
||||
@@ -1,6 +1,6 @@
|
||||
阿米·奥帕尔·霍伊 _8_21 1
|
||||
我的爱 _8_21 1
|
||||
打败它 _8_21 1
|
||||
阿杰伊阿卡什 _8_21 1
|
||||
Tumi#长袍#尼罗布 _8_21 1
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _8_21 1
|
||||
阿米·奥帕尔·霍伊 _8_19 1
|
||||
我的爱 _8_19 1
|
||||
打败它 _8_19 1
|
||||
阿杰伊阿卡什 _8_19 1
|
||||
Tumi#长袍#尼罗布 _8_19 1
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _8_19 1
|
||||
Reference in New Issue
Block a user