Commit 2ee3a855d177d141ce0ad432530322b772fc3b11
1 parent
e97edd61
Check for blank keys before fetching latest for entity view
Showing
2 changed files
with
15 additions
and
4 deletions
... | ... | @@ -63,6 +63,7 @@ import java.util.List; |
63 | 63 | import java.util.concurrent.ExecutionException; |
64 | 64 | import java.util.stream.Collectors; |
65 | 65 | |
66 | +import static org.apache.commons.lang.StringUtils.isBlank; | |
66 | 67 | import static org.thingsboard.server.controller.CustomerController.CUSTOMER_ID; |
67 | 68 | |
68 | 69 | /** |
... | ... | @@ -253,8 +254,12 @@ public class EntityViewController extends BaseController { |
253 | 254 | keysFuture = Futures.immediateFuture(keys); |
254 | 255 | } |
255 | 256 | ListenableFuture<List<TsKvEntry>> latestFuture = Futures.transformAsync(keysFuture, fetchKeys -> { |
256 | - List<ReadTsKvQuery> queries = fetchKeys.stream().map(key -> new BaseReadTsKvQuery(key, startTs, endTs, 1, "DESC")).collect(Collectors.toList()); | |
257 | - return tsService.findAll(user.getTenantId(), entityView.getEntityId(), queries); | |
257 | + List<ReadTsKvQuery> queries = fetchKeys.stream().filter(key -> !isBlank(key)).map(key -> new BaseReadTsKvQuery(key, startTs, endTs, 1, "DESC")).collect(Collectors.toList()); | |
258 | + if (!queries.isEmpty()) { | |
259 | + return tsService.findAll(user.getTenantId(), entityView.getEntityId(), queries); | |
260 | + } else { | |
261 | + return Futures.immediateFuture(null); | |
262 | + } | |
258 | 263 | }, MoreExecutors.directExecutor()); |
259 | 264 | return Futures.transform(latestFuture, latestValues -> { |
260 | 265 | if (latestValues != null && !latestValues.isEmpty()) { | ... | ... |
... | ... | @@ -48,6 +48,8 @@ import java.util.List; |
48 | 48 | import java.util.concurrent.ExecutionException; |
49 | 49 | import java.util.stream.Collectors; |
50 | 50 | |
51 | +import static org.apache.commons.lang.StringUtils.isBlank; | |
52 | + | |
51 | 53 | @Service |
52 | 54 | @Profile("install") |
53 | 55 | @Slf4j |
... | ... | @@ -158,8 +160,12 @@ public class DefaultDataUpdateService implements DataUpdateService { |
158 | 160 | keysFuture = Futures.immediateFuture(keys); |
159 | 161 | } |
160 | 162 | ListenableFuture<List<TsKvEntry>> latestFuture = Futures.transformAsync(keysFuture, fetchKeys -> { |
161 | - List<ReadTsKvQuery> queries = fetchKeys.stream().map(key -> new BaseReadTsKvQuery(key, startTs, endTs, 1, "DESC")).collect(Collectors.toList()); | |
162 | - return tsService.findAll(TenantId.SYS_TENANT_ID, entityView.getEntityId(), queries); | |
163 | + List<ReadTsKvQuery> queries = fetchKeys.stream().filter(key -> !isBlank(key)).map(key -> new BaseReadTsKvQuery(key, startTs, endTs, 1, "DESC")).collect(Collectors.toList()); | |
164 | + if (!queries.isEmpty()) { | |
165 | + return tsService.findAll(TenantId.SYS_TENANT_ID, entityView.getEntityId(), queries); | |
166 | + } else { | |
167 | + return Futures.immediateFuture(null); | |
168 | + } | |
163 | 169 | }, MoreExecutors.directExecutor()); |
164 | 170 | return Futures.transformAsync(latestFuture, latestValues -> { |
165 | 171 | if (latestValues != null && !latestValues.isEmpty()) { | ... | ... |