<commit_before>'use strict';

/**
 * Module dependencies.
 */
var _ = require('lodash'),
	path = require('path'),
	mongoose = require('mongoose'),
	Workout = mongoose.model('Workout'),
	errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller'));

/**
 * Create a Workout
 */
exports.create = function(req, res) {
	var workout = new Workout(req.body);

	workout.save(function(err) {
		if (err) {
			return res.status(400).send({
				message: errorHandler.getErrorMessage(err)
			});
		} else {
			res.jsonp(workout);
		}
	});
};

/**
 * Show the current Workout
 */
exports.read = function(req, res) {
	res.jsonp(req.workout);
};

/**
 * Update a Workout
 */
exports.update = function(req, res) {
	var workout = req.workout ;

	workout = _.extend(workout , req.body);

	workout.save(function(err) {
		if (err) {
			return res.status(400).send({
				message: errorHandler.getErrorMessage(err)
			});
		} else {
			res.jsonp(workout);
		}
	});
};

/**
 * Delete an Workout
 */
exports.delete = function(req, res) {
	var workout = req.workout ;

	workout.remove(function(err) {
		if (err) {
			return res.status(400).send({
				message: errorHandler.getErrorMessage(err)
			});
		} else {
			res.jsonp(workout);
		}
	});
};

/**
 * List of Workouts
 */
exports.list = function(req, res) { Workout.find().sort('-created').populate().exec(function(err, workouts) {
		if (err) {
			return res.status(400).send({
				message: errorHandler.getErrorMessage(err)
			});
		} else {
			res.jsonp(workouts);
		}
	});
};

/**
 * Workout middleware
 */
exports.workoutByID = function(req, res, next, id) { Workout.findById(id).populate('user', 'displayName').exec(function(err, workout) {
		if (err) return next(err);
		if (! workout) return next(new Error('Failed to load Workout ' + id));
		req.workout = workout ;
		next();
	});
};<commit_msg>workouts: remove unnecessary populate of user on workoutByID server method<commit_after>'use strict';

/**
 * Module dependencies.
 */
var _ = require('lodash'),
	path = require('path'),
	mongoose = require('mongoose'),
	Workout = mongoose.model('Workout'),
	errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller'));

/**
 * Create a Workout
 */
exports.create = function(req, res) {
	var workout = new Workout(req.body);

	workout.save(function(err) {
		if (err) {
			return res.status(400).send({
				message: errorHandler.getErrorMessage(err)
			});
		} else {
			res.jsonp(workout);
		}
	});
};

/**
 * Show the current Workout
 */
exports.read = function(req, res) {
	res.jsonp(req.workout);
};

/**
 * Update a Workout
 */
exports.update = function(req, res) {
	var workout = req.workout ;

	workout = _.extend(workout , req.body);

	workout.save(function(err) {
		if (err) {
			return res.status(400).send({
				message: errorHandler.getErrorMessage(err)
			});
		} else {
			res.jsonp(workout);
		}
	});
};

/**
 * Delete an Workout
 */
exports.delete = function(req, res) {
	var workout = req.workout ;

	workout.remove(function(err) {
		if (err) {
			return res.status(400).send({
				message: errorHandler.getErrorMessage(err)
			});
		} else {
			res.jsonp(workout);
		}
	});
};

/**
 * List of Workouts
 */
exports.list = function(req, res) { Workout.find().sort('-created').populate().exec(function(err, workouts) {
		if (err) {
			return res.status(400).send({
				message: errorHandler.getErrorMessage(err)
			});
		} else {
			res.jsonp(workouts);
		}
	});
};

/**
 * Workout middleware
 */
exports.workoutByID = function(req, res, next, id) { Workout.findById(id).exec(function(err, workout) {
		if (err) return next(err);
		if (! workout) return next(new Error('Failed to load Workout ' + id));
		req.workout = workout ;
		next();
	});
};
{'fraction_non_alphanumeric': 0.1801538869726718, 'fraction_numerical': 0.006367736800212258, 'mean_word_length': 3.6658415841584158, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3956065', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1326, 'n_words': 252}