From 438ee539d603cbd3b4558950060c15c9b60d26e4 Mon Sep 17 00:00:00 2001 From: jipeli <54889677+jipeli@users.noreply.github.com> Date: Tue, 14 Nov 2023 17:02:27 +0800 Subject: [PATCH] (improvement)(chat) metricSemantic query without dateInfo not get queryRatio (#380) Co-authored-by: jipengli --- .../chat/service/SemanticService.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/chat/core/src/main/java/com/tencent/supersonic/chat/service/SemanticService.java b/chat/core/src/main/java/com/tencent/supersonic/chat/service/SemanticService.java index 3166702f2..fc91493af 100644 --- a/chat/core/src/main/java/com/tencent/supersonic/chat/service/SemanticService.java +++ b/chat/core/src/main/java/com/tencent/supersonic/chat/service/SemanticService.java @@ -382,15 +382,17 @@ public class SemanticService { Optional lastDayOp = result.getResultList().stream().filter(r -> r.containsKey(dateField)) .map(r -> r.get(dateField).toString()) .sorted(Comparator.reverseOrder()).findFirst(); - if (lastDayOp.isPresent()) { - Optional> 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()); + if (!lastDayOp.isPresent()) { + return new AggregateInfo(); } + Optional> 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 metricInfoRoll = CompletableFuture .supplyAsync(() -> { return queryRatio(user, semanticParseInfo, ratioMetric.get(), AggOperatorEnum.RATIO_ROLL,