send foods via websockets

This commit is contained in:
MilosKozak
2017-10-16 19:51:40 +02:00
parent 9f7de63d6c
commit f13b6af0c8
2 changed files with 13 additions and 1 deletions
+11 -1
View File
@@ -66,6 +66,7 @@ function init(env, ctx) {
, loadProfileSwitchTreatments.bind(null, ddata, ctx)
, loadSensorAndInsulinTreatments.bind(null, ddata, ctx)
, loadProfile.bind(null, ddata, ctx)
, loadFood.bind(null, ddata, ctx)
, loadDeviceStatus.bind(null, ddata, env, ctx)
], loadComplete);
@@ -249,7 +250,16 @@ function loadProfile (ddata, ctx, callback) {
});
}
function loadDeviceStatus (ddata, env, ctx, callback) {
function loadFood (ddata, ctx, callback) {
ctx.food.list(function (err, results) {
if (!err && results) {
ddata.food = results;
}
callback();
});
}
function loadDeviceStatus (ddata, env, ctx, callback) {
var dateRange = {
$gte: new Date(ddata.lastUpdated - ONE_DAY).toISOString()
};
+2
View File
@@ -14,6 +14,7 @@ function init( ) {
, cals: []
, profiles: []
, devicestatus: []
, food: []
, lastUpdated: 0
};
@@ -66,6 +67,7 @@ function init( ) {
result.first.profiles = ddata.profiles;
result.rest.mbgs = ddata.mbgs.filter(filterMax);
result.rest.food = ddata.food;
console.log('results.first size', JSON.stringify(result.first).length,'bytes');
console.log('results.rest size', JSON.stringify(result.rest).length,'bytes');