descending order starts with last timestamp (#18789)

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
pull/18623/merge
Bernd Weymann 2025-06-10 21:21:07 +02:00 committed by GitHub
parent dc006338ae
commit 9f73acaf39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -510,12 +510,13 @@ public class RRD4jPersistenceService implements QueryablePersistenceService {
FetchData result = request.fetchData();
List<HistoricItem> items = new ArrayList<>();
long ts = result.getFirstTimestamp();
long step = result.getRowCount() > 1 ? result.getStep() : 0;
double prevValue = Double.NaN;
State prevState = null;
double[] values = result.getValues(DATASOURCE_STATE);
// Descending order shall start with the last timestamp and go backward
long ts = (ordering == Ordering.DESCENDING) ? result.getLastTimestamp() : result.getFirstTimestamp();
step = (ordering == Ordering.DESCENDING) ? -1 * step : step;
int startIndex = (ordering == Ordering.DESCENDING) ? values.length - 1 : 0;
int endIndex = (ordering == Ordering.DESCENDING) ? -1 : values.length;