<commit_before>var express = require("express");
var Q = require('q');
var router = express.Router();


/*
 Usage:
 localhost:50001/AddInventory/productId/quantity/location
 */

router.route("/:productId/:quantity/:location").get(function(req, res) {
    var db = require("../imp_services/impdb.js").connect();

    //Q.longStackSupport = true;   // for error checking

    Q.fcall(db.beginTransaction())
        .then(db.query("USE " + db.databaseName))
        .then(db.query("CALL AddInventory (" + req.params.productId + ", " + req.params.quantity + ", '" + req.params.location + "')"))
        // TODO: log this entry?
        .then(db.commit())
        .then(db.endTransaction())
        .then(function(){
            console.log("Successfully added new inventory. Product: " + req.params.productId + ", Quantity: " + req.params.quantity + ", Location: " + req.params.location + ".");
            res.send("Success");
        })
        .then(function() {
            //TODO Make this a promise chain??
            require('../imp_services/implogging')(req.cookies.IMPId, function(logService){
                logService.action.productId = req.params.productId;
                logService.action.quantity = req.params.quantity;
                logService.action.location = req.params.location;
                logService.setType(100);
                logService.store(function(err, results){
                    if(err){
                        res.status(500).send(err);
                    } else {
                        console.log("Successfully logged new inventory added.")
                    }
                });
            });

        })
        //.done()

        .catch(function(err){
            Q.fcall(db.rollback())
                .then(db.endTransaction())
                .done();
            console.log("Error: " + err);
            //console.error(err.stack);
            res.status(503).send("ERROR: " + err);
        })
        .done();
});

module.exports = router;<commit_msg>trying to get first log attempt to work<commit_after>var express = require("express");
var Q = require('q');
var router = express.Router();


/*
 Usage:
 localhost:50001/AddInventory/productId/quantity/location
 */

router.route("/:productId/:quantity/:location").get(function(req, res) {
    var db = require("../imp_services/impdb.js").connect();

    //Q.longStackSupport = true;   // for error checking

    Q.fcall(db.beginTransaction())
        .then(db.query("USE " + db.databaseName))
        .then(db.query("CALL AddInventory (" + req.params.productId + ", " + req.params.quantity + ", '" + req.params.location + "')"))
        // TODO: log this entry?
        .then(db.commit())
        .then(db.endTransaction())
        .then(function(){
            console.log("Successfully added new inventory. Product: " + req.params.productId + ", Quantity: " + req.params.quantity + ", Location: " + req.params.location + ".");
            res.send("Success");
        })
        .catch(function(err){
            Q.fcall(db.rollback())
                .then(db.endTransaction())
                .done();
            console.log("Error: " + err);
            //console.error(err.stack);
            res.status(503).send("ERROR: " + err);
        })
        .then(function() {
            //TODO Make this a promise chain??
            require('../imp_services/implogging')(req.cookies.IMPId, function(logService){
                logService.action.productId = req.params.productId;
                logService.action.quantity = req.params.quantity;
                logService.action.location = req.params.location;
                logService.setType(100);
                logService.store(function(err, results){
                    if(err){
                        res.status(500).send(err);
                    } else {
                        console.log("Successfully logged new inventory added.")
                    }
                });
            });
        })
        .done();
});

module.exports = router;
{'fraction_non_alphanumeric': 0.15714995034756704, 'fraction_numerical': 0.006951340615690168, 'mean_word_length': 1.8493635077793493, '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': '4001123', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1089, 'n_words': 177}