<commit_before>var express = require('express');
var router = express.Router();
var request = require('request');
var Step = require('step');

var OUR_GROUP_URL_NAME = 'Free-Code-Camp-NWA';

// converts military time to standard time
// accepts a string in these formats:
//   HH:mm:ss
//   HH:mm
// returns an object in this format:
//   hour: HH
//   min:  mm
//   period: am | pm
function convertMilitaryTime(time) {

    // splits the time into an array using the colon as separator
    var splitTime = time.split(':');

    // converts the strings to integers
    var hour = parseInt(splitTime[0]);
    var min = splitTime[1];
    var period = '';

    // converts the hour from military time to standard time
    if (hour === 0) {
        hour = 12;
        period = 'am';
    } else if (hour <= 11) {
        period = 'am';
    } else if (hour === 12) {
        period = 'pm';
    } else if (hour > 12) {
        hour = hour - 12;
        period = 'pm';
    }

    // creates the converted time object and returns it
    var convertedTime = {
        hour: hour.toString(),
        min: min,
        period: period
    };

    return convertedTime;
}


/* GET home page. */
router.get('/', function(req, res, next) {
    res.render('index');
});

// /* GET meetup page */
 router.get('/meetup', function(req, res) {

    // use Step to synchronize the API call
    // so we don't try to process data until
    // we've received it
    Step(
        function getMeetupData() {

            var self = this;

            var meetupApiUrl = 'https://api.meetup.com/2/events?group_urlname='
            + OUR_GROUP_URL_NAME
            + '&status=upcoming&page=10';

            // uses the request Node library to send the get request
            request.get(meetupApiUrl, function(error, response, jsonData) {

                // if successful, pass along the jsonData
                // else, pass along an error
                if (!error && response.statusCode == 200) {
                    self(null, jsonData);
                    console.log(jsonData);
                } else {
                    self(error, jsonData);
                }
            });
        },
        function processMeetupData(err, meetupDataJSON) {

            // Uh oh, there's an error.
            // Render the error template.
            if (err !== null) {

                res.render('error', {
                    message: 'Error getting data from Meetup.',
                    error: err
                });
            // No error.
            // Render the meetup template.
            } else {

                // need to parse the JSON to de-serialize it
                // from a string to an object we can work with
                // Thank you, Blake. -- Roy :-)
                dataJSON = JSON.parse(meetupDataJSON);
console.log(dataJSON);

if(dataJSON.results.length  ===0) {
  res.send('We will change this to render the jade page...');
} else {
                // meetup time is in format of milliseconds since epoch
                // convert to local date time
                var msUTC = dataJSON.results[0].time;<commit_msg>Update empty route<commit_after>var express = require('express');
var router = express.Router();
var request = require('request');
var Step = require('step');

var OUR_GROUP_URL_NAME = 'Free-Code-Camp-NWA';

// converts military time to standard time
// accepts a string in these formats:
//   HH:mm:ss
//   HH:mm
// returns an object in this format:
//   hour: HH
//   min:  mm
//   period: am | pm
function convertMilitaryTime(time) {

    // splits the time into an array using the colon as separator
    var splitTime = time.split(':');

    // converts the strings to integers
    var hour = parseInt(splitTime[0]);
    var min = splitTime[1];
    var period = '';

    // converts the hour from military time to standard time
    if (hour === 0) {
        hour = 12;
        period = 'am';
    } else if (hour <= 11) {
        period = 'am';
    } else if (hour === 12) {
        period = 'pm';
    } else if (hour > 12) {
        hour = hour - 12;
        period = 'pm';
    }

    // creates the converted time object and returns it
    var convertedTime = {
        hour: hour.toString(),
        min: min,
        period: period
    };

    return convertedTime;
}


/* GET home page. */
router.get('/', function(req, res, next) {
    res.render('index');
});

// /* GET meetup page */
 router.get('/meetup', function(req, res) {

    // use Step to synchronize the API call
    // so we don't try to process data until
    // we've received it
    Step(
        function getMeetupData() {

            var self = this;

            var meetupApiUrl = 'https://api.meetup.com/2/events?group_urlname='
            + OUR_GROUP_URL_NAME
            + '&status=upcoming&page=10';

            // uses the request Node library to send the get request
            request.get(meetupApiUrl, function(error, response, jsonData) {

                // if successful, pass along the jsonData
                // else, pass along an error
                if (!error && response.statusCode == 200) {
                    self(null, jsonData);
                    console.log(jsonData);
                } else {
                    self(error, jsonData);
                }
            });
        },
        function processMeetupData(err, meetupDataJSON) {

            // Uh oh, there's an error.
            // Render the error template.
            if (err !== null) {

                res.render('error', {
                    message: 'Error getting data from Meetup.',
                    error: err
                });
            // No error.
            // Render the meetup template.
            } else {

                // need to parse the JSON to de-serialize it
                // from a string to an object we can work with
                // Thank you, Blake. -- Roy :-)
                dataJSON = JSON.parse(meetupDataJSON);
console.log(dataJSON);

if(dataJSON.results.length  ===0) {
  res.render('empty');
} else {
                // meetup time is in format of milliseconds since epoch
                // convert to local date time
                var msUTC = dataJSON.results[0].time;
{'fraction_non_alphanumeric': 0.11658114175753688, 'fraction_numerical': 0.006735086593970494, 'mean_word_length': 1.6450381679389312, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '6388029', 'n_tokens_mistral': 1801, 'n_tokens_neox': 1661, 'n_words': 571}