<commit_before>var keystone = require('keystone');
var operation = keystone.list('Operation');

exports = module.exports = function (req, res) {
  operation.model.search(req.query.text, function (err, data) {
    if (err) {
      res.status(500).render('errors/500', {
        err: err,
        errorTitle: 'Databasfel',
        errorMsg: 'Kunde inte söka i databasen'
      });
      return;
    }
    res.send(data);
  });
};<commit_msg>Limit on search added and issue #1 resolved<commit_after>var keystone = require('keystone');
var operation = keystone.list('Operation');

exports = module.exports = function (req, res) {
  operation.model.search(req.query.text, function (err, data) {
    if (err) {
      res.status(500).render('errors/500', {
        err: err,
        errorTitle: 'Databasfel',
        errorMsg: 'Kunde inte söka i databasen'
      });
      return;
    }    
    if (req.query.text !== '') {      
      if (typeof(req.query.limit) === 'undefined') {        
        res.send(data.slice(0, 10));    
      } 
      else {
        res.send(data.slice(0, req.query.limit));
      }       
    }
  });
};
{'fraction_non_alphanumeric': 0.15896980461811722, 'fraction_numerical': 0.015097690941385435, 'mean_word_length': 2.425531914893617, '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': '3363488', 'n_tokens_mistral': 385, 'n_tokens_neox': 367, 'n_words': 76}