Export points as arrays instaed of dictionaries, so the JSON is smaller.
This commit is contained in:
Родитель
57e2d583ef
Коммит
16b465def4
|
@ -48,14 +48,17 @@ class Builder:
|
|||
|
||||
# Now we have a canonical list of time points across all lines. Build
|
||||
# a new point list for each line, such that all lines have the same
|
||||
# list of points.
|
||||
# list of points. At this time, we also rewrite points to be lists, as
|
||||
# this results in smaller exported JSON.
|
||||
for i, line in enumerate(lines):
|
||||
# Prefill, so each slot in the line has one point.
|
||||
newlist = [None] * len(self.timelist)
|
||||
for point in line['data']:
|
||||
index = self.timemap[point['time']]
|
||||
del point['time']
|
||||
newlist[index] = point
|
||||
if 'last' in point:
|
||||
newlist[index] = [point['score'], point['first'], point['last']]
|
||||
else:
|
||||
newlist[index] = [point['score'], point['first']]
|
||||
|
||||
line['data'] = newlist
|
||||
return
|
||||
|
|
|
@ -64,7 +64,7 @@ def condense_graph(graph, regions):
|
|||
last = None
|
||||
for i in range(start, end):
|
||||
p = line.data[i]
|
||||
if not p or not p['score']
|
||||
if not p or not p['score']:
|
||||
continue
|
||||
average = ((average * count) + p['score']) / (count + 1)
|
||||
count = count + 1
|
||||
|
|
Загрузка…
Ссылка в новой задаче