Browse Source

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

pull/1070/head
viktorbasanets 8 years ago
parent
commit
1e1beaaeac
  1. 4
      common/data/src/main/java/org/thingsboard/server/common/data/kv/BaseReadTsKvQuery.java
  2. 5
      dao/src/main/java/org/thingsboard/server/dao/timeseries/BaseTimeseriesService.java

4
common/data/src/main/java/org/thingsboard/server/common/data/kv/BaseReadTsKvQuery.java

@ -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);
}
}

5
dao/src/main/java/org/thingsboard/server/dao/timeseries/BaseTimeseriesService.java

@ -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)));

Loading…
Cancel
Save