Skip to content

Commit

Permalink
Reduce results payload size
Browse files Browse the repository at this point in the history
  • Loading branch information
NaniteBased committed Dec 15, 2020
1 parent 666e925 commit 6c65247
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Scheduler/east_west/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,21 @@ def results(executionId: int):
for measurement in measurements:
payloads = influx.GetMeasurement(executionId, measurement)
data[measurement] = []

for payload in payloads:
points = []
for point in payload.Points:
points.append([point.Time, point.Fields])
data[measurement].append({
'tags': payload.Tags,
'points': points
})
if len(payload.Points) != 0:
header = list(payload.Points[0].Fields.keys())
points = []
for point in payload.Points:
fields = point.Fields
values = [fields[value] for value in header]

points.append([point.Time.timestamp(), values])
data[measurement].append({
'tags': payload.Tags,
'header': header,
'points': points
})

return jsonify({'success': True, 'measurements': measurements, 'data': data,
'message': f"Results for execution {executionId} retrieved successfully"})
Expand Down

0 comments on commit 6c65247

Please sign in to comment.