Browse Source

add batching for measurement backfill.

master
Gisle Aune 5 years ago
parent
commit
771f4e4f69
  1. 6
      src/api/workout.js

6
src/api/workout.js

@ -184,7 +184,9 @@ module.exports = function workoutRouter(repo) {
} }
workout.listMeasurements().then((list) => { 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 => { }).catch(err => {
ws.send(JSON.stringify({error: `could not list measurements: ${err.message || err}`})); ws.send(JSON.stringify({error: `could not list measurements: ${err.message || err}`}));
ws.close(); ws.close();
@ -196,7 +198,7 @@ module.exports = function workoutRouter(repo) {
ws.send(JSON.stringify({workotuStatus})) ws.send(JSON.stringify({workotuStatus}))
} }
workout.events.on("workoutStatus", handler); workout.events.on("workoutStatus", handler);
ws.onclose = () => { ws.onclose = () => {

Loading…
Cancel
Save