<commit_before>var Solution = require('./solutionModel');

module.exports = function(app) {
  app.param('qid', function(req, res, next, qid) {
    Solution.find({questionId: qid}).populate('questionId').populate('userId')
    .exec(function(err, data) {
      if (err) {
        //res.send(500, err);
        res.status(500).send(err);
      } else {
        req.solutionData = data;
        next();
      }
    });
  });

  app.get('/solutions/:qid', function(req, res, next) {
    res.status(200);
    res.send(req.solutionData);
  });

  app.get('/solutions', function(req, res, next) {
    Solution.find().exec(function(err, data) {
      if (err) {
        res.send(500, err);
      } else {<commit_msg>Sort solutions by vote number.<commit_after>var Solution = require('./solutionModel');

module.exports = function(app) {
  app.param('qid', function(req, res, next, qid) {
    Solution.find({questionId: qid}).sort( { votes: -1 } ).populate('questionId').populate('userId')
    .exec(function(err, data) {
      if (err) {
        //res.send(500, err);
        res.status(500).send(err);
      } else {
        req.solutionData = data;
        next();
      }
    });
  });

  app.get('/solutions/:qid', function(req, res, next) {
    res.status(200);
    res.send(req.solutionData);
  });

  app.get('/solutions', function(req, res, next) {
    Solution.find().exec(function(err, data) {
      if (err) {
        res.send(500, err);
      } else {
{'fraction_non_alphanumeric': 0.19243986254295534, 'fraction_numerical': 0.01718213058419244, 'mean_word_length': 2.704834605597964, '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': '5197257', 'n_tokens_mistral': 516, 'n_tokens_neox': 493, 'n_words': 87}