mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-01-25 22:51:37 +00:00
added methods and routes for getting an exercises history, and the sum of a workouts musclearrays -- incl a modifier
This commit is contained in:
@@ -30,4 +30,43 @@ module.exports = function(app) {
|
||||
|
||||
});
|
||||
|
||||
app.get('/api/getexercisemodifier/:userid/:exerciseid', function(req, res) {
|
||||
res.contentType('json');
|
||||
console.log('userID' + req.params.userid);
|
||||
console.log('exerciseID' + req.params.exerciseid);
|
||||
//DB search workouts
|
||||
// where userid
|
||||
//where exerciseid
|
||||
|
||||
Workout
|
||||
.where('userID', req.params.userid)
|
||||
.where('elements.exerciseID', req.params.exerciseid)
|
||||
.select('elements')
|
||||
// .exec(callback);
|
||||
|
||||
// workout.findOne({_id: req.params._id})
|
||||
// //.populate('elements.exerciseID')
|
||||
.exec(function(err, workout) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (! workout) {
|
||||
return res.send('Not found', 404);
|
||||
}
|
||||
//need for loop for workout as it returns an array
|
||||
var filteredarray = workout[0].elements.filter( function(i) {
|
||||
return i.exerciseID == req.params.exerciseid;
|
||||
});
|
||||
// then for each in filtered array grab sets reps weight
|
||||
// punch that into an array.
|
||||
|
||||
// res.send(filteredarray);
|
||||
// //console.log("hmm" + JSON.stringify(workout[0].elements));
|
||||
res.send(workout);
|
||||
//next();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user