<commit_before>var IMPLEMENTS = 'people';
var INJECT = ['logger', 'presence', 'config'];

var express = require('express');
var bodyParser = require('body-parser');

function factory(services) {
  var people = services.config.people;
  var presence = services.presence;
  var logger = services.logger.getLogger('people');

  var svc = {all:[]};

  presence.add('person:any', {category:'person', name:'Anyone'});

  people.forEach(function(person) {
    presence.add('person:'+person.id, {category:'person', name:person.name, timeout:person.timeout, parent:'person:any'});
    svc.all.push({id: person.id});
  });


  var app = express();
  app.use(bodyParser.json());

  app.use('/:who/:what', function(req, res) {

    var who = req.params.who;
    var what = req.params.what;
    var present;

    if (what === 'present' || what === 'away') {
      
      present = what;

    } else if (what === 'geohopper') {

      present = req.body.event === 'LocationEnter' ? 'present' : 'away';
      logger.debug('Geohopper: ' + who + ' - ' + req.body.event);

    } else {

      res.status(500).send('error');
      return;

    }

    var p = presence['person:'+who];

    if (!p) {
      return res.status(500).send('Cannot find person:'+who);
    }
    var method = (present === 'present') ? 'set' : 'clear';
    p[method]();
    res.send(who + ' is ' + present);
    logger.info('Person: ' + who + ' - ' + present);

  });

  return {
    app: app
  };

}
<commit_msg>fix legacy crap<commit_after>var IMPLEMENTS = 'people';
var INJECT = ['logger', 'presence', 'config'];

var express = require('express');
var bodyParser = require('body-parser');

function factory(services) {
  var people = services.config.people;
  var presence = services.presence;
  var logger = services.logger.getLogger('people');

  var svc = {all:[]};

  presence.add('person:any', {category:'person', name:'Anyone'});

  people.forEach(function(person) {
    presence.add('person:'+person.id, {category:'person', name:person.name, timeout:person.timeout, parent:'person:any'});
    svc.all.push({id: person.id});
  });


  var app = express();
  app.use(bodyParser.json());

  app.use('/:who/:what', function(req, res) {

    var who = req.params.who;
    var what = req.params.what;
    var present;

    if (what === 'present' || what === 'away') {
      
      present = what;

    } else if (what === 'geohopper') {

      present = req.body.event === 'LocationEnter' ? 'present' : 'away';
      logger.debug('Geohopper: ' + who + ' - ' + req.body.event);

    } else {

      res.status(500).send('error');
      return;

    }

    var p = presence.get('person:'+who);

    if (!p) {
      return res.status(500).send('Cannot find person:'+who);
    }
    var method = (present === 'present') ? 'set' : 'clear';
    p[method]();
    res.send(who + ' is ' + present);
    logger.info('Person: ' + who + ' - ' + present);

  });

  return {
    app: app
  };

}

{'fraction_non_alphanumeric': 0.19884432358939497, 'fraction_numerical': 0.004078857919782461, 'mean_word_length': 3.133426966292135, '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': '1957899', 'n_tokens_mistral': 1011, 'n_tokens_neox': 968, 'n_words': 204}