Skip to content

Commit

Permalink
Fix step query (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
alemf authored Jun 2, 2022
1 parent a28d762 commit a007765
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,18 @@ public Task<DataReadResponse> getSteps(final PluginCall call) throws ParseExcept
public void onSuccess(DataReadResponse dataReadResponse) {
List<Bucket> buckets = dataReadResponse.getBuckets();

JSONObject steps = new JSONObject();
JSONArray steps = new JSONArray();

for (Bucket bucket : buckets) {
for (DataSet dataSet : bucket.getDataSets()) {
for (DataPoint dp : dataSet.getDataPoints()) {
for (Field field : dp.getDataType().getFields()) {
JSONObject stepEntry = new JSONObject();
try {
steps.put("startTime", timestampToDate(dp.getStartTime(TimeUnit.MILLISECONDS)));
steps.put("endTime", timestampToDate(dp.getEndTime(TimeUnit.MILLISECONDS)));
steps.put("value", dp.getValue(field).toString());
stepEntry.put("startTime", timestampToDate(dp.getStartTime(TimeUnit.MILLISECONDS)));
stepEntry.put("endTime", timestampToDate(dp.getEndTime(TimeUnit.MILLISECONDS)));
stepEntry.put("value", dp.getValue(field).toString());
steps.put(stepEntry);
} catch (JSONException e) {
call.reject(e.getMessage());
return;
Expand All @@ -194,7 +196,6 @@ public void onSuccess(DataReadResponse dataReadResponse) {
}

JSObject result = new JSObject();

result.put("steps", steps);

call.resolve(result);
Expand Down

0 comments on commit a007765

Please sign in to comment.