Commit 73a951c58f6b596742cb25c9e044efe365eb6e53
Committed by
GitHub
Merge pull request #3403 from YevhenBondarenko/develop/2.5.5-improvements
add request param "orderBy" for getTimeseries
Showing
1 changed file
with
4 additions
and
2 deletions
@@ -197,19 +197,21 @@ public class TelemetryController extends BaseController { | @@ -197,19 +197,21 @@ public class TelemetryController extends BaseController { | ||
197 | @RequestMapping(value = "/{entityType}/{entityId}/values/timeseries", method = RequestMethod.GET, params = {"keys", "startTs", "endTs"}) | 197 | @RequestMapping(value = "/{entityType}/{entityId}/values/timeseries", method = RequestMethod.GET, params = {"keys", "startTs", "endTs"}) |
198 | @ResponseBody | 198 | @ResponseBody |
199 | public DeferredResult<ResponseEntity> getTimeseries( | 199 | public DeferredResult<ResponseEntity> getTimeseries( |
200 | - @PathVariable("entityType") String entityType, @PathVariable("entityId") String entityIdStr, | 200 | + @PathVariable("entityType") String entityType, |
201 | + @PathVariable("entityId") String entityIdStr, | ||
201 | @RequestParam(name = "keys") String keys, | 202 | @RequestParam(name = "keys") String keys, |
202 | @RequestParam(name = "startTs") Long startTs, | 203 | @RequestParam(name = "startTs") Long startTs, |
203 | @RequestParam(name = "endTs") Long endTs, | 204 | @RequestParam(name = "endTs") Long endTs, |
204 | @RequestParam(name = "interval", defaultValue = "0") Long interval, | 205 | @RequestParam(name = "interval", defaultValue = "0") Long interval, |
205 | @RequestParam(name = "limit", defaultValue = "100") Integer limit, | 206 | @RequestParam(name = "limit", defaultValue = "100") Integer limit, |
206 | @RequestParam(name = "agg", defaultValue = "NONE") String aggStr, | 207 | @RequestParam(name = "agg", defaultValue = "NONE") String aggStr, |
208 | + @RequestParam(name= "orderBy", defaultValue = "DESC") String orderBy, | ||
207 | @RequestParam(name = "useStrictDataTypes", required = false, defaultValue = "false") Boolean useStrictDataTypes) throws ThingsboardException { | 209 | @RequestParam(name = "useStrictDataTypes", required = false, defaultValue = "false") Boolean useStrictDataTypes) throws ThingsboardException { |
208 | return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_TELEMETRY, entityType, entityIdStr, | 210 | return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_TELEMETRY, entityType, entityIdStr, |
209 | (result, tenantId, entityId) -> { | 211 | (result, tenantId, entityId) -> { |
210 | // If interval is 0, convert this to a NONE aggregation, which is probably what the user really wanted | 212 | // If interval is 0, convert this to a NONE aggregation, which is probably what the user really wanted |
211 | Aggregation agg = interval == 0L ? Aggregation.valueOf(Aggregation.NONE.name()) : Aggregation.valueOf(aggStr); | 213 | Aggregation agg = interval == 0L ? Aggregation.valueOf(Aggregation.NONE.name()) : Aggregation.valueOf(aggStr); |
212 | - List<ReadTsKvQuery> queries = toKeysList(keys).stream().map(key -> new BaseReadTsKvQuery(key, startTs, endTs, interval, limit, agg)) | 214 | + List<ReadTsKvQuery> queries = toKeysList(keys).stream().map(key -> new BaseReadTsKvQuery(key, startTs, endTs, interval, limit, agg, orderBy)) |
213 | .collect(Collectors.toList()); | 215 | .collect(Collectors.toList()); |
214 | 216 | ||
215 | Futures.addCallback(tsService.findAll(tenantId, entityId, queries), getTsKvListCallback(result, useStrictDataTypes), MoreExecutors.directExecutor()); | 217 | Futures.addCallback(tsService.findAll(tenantId, entityId, queries), getTsKvListCallback(result, useStrictDataTypes), MoreExecutors.directExecutor()); |