<commit_before>'use strict';

var utils = require('./utils');
var trim = require('trim');

module.exports = function(pg, persistence, broadcast, consumptionsPersistence) {
  var consumers = {};

  consumers.list = function(req, res) {
    console.log("list Consumers");

    // get a pg client from the connection pool
    pg.connect(function(err, client, done) {
      if(utils.handleError(err, client, done, res)) { return; }

      persistence.getAllConsumersSortedByConsumption(client, function(err, consumers) {
        if(utils.handleError(err, client, done, res)) { return; }

        done();
        res.json(consumers);
      });
    });
  };

  consumers.create = function(req, res) {
    console.log("create Consumer");

    //TODO: users may not have the same name as a drinks barcode, this would
    // create issues on the client side.
    console.log("Request body:", req.body);

    var escapedName = trim(req.body.username);

    if(escapedName == "") {
      res.status(400);
      res.json({
        message: 'Empty String Not Allowed'
      });
    }

    var userdata = {<commit_msg>returning after rejecting username<commit_after>'use strict';

var utils = require('./utils');
var trim = require('trim');

module.exports = function(pg, persistence, broadcast, consumptionsPersistence) {
  var consumers = {};

  consumers.list = function(req, res) {
    console.log("list Consumers");

    // get a pg client from the connection pool
    pg.connect(function(err, client, done) {
      if(utils.handleError(err, client, done, res)) { return; }

      persistence.getAllConsumersSortedByConsumption(client, function(err, consumers) {
        if(utils.handleError(err, client, done, res)) { return; }

        done();
        res.json(consumers);
      });
    });
  };

  consumers.create = function(req, res) {
    console.log("create Consumer");

    //TODO: users may not have the same name as a drinks barcode, this would
    // create issues on the client side.
    console.log("Request body:", req.body);

    var escapedName = trim(req.body.username);

    if(escapedName == "") {
      res.status(400);
      res.json({
        message: 'Empty String Not Allowed'
      });
      return;
    }

    var userdata = {
{'fraction_non_alphanumeric': 0.13776192599197504, 'fraction_numerical': 0.0026749888542131075, 'mean_word_length': 3.0, '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': '897118', 'n_tokens_mistral': 678, 'n_tokens_neox': 652, 'n_words': 178}