<commit_before>'use strict';

var express   = require('express'),
    request   = require('request'),
    router    = express.Router(),
    moment    = require('moment'),
    _         = require('lodash-node'),
    maps      = require('../maps'),
    utils     = require('../utils'),
    OAuth     = require('../utils/oauth');

/* GET status */
router.get('/:id([0-9]+)/:subset(arrivals|departures)?', function(req, res, next) {

  var dateTimeFrom = moment()
    .zone('+0200')
    .format('YYYY-MM-DD HH:mm:ss');

  var dateTimeTo   = moment()
    .zone('+0200')
    .add(1, 'hours')
    .format('YYYY-MM-DD HH:mm:ss');

  var params = {
    'dateTimeFrom'  : dateTimeFrom,
    'dateTimeTo'    : dateTimeTo,
    'searchType'    : 0,
    'stationID'     : req.params.id
  };

  request.get(new OAuth('RetrieveStationSchedule', params), function(err, resp, body) {

    if (err || resp.statusCode !== 200)
      return res.send(resp.statusCode || 500, { error: '¯\\_(ツ)_/¯' });

    body = maps.stations.station(body, req.locale);

    var sort, reject;

    if (req.params.subset === 'arrivals') {
      sort = 'arrival';
      reject = function(train) { return train.arrival === null; };
    } else if (req.params.subset === 'departures') {
      sort = 'departure';
      reject = function(train) { return train.departure === null; };
    }

    body.trains = _.chain(body.trains)
      .reject(reject)
      .sortBy(sort)
      .value();

    res.json(body);
  });

});

router.get('/list', function(req, res, next) {

  var params = {
    // 'LastUpdateDate': '1970-08-11 3:35:53 am'
  };

  request.get(new OAuth('RetrieveStationList', params), function(err, resp, body) {

    if (err || resp.statusCode !== 200)
      return res.send(resp.statusCode || 500, { error: '¯\\_(ツ)_/¯' });

    res.json(maps.stations.list(body));
  });

});

module.exports = router;<commit_msg>Added default behavior for a station<commit_after>'use strict';

var express   = require('express'),
    request   = require('request'),
    router    = express.Router(),
    moment    = require('moment'),
    _         = require('lodash-node'),
    maps      = require('../maps'),
    utils     = require('../utils'),
    OAuth     = require('../utils/oauth');

/* GET status */
router.get('/:id([0-9]+)/:subset(arrivals|departures)?', function(req, res, next) {

  var dateTimeFrom = moment()
    .zone('+0200')
    .format('YYYY-MM-DD HH:mm:ss');

  var dateTimeTo   = moment()
    .zone('+0200')
    .add(1, 'hours')
    .format('YYYY-MM-DD HH:mm:ss');

  var params = {
    'dateTimeFrom'  : dateTimeFrom,
    'dateTimeTo'    : dateTimeTo,
    'searchType'    : 0,
    'stationID'     : req.params.id
  };

  request.get(new OAuth('RetrieveStationSchedule', params), function(err, resp, body) {

    if (err || resp.statusCode !== 200)
      return res.send(resp.statusCode || 500, { error: '¯\\_(ツ)_/¯' });

    body = maps.stations.station(body, req.locale);

    var sort, reject;

    if (req.params.subset === 'arrivals') {
      sort = 'arrival';
      reject = function(train) { return train.arrival === null; };
    } else if (req.params.subset === 'departures') {
      sort = 'departure';
      reject = function(train) { return train.departure === null; };
    } else {
      sort = 'departure';
      reject = utils.noop;
    }

    body.trains = _.chain(body.trains)
      .reject(reject)
      .sortBy(sort)
      .value();

    res.json(body);
  });

});

router.get('/list', function(req, res, next) {

  var params = {
    // 'LastUpdateDate': '1970-08-11 3:35:53 am'
  };

  request.get(new OAuth('RetrieveStationList', params), function(err, resp, body) {

    if (err || resp.statusCode !== 200)
      return res.send(resp.statusCode || 500, { error: '¯\\_(ツ)_/¯' });

    res.json(maps.stations.list(body));
  });

});

module.exports = router;
{'fraction_non_alphanumeric': 0.194494936380161, 'fraction_numerical': 0.0192157881069852, 'mean_word_length': 2.7398058252427187, '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': '306542', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1327, 'n_words': 257}