#59 -- sort time series values

This commit is contained in:
Anton Romanov 2022-10-08 12:24:36 +04:00
parent cfe1197a3f
commit fd001da317

View File

@ -3,6 +3,7 @@ package ru.ulstu.extractor.ts;
import ru.ulstu.extractor.model.TimeSeriesValue;
import ru.ulstu.extractor.service.TimeSeriesService;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
@ -35,6 +36,13 @@ public abstract class AbstractTimeSeriesCreator {
// сгруппированные по временным интервалам точки временных рядов
timeSeriesValues.replaceAll((k, v) -> mapTimeSeriesToInterval(getTimeSeriesService().getTimeSeriesInterval(), v));
getTimeSeriesService().save(timeSeriesValues);
getTimeSeriesService().save(sortTimeSeriesValues(timeSeriesValues));
}
private Map<String, List<TimeSeriesValue>> sortTimeSeriesValues(Map<String, List<TimeSeriesValue>> timeSeriesValues) {
for (Map.Entry<String, List<TimeSeriesValue>> entry : timeSeriesValues.entrySet()) {
entry.getValue().sort(Comparator.comparing(TimeSeriesValue::getDate));
}
return timeSeriesValues;
}
}