(improvement)(chat) metricSemantic query without dateInfo not get queryRatio (#380)

Co-authored-by: jipengli <jipengli@tencent.com>
This commit is contained in:
jipeli
2023-11-14 17:02:27 +08:00
committed by GitHub
parent 5ccde0206c
commit 438ee539d6

View File

@@ -382,15 +382,17 @@ public class SemanticService {
Optional<String> lastDayOp = result.getResultList().stream().filter(r -> r.containsKey(dateField)) Optional<String> lastDayOp = result.getResultList().stream().filter(r -> r.containsKey(dateField))
.map(r -> r.get(dateField).toString()) .map(r -> r.get(dateField).toString())
.sorted(Comparator.reverseOrder()).findFirst(); .sorted(Comparator.reverseOrder()).findFirst();
if (lastDayOp.isPresent()) { if (!lastDayOp.isPresent()) {
Optional<Map<String, Object>> lastValue = result.getResultList().stream() return new AggregateInfo();
.filter(r -> r.get(dateField).toString().equals(lastDayOp.get())).findFirst();
if (lastValue.isPresent() && lastValue.get().containsKey(ratioMetric.get().getBizName())) {
DecimalFormat df = new DecimalFormat("#.####");
metricInfo.setValue(df.format(lastValue.get().get(ratioMetric.get().getBizName())));
}
metricInfo.setDate(lastValue.get().get(dateField).toString());
} }
Optional<Map<String, Object>> lastValue = result.getResultList().stream()
.filter(r -> r.get(dateField).toString().equals(lastDayOp.get())).findFirst();
if (lastValue.isPresent() && lastValue.get().containsKey(ratioMetric.get().getBizName())) {
DecimalFormat df = new DecimalFormat("#.####");
metricInfo.setValue(df.format(lastValue.get().get(ratioMetric.get().getBizName())));
}
metricInfo.setDate(lastValue.get().get(dateField).toString());
CompletableFuture<MetricInfo> metricInfoRoll = CompletableFuture CompletableFuture<MetricInfo> metricInfoRoll = CompletableFuture
.supplyAsync(() -> { .supplyAsync(() -> {
return queryRatio(user, semanticParseInfo, ratioMetric.get(), AggOperatorEnum.RATIO_ROLL, return queryRatio(user, semanticParseInfo, ratioMetric.get(), AggOperatorEnum.RATIO_ROLL,