Was modified findLatest(...) method & BaseTimeseriesService(...) constructor for set limit and order by values

This commit is contained in:
viktorbasanets 2018-09-11 15:13:45 +03:00
parent 94f3680f24
commit 1e1beaaeac
2 changed files with 8 additions and 1 deletions

View File

@ -42,4 +42,8 @@ public class BaseReadTsKvQuery extends BaseTsKvQuery implements ReadTsKvQuery {
this(key, startTs, endTs, endTs - startTs, 1, Aggregation.AVG, "DESC");
}
public BaseReadTsKvQuery(String key, long startTs, long endTs, int limit, String orderBy) {
this(key, startTs, endTs, endTs - startTs, limit, Aggregation.AVG, orderBy);
}
}

View File

@ -75,7 +75,10 @@ public class BaseTimeseriesService implements TimeseriesService {
EntityView entityView = entityViewService.findEntityViewById((EntityViewId) entityId);
Collection<String> matchingKeys = chooseKeysForEntityView(entityView, keys);
List<ReadTsKvQuery> queries = new ArrayList<>();
matchingKeys.forEach(key -> queries.add(new BaseReadTsKvQuery(key, entityView.getStartTs(), entityView.getEndTs())));
matchingKeys.forEach(key -> queries.add(
new BaseReadTsKvQuery(key, entityView.getStartTs(), entityView.getEndTs(), 1, "ASC")));
return timeseriesDao.findAllAsync(entityView.getEntityId(), updateQueriesForEntityView(entityView, queries));
}
keys.forEach(key -> futures.add(timeseriesDao.findLatest(entityId, key)));