From 9d0a862feb192bb0c595ecad37678a0d73bda8f4 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Sat, 8 Oct 2022 14:40:49 +0400 Subject: [PATCH] #8 -- fix x-axis dates --- src/main/java/ru/ulstu/controller/IndexController.java | 3 +-- src/main/java/ru/ulstu/service/MethodParamBruteForce.java | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/ru/ulstu/controller/IndexController.java b/src/main/java/ru/ulstu/controller/IndexController.java index 4a329cc..f034573 100644 --- a/src/main/java/ru/ulstu/controller/IndexController.java +++ b/src/main/java/ru/ulstu/controller/IndexController.java @@ -99,11 +99,10 @@ public class IndexController { } private List getDatesForChart(TimeSeries timeSeries, TimeSeries forecast) { - return Stream.concat(timeSeries.getValues().stream(), forecast.getValues().stream()) + return Stream.concat(timeSeries.getValues().stream(), forecast.getValues().stream().skip(1)) .map(TimeSeriesValue::getDate) .sorted() .map(date -> date.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT))) - .distinct() .collect(Collectors.toList()); } diff --git a/src/main/java/ru/ulstu/service/MethodParamBruteForce.java b/src/main/java/ru/ulstu/service/MethodParamBruteForce.java index f065f8f..c8e76a9 100644 --- a/src/main/java/ru/ulstu/service/MethodParamBruteForce.java +++ b/src/main/java/ru/ulstu/service/MethodParamBruteForce.java @@ -16,6 +16,7 @@ import java.lang.reflect.InvocationTargetException; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Comparator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -51,7 +52,8 @@ class MethodParamBruteForce { } Map tsValues = timeSeries.getValues().stream() - .collect(Collectors.toMap(TimeSeriesValue::getDate, TimeSeriesValue::getValue)); + .collect(Collectors.toMap(TimeSeriesValue::getDate, TimeSeriesValue::getValue, + (oldValue, newValue) -> oldValue, LinkedHashMap::new)); for (Method method : methods) { List> availableParametersValues = getAvailableParametersValues(timeSeries, method.getAvailableParameters()); @@ -134,7 +136,8 @@ class MethodParamBruteForce { List results2 = new CopyOnWriteArrayList<>(); Map tsValues = timeSeries.getValues().stream() - .collect(Collectors.toMap(TimeSeriesValue::getDate, TimeSeriesValue::getValue)); + .collect(Collectors.toMap(TimeSeriesValue::getDate, TimeSeriesValue::getValue, + (oldValue, newValue) -> oldValue, LinkedHashMap::new)); for (Method method : methods) { List> availableParametersValues = getAvailableParametersValues(timeSeries, method.getAvailableParameters()); -- 2.34.1