mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 04:27:39 +00:00
[improvement](knowledge) support knowledge scenes without dates (#318)
Co-authored-by: kanedai <kanedai@tencent.com>
This commit is contained in:
@@ -173,20 +173,22 @@ public class DictMetaHelper {
|
|||||||
.forEach(knowledgeInfo -> {
|
.forEach(knowledgeInfo -> {
|
||||||
SchemaElement dimensionDesc = dimIdAndDescPair.get(knowledgeInfo.getItemId());
|
SchemaElement dimensionDesc = dimIdAndDescPair.get(knowledgeInfo.getItemId());
|
||||||
|
|
||||||
//default cnt
|
Long dimId = dimensionDesc.getId();
|
||||||
if (Objects.isNull(chatDefaultConfig)
|
String internalMetricName = "";
|
||||||
|| CollectionUtils.isEmpty(chatDefaultConfig.getMetrics())) {
|
if (Objects.nonNull(dimId)) {
|
||||||
Long dimId = dimensionDesc.getId();
|
String datasourceBizName = queryDataSourceByDimId(dimId);
|
||||||
if (Objects.nonNull(dimId)) {
|
internalMetricName = datasourceBizName + UNDERLINE + internalMetricNameSuffix;
|
||||||
String datasourceBizName = queryDataSourceByDimId(dimId);
|
}
|
||||||
String internalMetricName =
|
|
||||||
datasourceBizName + UNDERLINE + internalMetricNameSuffix;
|
if (Objects.isNull(chatDefaultConfig)) {
|
||||||
defaultMetricDescList.add(new DefaultMetric(internalMetricName,
|
defaultMetricDescList.add(new DefaultMetric(internalMetricName,
|
||||||
internalMetricDays, DAY));
|
internalMetricDays, DAY));
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
SchemaElement schemaItem = chatDefaultConfig.getMetrics().get(0);
|
String metric = internalMetricName;
|
||||||
defaultMetricDescList.add(new DefaultMetric(schemaItem.getBizName(),
|
if (!CollectionUtils.isEmpty(chatDefaultConfig.getMetrics())) {
|
||||||
|
metric = chatDefaultConfig.getMetrics().get(0).getBizName();
|
||||||
|
}
|
||||||
|
defaultMetricDescList.add(new DefaultMetric(metric,
|
||||||
chatDefaultConfig.getUnit(), chatDefaultConfig.getPeriod()));
|
chatDefaultConfig.getUnit(), chatDefaultConfig.getPeriod()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class DictQueryHelper {
|
|||||||
defaultMetricDesc.getBizName(), dim4Dict);
|
defaultMetricDesc.getBizName(), dim4Dict);
|
||||||
if (!CollectionUtils.isEmpty(data)) {
|
if (!CollectionUtils.isEmpty(data)) {
|
||||||
int size = (data.size() > printDataShow) ? printDataShow : data.size();
|
int size = (data.size() > printDataShow) ? printDataShow : data.size();
|
||||||
log.info("data:{}", data.subList(0, size - 1));
|
log.info("data:{}", data.subList(0, size));
|
||||||
} else {
|
} else {
|
||||||
log.warn("data is empty. nature:{}", nature);
|
log.warn("data is empty. nature:{}", nature);
|
||||||
if (Objects.nonNull(queryResultWithColumns)) {
|
if (Objects.nonNull(queryResultWithColumns)) {
|
||||||
@@ -178,6 +178,7 @@ public class DictQueryHelper {
|
|||||||
|
|
||||||
DateConf dateInfo = new DateConf();
|
DateConf dateInfo = new DateConf();
|
||||||
dateInfo.setDateMode(DateConf.DateMode.RECENT);
|
dateInfo.setDateMode(DateConf.DateMode.RECENT);
|
||||||
|
log.debug("defaultMetric unit():{}", defaultMetricDesc.getUnit());
|
||||||
dateInfo.setUnit(defaultMetricDesc.getUnit());
|
dateInfo.setUnit(defaultMetricDesc.getUnit());
|
||||||
queryStructCmd.setDateInfo(dateInfo);
|
queryStructCmd.setDateInfo(dateInfo);
|
||||||
|
|
||||||
|
|||||||
@@ -137,6 +137,12 @@ public class QueryStructUtils {
|
|||||||
if (Objects.isNull(dateInfo) || Objects.isNull(dateInfo.getDateMode())) {
|
if (Objects.isNull(dateInfo) || Objects.isNull(dateInfo.getDateMode())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
if (dateInfo.getDateMode().equals(DateMode.RECENT)) {
|
||||||
|
if (dateInfo.getUnit() <= 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<Long> dimensionIds = getDimensionIds(queryStructCmd);
|
List<Long> dimensionIds = getDimensionIds(queryStructCmd);
|
||||||
List<Long> metricIds = getMetricIds(queryStructCmd);
|
List<Long> metricIds = getMetricIds(queryStructCmd);
|
||||||
|
|
||||||
@@ -177,7 +183,7 @@ public class QueryStructUtils {
|
|||||||
return whereClauseFromFilter;
|
return whereClauseFromFilter;
|
||||||
} else if (Strings.isNotEmpty(whereFromDate) && Strings.isEmpty(whereClauseFromFilter)) {
|
} else if (Strings.isNotEmpty(whereFromDate) && Strings.isEmpty(whereClauseFromFilter)) {
|
||||||
return whereFromDate;
|
return whereFromDate;
|
||||||
} else if (Strings.isEmpty(whereFromDate) && Strings.isEmpty(whereClauseFromFilter)) {
|
} else if (Objects.isNull(whereFromDate) && Strings.isEmpty(whereClauseFromFilter)) {
|
||||||
log.info("the current date information is empty, enter the date initialization logic");
|
log.info("the current date information is empty, enter the date initialization logic");
|
||||||
return dateModeUtils.defaultRecentDateInfo(queryStructCmd.getDateInfo());
|
return dateModeUtils.defaultRecentDateInfo(queryStructCmd.getDateInfo());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user