add batching for measurement backfill.

This commit is contained in:
2019-10-31 19:37:36 +01:00
parent e3c7730f1d
commit 771f4e4f69
+4 -2
View File
@@ -184,7 +184,9 @@ module.exports = function workoutRouter(repo) {
}
workout.listMeasurements().then((list) => {
ws.send(JSON.stringify({workoutStatusBackfill: list}));
for (let i = 0; i < list.length; i += 240) {
ws.send(JSON.stringify({workoutStatusBackfill: list.slice(i, i+240)}));
}
}).catch(err => {
ws.send(JSON.stringify({error: `could not list measurements: ${err.message || err}`}));
ws.close();
@@ -196,7 +198,7 @@ module.exports = function workoutRouter(repo) {
ws.send(JSON.stringify({workotuStatus}))
}
workout.events.on("workoutStatus", handler);
ws.onclose = () => {