Skip to content

Commit

Permalink
Refactored arguments -> queryArguments
Browse files Browse the repository at this point in the history
  • Loading branch information
silvae86 committed Jun 14, 2017
1 parent 3c8ff57 commit 1ec6f89
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 48 deletions.
7 changes: 4 additions & 3 deletions conf/deployment_configs.json
Original file line number Diff line number Diff line change
Expand Up @@ -876,10 +876,11 @@
"request_times_log_folder" : "logs/request_times",
"log_requests_in_apache_format" : false,
"requests_in_apache_format_log_folder" : "logs/requests_apache_format",
"suppress_all_logs" : true,
"suppress_all_logs" : false,
"suppress_all_errors" : false,
"log_all_requests" : false,
"log_emailing" : false
"log_emailing" : false,
"custom_exception_logging" : false
},
"version" :
{
Expand Down Expand Up @@ -1218,7 +1219,7 @@
"request_times_log_folder" : "logs/request_times",
"log_requests_in_apache_format" : false,
"requests_in_apache_format_log_folder" : "logs/requests_apache_format",
"suppress_all_logs" : true,
"suppress_all_logs" : false,
"suppress_all_errors" : false,
"log_all_requests" : false,
"log_emailing" : false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"report-coverage": "npm run coverage && node ./node_modules/coveralls/bin/coveralls.js < ./coverage/lcov.info && node ./node_modules/codeclimate-test-reporter/bin/codeclimate.js < ./coverage/lcov.info && rm -rf coverage",
"everything": "rm -rf node_modules && npm cache clean && npm install && npm run test && npm run report-coverage",
"remote_debug": "node app.js --debug=5858",
"profile": "node --prof node_modules/.bin/_mocha ./test_new_structure/index.Test.js-t 10000"
"profile": "cross-env NODE_ENV=test node --prof node_modules/.bin/_mocha ./test_new_structure/index.Test.js -t 60000 --ui bdd"
},
"dependencies": {
"archiver": "*",
Expand Down
40 changes: 18 additions & 22 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let async = require('async');
let util = require('util');
let mkdirp = require('mkdirp');
let pid;

let registeredUncaughtExceptionHandler;

//Setup logging
if(!isNull(Config.logging))
Expand Down Expand Up @@ -133,22 +133,27 @@ if(!isNull(Config.logging))
};
}

process.on('uncaughtException', function (err)
if (!registeredUncaughtExceptionHandler && !(typeof Config.logging.app_logs_folder !== "undefined" && Config.logging.pipe_console_to_logfile))
{
const date = new Date().toISOString();

if (!isNull(err.stack))
process.on('uncaughtException', function (err)
{
log_file.write("[ " + date + " ] [ uncaughtException ] " + util.format(err.stack) + "\n");
}
const date = new Date().toISOString();

if(!isNull(pid))
{
pid.remove();
}
if (!isNull(err.stack))
{
log_file.write("[ " + date + " ] [ uncaughtException ] " + util.format(err.stack) + "\n");
}

throw err;
});
if(!isNull(pid))
{
pid.remove();
}

throw err;
});

registeredUncaughtExceptionHandler = true;
}

cb(null);
})
Expand Down Expand Up @@ -1974,15 +1979,6 @@ async.series([
process.exit(err);
});

if (!(typeof Config.logging.app_logs_folder !== "undefined" && Config.logging.pipe_console_to_logfile))
{
process.on('uncaughtException', function (err)
{
pid.remove();
throw err;
});
}

console.log('Express server listening on port ' + app.get('port'));
const appInfo = {server: server, app: app};
bootupPromise.resolve(appInfo);
Expand Down
20 changes: 10 additions & 10 deletions src/kb/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ DbConnection.prototype.deleteTriples = function(triples, graphName, callback)
let i;
let argCount = 1;

const arguments = [
const queryArguments = [
{
type: DbConnection.resourceNoEscape,
value: graphName
Expand All @@ -650,15 +650,15 @@ DbConnection.prototype.deleteTriples = function(triples, graphName, callback)
//build the delete string
triplesToDeleteString = triplesToDeleteString + " [" + argCount++ + "]";

arguments.push({
queryArguments.push({
type : DbConnection.resource,
value : triple.subject
});


triplesToDeleteString = triplesToDeleteString + " [" + argCount++ + "]";

arguments.push({
queryArguments.push({
type : DbConnection.resource,
value : triple.predicate
});
Expand All @@ -667,7 +667,7 @@ DbConnection.prototype.deleteTriples = function(triples, graphName, callback)
{
triplesToDeleteString = triplesToDeleteString + " [" + argCount++ + "]";

arguments.push({
queryArguments.push({
type : triple.object.type,
value : triple.object.value
});
Expand Down Expand Up @@ -704,7 +704,7 @@ DbConnection.prototype.deleteTriples = function(triples, graphName, callback)
});
}

self.execute(query, arguments, function(err, results)
self.execute(query, queryArguments, function(err, results)
{
callback(err, results);
});
Expand All @@ -724,7 +724,7 @@ DbConnection.prototype.insertDescriptorsForSubject = function(subject, newDescri
let insertString = "";
let argCount = 1;

const arguments = [
const queryArguments = [
{
type: DbConnection.resourceNoEscape,
value: graphName
Expand All @@ -746,21 +746,21 @@ DbConnection.prototype.insertDescriptorsForSubject = function(subject, newDescri

insertString = insertString + " [" + argCount++ + "] ";

arguments.push({
queryArguments.push({
type : DbConnection.resource,
value : subject
});

insertString = insertString + " [" + argCount++ + "] ";

arguments.push({
queryArguments.push({
type : DbConnection.resource,
value : newDescriptor.uri
});

insertString = insertString + " [" + argCount++ + "] ";

arguments.push({
queryArguments.push({
type : newDescriptor.type,
value : objects[j]
});
Expand All @@ -780,7 +780,7 @@ DbConnection.prototype.insertDescriptorsForSubject = function(subject, newDescri
let redis = GLOBAL.redis.default;
redis.connection.delete(subject, function(err, result){});

self.execute(query, arguments, function(err, results)
self.execute(query, queryArguments, function(err, results)
{
callback(err, results);
//console.log(results);
Expand Down
6 changes: 3 additions & 3 deletions src/models/meta/research_domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ResearchDomain.findByTitleOrDescription = function(query, callback, max_results
" } \n" +
"} \n";

const arguments = [
const queryArguments = [
{
type: DbConnection.resourceNoEscape,
value: db.graphUri
Expand All @@ -90,14 +90,14 @@ ResearchDomain.findByTitleOrDescription = function(query, callback, max_results
{
query = query + "LIMIT [1]";

arguments.push({
queryArguments.push({
type : DbConnection.int,
value : max_results
})
}

db.connection.execute(query,
arguments,
queryArguments,
function(err, results)
{
if (!err)
Expand Down
18 changes: 9 additions & 9 deletions src/models/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Resource.all = function(callback, req, customGraphUri, descriptorTypesToRemove,
);
}

const arguments = [
const queryArguments = [
{
type: DbConnection.resourceNoEscape,
value: graphUri
Expand All @@ -130,15 +130,15 @@ Resource.all = function(callback, req, customGraphUri, descriptorTypesToRemove,

if(!isNull(type))
{
arguments.push({
queryArguments.push({
type : DbConnection.prefixedResource,
value : type
});
}

db.connection.execute(
query,
arguments,
queryArguments,
function(err, results) {
if(!err)
{
Expand Down Expand Up @@ -668,7 +668,7 @@ Resource.prototype.replaceDescriptorsInTripleStore = function(newDescriptors, gr
let predCount = 0;
let argCount = 1;

const arguments = [
const queryArguments = [
{
type: DbConnection.resourceNoEscape,
value: graphName
Expand All @@ -678,7 +678,7 @@ Resource.prototype.replaceDescriptorsInTripleStore = function(newDescriptors, gr
//build the delete string
deleteString = deleteString + " [" + argCount++ + "]";

arguments.push({
queryArguments.push({
type : DbConnection.resource,
value : subject
});
Expand All @@ -704,21 +704,21 @@ Resource.prototype.replaceDescriptorsInTripleStore = function(newDescriptors, gr
{
insertString = insertString + " [" + argCount++ + "] ";

arguments.push({
queryArguments.push({
type : DbConnection.resource,
value : subject
});

insertString = insertString + " [" + argCount++ + "] ";

arguments.push({
queryArguments.push({
type : DbConnection.resource,
value : newDescriptor.uri
});

insertString = insertString + " [" + argCount++ + "] ";

arguments.push({
queryArguments.push({
type : newDescriptor.type,
value : objects[j]
});
Expand Down Expand Up @@ -746,7 +746,7 @@ Resource.prototype.replaceDescriptorsInTripleStore = function(newDescriptors, gr
//Invalidate cache record for the updated resources
redis().connection.delete(subject, function(err, result){});

db.connection.execute(query, arguments, function(err, results)
db.connection.execute(query, queryArguments, function(err, results)
{
callback(err, results);
//console.log(results);
Expand Down

0 comments on commit 1ec6f89

Please sign in to comment.