added some psuedocode for combining arrays

This commit is contained in:
2013-01-08 23:45:19 -05:00
parent 78061256b8
commit 4aebfbf83d

14
app.js
View File

@@ -121,6 +121,15 @@ io.sockets.on('connection', function(socket) {
callback2(); callback2();
}); });
}, function(err){ }, function(err){
/////////THIS is psuedo code for adding the activity arrays
//combinedarray = [0,0,0,0,0,0]
// for j in result
// do
//for i in (1..6)
// do
// combinedarray[i] = result[j].exercisemuscledata[i] + combinedarray[i]
//
// result.combinedarray = combinedarray
socket.emit('populateactivities', result); socket.emit('populateactivities', result);
}); });
}); });
@@ -146,16 +155,12 @@ io.sockets.on('connection', function(socket) {
//////////////////////// ////////////////////////
socket.on('addactivity', function(data, docid) { socket.on('addactivity', function(data, docid) {
var document_id; var document_id;
// console.log('addactivity' + docid);
// console.log('add_activity_data' + JSON.stringify(data));
if (docid === null) { if (docid === null) {
document_id = new BSON.ObjectID(); document_id = new BSON.ObjectID();
} }
else { else {
document_id = new BSON.ObjectID(docid); document_id = new BSON.ObjectID(docid);
} }
//var document_id = new BSON.ObjectID(docid);
// console.log('inserted BSONID' + document_id);
testcollection.update({_id:document_id}, data,{upsert:true} , function(err, result) { testcollection.update({_id:document_id}, data,{upsert:true} , function(err, result) {
if (err) throw err; if (err) throw err;
exercisecollection.find().toArray(function(err, result) { exercisecollection.find().toArray(function(err, result) {
@@ -179,7 +184,6 @@ io.sockets.on('connection', function(socket) {
}); });
/////////////////// ///////////////////
socket.on('getexercises', function(data) { socket.on('getexercises', function(data) {
// console.log('emit exercises');
exercisecollection.find().toArray(function(err, result) { exercisecollection.find().toArray(function(err, result) {
if (err) throw err; if (err) throw err;
socket.emit('populateexercises', result); socket.emit('populateexercises', result);