<commit_before>var express = require('express');
var request = require('request');
var bookingModel = require('../models/booking');
var basicAuth = require('basic-auth');
var validators = require('../utils/validators');
var htmlToText = require('html-to-text');
var router = express.Router();
var formatter = require('../utils/booking_formatter');

/* GET to /bookings: get all bookings for user */
router.get('/', validateUserAndPass, function(req, res, next) {
  var j = request.jar();
  var d = new Date();
  var n = d.toISOString();
  n = n.substring(2, 10);
  request({
    url: 'https://schema.mah.se/resursbokning.jsp?flik=FLIK-0017',
    jar: j
  }, function(err, httpResponse, bodyHandshake) {
    if (!err) {
      var user = req.userAndPassValidationResult.name;
      var pass = req.userAndPassValidationResult.pass;
      request({
        method: 'POST',
        url: 'https://schema.mah.se/login_do.jsp',
        form: {
          username: user,
          password: <PASSWORD>
        },
        jar: j
      }, function(err, httpResponse, body) {
        if (!err) {
          request({
            method: 'GET',
            url: 'https://schema.mah.se/minaresursbokningar.jsp?flik=FLIK-0017&datum=' + n,
            jar: j
          }, function(err, httpResponse, body) {
            var text = htmlToText.fromString(httpResponse.body, {
              wordwrap: 1
            });
            var textArray = text.split('\n');
            if (textArray[18] === 'Inga') {
              return res.send({
                bookings: []
              });
            } else {
              return createBookings(res, textArray);
            }
          });
        }
      });
    }
  });
});

/*
Subroutine for /get bookings
Returns response to user with all bookings if there are any.
 */
function createBookings(res, textArray) {
  var result = [];
  var i = 18;
  while (i != -1) {<commit_msg>Bumped to version 0.2.1, fixed GET to /bookings<commit_after>var express = require('express');
var request = require('request');
var bookingModel = require('../models/booking');
var basicAuth = require('basic-auth');
var validators = require('../utils/validators');
var htmlToText = require('html-to-text');
var router = express.Router();
var formatter = require('../utils/booking_formatter');

/* GET to /bookings: get all bookings for user */
router.get('/', validateUserAndPass, function(req, res, next) {
  var j = request.jar();
  var d = new Date();
  var n = d.toISOString();
  n = n.substring(2, 10);
  request({
    url: 'https://schema.mah.se/resursbokning.jsp?flik=FLIK-0017',
    jar: j
  }, function(err, httpResponse, bodyHandshake) {
    if (!err) {
      var user = req.userAndPassValidationResult.name;
      var pass = req.userAndPassValidationResult.pass;
      request({
        method: 'POST',
        url: 'https://schema.mah.se/login_do.jsp',
        form: {
          username: user,
          password: <PASSWORD>
        },
        jar: j
      }, function(err, httpResponse, body) {
        if (!err) {
          request({
            method: 'GET',
            url: 'https://schema.mah.se/minaresursbokningar.jsp?flik=FLIK-0017&datum=' + n,
            jar: j
          }, function(err, httpResponse, body) {
            var text = htmlToText.fromString(httpResponse.body, {
              wordwrap: 1
            });
            var textArray = text.split('\n');
            if (textArray[18] === 'Inga') {
              return res.send({
                bookings: []
              });
            } else {
              return createBookings(res, textArray);
            }
          });
        }
      });
    }
  });
});

/*
Subroutine for /get bookings
Returns all bookings to the user if there are any.
 */
function createBookings(res, textArray) {
  var result = [];
  var i = 18;
  while (i != -1) {
{'fraction_non_alphanumeric': 0.15088449531737774, 'fraction_numerical': 0.009625390218522373, 'mean_word_length': 2.1620065789473686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, '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': '3579822', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1174, 'n_words': 282}