Commit bc2520fbbb95d06e63dea73f5c5d47fc08ce5aee

Authored by YevhenBondarenko
1 parent 03fbc466

add request param "orderBy" for getTimeseries

... ... @@ -197,19 +197,21 @@ public class TelemetryController extends BaseController {
197 197 @RequestMapping(value = "/{entityType}/{entityId}/values/timeseries", method = RequestMethod.GET, params = {"keys", "startTs", "endTs"})
198 198 @ResponseBody
199 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 202 @RequestParam(name = "keys") String keys,
202 203 @RequestParam(name = "startTs") Long startTs,
203 204 @RequestParam(name = "endTs") Long endTs,
204 205 @RequestParam(name = "interval", defaultValue = "0") Long interval,
205 206 @RequestParam(name = "limit", defaultValue = "100") Integer limit,
206 207 @RequestParam(name = "agg", defaultValue = "NONE") String aggStr,
  208 + @RequestParam(name= "orderBy", defaultValue = "DESC") String orderBy,
207 209 @RequestParam(name = "useStrictDataTypes", required = false, defaultValue = "false") Boolean useStrictDataTypes) throws ThingsboardException {
208 210 return accessValidator.validateEntityAndCallback(getCurrentUser(), Operation.READ_TELEMETRY, entityType, entityIdStr,
209 211 (result, tenantId, entityId) -> {
210 212 // If interval is 0, convert this to a NONE aggregation, which is probably what the user really wanted
211 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 215 .collect(Collectors.toList());
214 216
215 217 Futures.addCallback(tsService.findAll(tenantId, entityId, queries), getTsKvListCallback(result, useStrictDataTypes), MoreExecutors.directExecutor());
... ...