Do not load all data if it is not in the current time interval

This commit is contained in:
Alejandro Santana Lima 2021-01-25 08:49:02 +01:00 committed by Andrew Shvayka
parent 430e96cdb2
commit 5820c5446b

View File

@ -434,8 +434,10 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene
if (curTs > value) { if (curTs > value) {
long startTs = subscription.getStartTime() > 0 ? Math.max(subscription.getStartTime(), value + 1L) : (value + 1L); long startTs = subscription.getStartTime() > 0 ? Math.max(subscription.getStartTime(), value + 1L) : (value + 1L);
long endTs = subscription.getEndTime() > 0 ? Math.min(subscription.getEndTime(), curTs) : curTs; long endTs = subscription.getEndTime() > 0 ? Math.min(subscription.getEndTime(), curTs) : curTs;
if (startTs > 1) {
queries.add(new BaseReadTsKvQuery(key, startTs, endTs, 0, 1000, Aggregation.NONE)); queries.add(new BaseReadTsKvQuery(key, startTs, endTs, 0, 1000, Aggregation.NONE));
} }
}
}); });
if (!queries.isEmpty()) { if (!queries.isEmpty()) {
DonAsynchron.withCallback(tsService.findAll(subscription.getTenantId(), subscription.getEntityId(), queries), DonAsynchron.withCallback(tsService.findAll(subscription.getTenantId(), subscription.getEntityId(), queries),