-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
315 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
let QueryRunner = require('./query-runner'); | ||
|
||
let queryRunner = new QueryRunner().getInstance(); | ||
|
||
class BuildHivSummary { | ||
|
||
constructor() { | ||
|
||
} | ||
|
||
runJob() { | ||
return new Promise((resolve, reject) => { | ||
let sql = `select count(*) as items_in_queue from etl.flat_hiv_summary_build_queue`; | ||
|
||
queryRunner.runQuery(sql) | ||
.then((result) => { | ||
let items = result.results[0].items_in_queue; | ||
console.log('Items in queue:' + items); | ||
|
||
let batches = items < 50 ? 1 : items / 50; | ||
batches = Math.ceil(batches); | ||
console.log('batches: ' + batches); | ||
|
||
let queries = []; | ||
|
||
for(let i =0; i < batches; i++) { | ||
let qry = `call generate_hiv_summary_v15_7("build",${i},50,20);`; | ||
queries.push(queryRunner.runQuery(qry)); | ||
} | ||
|
||
Promise.all(queries).then((results)=>{ | ||
console.log('finished running all the queries', results); | ||
resolve(results); | ||
}).catch((err)=>{ | ||
reject(err); | ||
console.error('Error running all the queries', err); | ||
}); | ||
|
||
//resolve(parallelism) | ||
}) | ||
.catch((err) => { | ||
// handle error | ||
reject(err); | ||
}); | ||
|
||
}); | ||
} | ||
|
||
} | ||
|
||
module.exports = BuildHivSummary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Object to capture process exits and call app specific cleanup function | ||
|
||
function noOp() {}; | ||
|
||
exports.Cleanup = function Cleanup(callback) { | ||
|
||
// attach user callback to the process event emitter | ||
// if no callback, it will still exit gracefully on Ctrl-C | ||
callback = callback || noOp; | ||
process.on('cleanup',callback); | ||
|
||
// do app specific cleaning before exiting | ||
process.on('exit', function () { | ||
process.emit('cleanup'); | ||
}); | ||
|
||
// catch ctrl+c event and exit normally | ||
process.on('SIGINT', function () { | ||
console.log('Ctrl-C...'); | ||
process.exit(2); | ||
}); | ||
|
||
//catch uncaught exceptions, trace, then exit normally | ||
process.on('uncaughtException', function(e) { | ||
console.log('Uncaught Exception...'); | ||
console.log(e.stack); | ||
process.exit(99); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
let config = { | ||
host : 'localhost', | ||
user : 'admin', | ||
password: 'admin', | ||
database: 'test' | ||
}; | ||
|
||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
let BuildHivSummary = require('./build-hiv-summary'); | ||
let ScheduleHivSummary = require('./schedule-hiv-summary'); | ||
let Moment = require('moment'); | ||
try { | ||
let buildJob = new BuildHivSummary(); | ||
let startedAt = Moment(); | ||
console.log('Starting at:', startedAt.toLocaleString()) | ||
buildJob.runJob().then(() => { | ||
console.log('Finshed all jobs.'); | ||
let endedAt = Moment(); | ||
let diff = endedAt.diff(startedAt, 'seconds'); | ||
console.log('Took ' + diff + ' seconds.'); | ||
}).catch((err) => { | ||
console.error('error running hiv summary job'); | ||
throw err; | ||
}); | ||
} catch (error) { | ||
console.error('Error running pipeline', error); | ||
} | ||
|
||
process.stdin.resume(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.