Fixed conflicts in merge
This commit is contained in:
commit
cc1a5641ea
@ -24,11 +24,10 @@ module.exports = function batchFactory (metadataBackend) {
|
||||
var userIndexer = new UserIndexer(metadataBackend);
|
||||
var jobBackend = new JobBackend(metadataBackend, jobQueue, jobPublisher, userIndexer);
|
||||
var userDatabaseMetadataService = new UserDatabaseMetadataService(metadataBackend);
|
||||
// TODO: down userDatabaseMetadataService
|
||||
var queryRunner = new QueryRunner();
|
||||
var queryRunner = new QueryRunner(userDatabaseMetadataService);
|
||||
var jobCanceller = new JobCanceller(userDatabaseMetadataService);
|
||||
var jobService = new JobService(jobBackend, jobCanceller);
|
||||
var jobRunner = new JobRunner(jobService, jobQueue, queryRunner, userDatabaseMetadataService);
|
||||
var jobRunner = new JobRunner(jobService, jobQueue, queryRunner);
|
||||
|
||||
return new Batch(jobSubscriber, jobQueuePool, jobRunner, jobService);
|
||||
};
|
||||
|
@ -29,8 +29,7 @@ function toRedisParams(job) {
|
||||
for (var property in obj) {
|
||||
if (obj.hasOwnProperty(property)) {
|
||||
redisParams.push(property);
|
||||
// TODO: this should be moved to job model ??
|
||||
if ((property === 'query' || property === 'status') && typeof obj[property] !== 'string') {
|
||||
if (property === 'query' && typeof obj[property] !== 'string') {
|
||||
redisParams.push(JSON.stringify(obj[property]));
|
||||
} else {
|
||||
redisParams.push(obj[property]);
|
||||
@ -65,7 +64,6 @@ function toObject(job_id, redisParams, redisValues) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
// TODO: is it really necessary??
|
||||
function isJobFound(redisValues) {
|
||||
return redisValues[0] && redisValues[1] && redisValues[2] && redisValues[3] && redisValues[4];
|
||||
}
|
||||
|
@ -3,11 +3,10 @@
|
||||
var errorCodes = require('../app/postgresql/error_codes').codeToCondition;
|
||||
var jobStatus = require('./job_status');
|
||||
|
||||
function JobRunner(jobService, jobQueue, queryRunner, userDatabaseMetadataService) {
|
||||
function JobRunner(jobService, jobQueue, queryRunner) {
|
||||
this.jobService = jobService;
|
||||
this.jobQueue = jobQueue;
|
||||
this.queryRunner = queryRunner;
|
||||
this.userDatabaseMetadataService = userDatabaseMetadataService; // TODO: move to queryRunner
|
||||
}
|
||||
|
||||
JobRunner.prototype.run = function (job_id, callback) {
|
||||
@ -39,13 +38,7 @@ JobRunner.prototype.run = function (job_id, callback) {
|
||||
JobRunner.prototype._run = function (job, query, callback) {
|
||||
var self = this;
|
||||
|
||||
// TODO: move to query
|
||||
self.userDatabaseMetadataService.getUserMetadata(job.data.user, function (err, userDatabaseMetadata) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
self.queryRunner.run(job.data.job_id, query, userDatabaseMetadata, function (err /*, result */) {
|
||||
self.queryRunner.run(job.data.job_id, query, job.data.user, function (err /*, result */) {
|
||||
if (err) {
|
||||
if (!err.code) {
|
||||
return callback(err);
|
||||
@ -76,7 +69,7 @@ JobRunner.prototype._run = function (job, query, callback) {
|
||||
return callback(null, job);
|
||||
}
|
||||
|
||||
self.jobQueue.enqueue(job.data.job_id, userDatabaseMetadata.host, function (err) {
|
||||
self.jobQueue.enqueue(job.data.job_id, job.data.host, function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@ -85,7 +78,6 @@ JobRunner.prototype._run = function (job, query, callback) {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = JobRunner;
|
||||
|
@ -19,6 +19,7 @@ var mandatoryProperties = [
|
||||
'query',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'host',
|
||||
'user'
|
||||
];
|
||||
|
||||
|
@ -2,12 +2,18 @@
|
||||
|
||||
var PSQL = require('cartodb-psql');
|
||||
|
||||
function QueryRunner() {
|
||||
function QueryRunner(userDatabaseMetadataService) {
|
||||
this.userDatabaseMetadataService = userDatabaseMetadataService;
|
||||
}
|
||||
|
||||
module.exports = QueryRunner;
|
||||
|
||||
QueryRunner.prototype.run = function (job_id, sql, userDatabaseMetadata, callback) {
|
||||
QueryRunner.prototype.run = function (job_id, sql, user, callback) {
|
||||
this.userDatabaseMetadataService.getUserMetadata(user, function (err, userDatabaseMetadata) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var pg = new PSQL(userDatabaseMetadata, {}, { destroyOnError: true });
|
||||
|
||||
pg.query('SET statement_timeout=0', function (err) {
|
||||
@ -34,5 +40,5 @@ QueryRunner.prototype.run = function (job_id, sql, userDatabaseMetadata, callbac
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user