Skip to content

Commit

Permalink
Merge pull request #760 from veg/mongoose-5-migration
Browse files Browse the repository at this point in the history
mongoose 5 migration
  • Loading branch information
stevenweaver authored Nov 20, 2024
2 parents 441e3e8 + 4f48820 commit 4977e66
Show file tree
Hide file tree
Showing 20 changed files with 228 additions and 173 deletions.
7 changes: 4 additions & 3 deletions app/models/absrel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ var mongoose = require("mongoose"),
logger = require("../../lib/logger"),
helpers = require(__dirname + "/../../lib/helpers.js");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var aBSREL = AnalysisSchema.extend({
var aBSREL = new mongoose.Schema({
tagged_nwk_tree: String,
analysis_type: Number,
last_status_msg: String,
results: Object,
});

// Inherit fields from BaseSchema
aBSREL.add(AnalysisSchema);

aBSREL.virtual("max_sequences").get(function () {
return 75;
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/bgm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ var mongoose = require("mongoose"),
logger = require("../../lib/logger"),
helpers = require(__dirname + "/../../lib/helpers.js");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var BGM = AnalysisSchema.extend({
var BGM = new mongoose.Schema({
analysis_type: Number,
substitution_model: Number,
last_status_msg: String,
Expand All @@ -19,6 +17,8 @@ var BGM = AnalysisSchema.extend({
results: Object,
});

BGM.add(AnalysisSchema);

BGM.virtual("pmid").get(function () {
return "18562270";
});
Expand Down
4 changes: 3 additions & 1 deletion app/models/busted.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var Busted = AnalysisSchema.extend({
var Busted = new mongoose.Schema({
tagged_nwk_tree: String,
last_status_msg: String,
multihit: String,
results: Object,
ds_variation: Number,
});

Busted.add(AnalysisSchema);

Busted.virtual("analysistype").get(function () {
return "busted";
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/contrast-fel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ var mongoose = require("mongoose"),
path = require("path"),
helpers = require("../../lib/helpers");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var ContrastFEL = AnalysisSchema.extend({
var ContrastFEL = mongoose.Schema({
tagged_nwk_tree: String,
analysis_type: Number,
original_extension: String,
Expand All @@ -16,6 +14,8 @@ var ContrastFEL = AnalysisSchema.extend({
ds_variation: Number,
});

ContrastFEL.add(AnalysisSchema);

ContrastFEL.virtual("pmid").get(function () {
return "22807683";
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/fade.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ var mongoose = require("mongoose"),
logger = require("../../lib/logger"),
helpers = require(__dirname + "/../../lib/helpers.js");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var Fade = AnalysisSchema.extend({
var Fade = mongoose.Schema({
analysis_type: Number,
last_status_msg: String,
results: Object,
Expand All @@ -21,6 +19,8 @@ var Fade = AnalysisSchema.extend({
posterior_estimation_method: Number,
});

Fade.add(AnalysisSchema);

Fade.virtual("pmid").get(function () {
return "22807683";
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/fel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ var mongoose = require("mongoose"),
logger = require("../../lib/logger"),
helpers = require("../../lib/helpers");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var FEL = AnalysisSchema.extend({
var FEL = mongoose.Schema({
tagged_nwk_tree: String,
analysis_type: Number,
original_extension: String,
Expand All @@ -19,6 +17,8 @@ var FEL = AnalysisSchema.extend({
bootstrap: Boolean,
});

FEL.add(AnalysisSchema);

FEL.virtual("pmid").get(function () {
return "22807683";
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/flea.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ var mongoose = require("mongoose"),
winston = require("winston"),
Msa = require(__dirname + "/msa");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var Flea = AnalysisSchema.extend({
var Flea = mongoose.Schema({
msas: [Msa.MsaSchema],
last_status_msg: String,
mail: String,
results: Object,
});

Flea.add(AnalysisSchema);

Flea.virtual("analysistype").get(function () {
return "flea";
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/fubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ var mongoose = require("mongoose"),
path = require("path"),
helpers = require("../../lib/helpers");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var FUBAR = AnalysisSchema.extend({
var FUBAR = mongoose.Schema({
analysis_type: Number,
last_status_msg: String,
results: Object,
number_of_grid_points: Number,
concentration_of_dirichlet_prior: Number,
});

FUBAR.add(AnalysisSchema);

FUBAR.virtual("pmid").get(function () {
return "22807683";
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/gard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ var mongoose = require("mongoose"),
logger = require("../../lib/logger"),
helpers = require("../../lib/helpers");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var GARD = AnalysisSchema.extend({
var GARD = mongoose.Schema({
analysis_type: Number,
datatype: String,
run_mode: String,
Expand All @@ -17,6 +15,8 @@ var GARD = AnalysisSchema.extend({
rate_classes: Number,
});

GARD.add(AnalysisSchema);

GARD.virtual("pmid").get(function () {
return "22807683";
});
Expand Down
39 changes: 19 additions & 20 deletions app/models/hivtrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const mongoose = require("mongoose"),
mailer = require(path.join(__dirname, "/../../lib/mailer.js")),
winston = require("winston");

require("mongoose-schema-extend");

const Schema = mongoose.Schema;

function notEmptyValidator(val) {
Expand Down Expand Up @@ -325,9 +323,8 @@ HivTrace.methods.addAttributesToResults = function (cb) {
try {
let json_results = JSON.parse(results);

json_results["trace_results"][
"patient_attribute_schema"
] = patient_schema;
json_results["trace_results"]["patient_attribute_schema"] =
patient_schema;

// annotate each node with the attributes
_.each(json_results["trace_results"].Nodes, function (node) {
Expand Down Expand Up @@ -362,22 +359,24 @@ HivTrace.methods.onComplete = function (data, publisher, channel) {
if (data) {
// save results to file
//self.results = data.results;
fs.writeFile(self.trace_results, JSON.stringify(data.results), function (
err
) {
if (err) throw err;
winston.info("saved results file");

if (self.mail) {
mailer.sendJobComplete(self);
}

//Update the status for the analysis
self.save(function (err, result) {
fs.writeFile(
self.trace_results,
JSON.stringify(data.results),
function (err) {
if (err) throw err;
publisher.publish(channel, JSON.stringify(redis_packet));
});
});
winston.info("saved results file");

if (self.mail) {
mailer.sendJobComplete(self);
}

//Update the status for the analysis
self.save(function (err, result) {
if (err) throw err;
publisher.publish(channel, JSON.stringify(redis_packet));
});
}
);
winston.info("job complete; got results");
} else {
winston.error("job complete, but no data received");
Expand Down
6 changes: 3 additions & 3 deletions app/models/meme.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ var mongoose = require("mongoose"),
logger = require("../../lib/logger"),
helpers = require("../../lib/helpers");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var MEME = AnalysisSchema.extend({
var MEME = mongoose.Schema({
analysis_type: Number,
last_status_msg: String,
results: Object,
resample: Number,
bootstrap: Boolean,
});

MEME.add(AnalysisSchema);

MEME.virtual("pmid").get(function () {
return "22807683";
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/multihit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ var mongoose = require("mongoose"),
logger = require("../../lib/logger"),
helpers = require(__dirname + "/../../lib/helpers.js");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var MULTIHIT = AnalysisSchema.extend({
var MULTIHIT = mongoose.Schema({
last_status_msg: String,
results: Object,
triple_islands: String,
rate_classes: Number,
});

MULTIHIT.add(AnalysisSchema);

MULTIHIT.virtual("analysistype").get(function () {
return "multihit";
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/nrm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ var mongoose = require("mongoose"),
logger = require("../../lib/logger"),
helpers = require(__dirname + "/../../lib/helpers.js");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var NRM = AnalysisSchema.extend({
var NRM = mongoose.Schema({
last_status_msg: String,
results: Object,
});

NRM.add(AnalysisSchema);

NRM.virtual("analysistype").get(function () {
return "nrm";
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/prime.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var mongoose = require("mongoose"),
Msa = require(__dirname + "/msa");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var PRIME = AnalysisSchema.extend({
var PRIME = mongoose.Schema({
analysis_type: Number,
last_status_msg: String,
results: Object,
});

PRIME.add(AnalysisSchema);

PRIME.virtual("pmid").get(function () {
return "22807683";
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/relax.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ var mongoose = require("mongoose"),
logger = require("../../lib/logger"),
helpers = require(__dirname + "/../../lib/helpers.js");

require("mongoose-schema-extend");

var AnalysisSchema = require(__dirname + "/analysis");

var Relax = AnalysisSchema.extend({
var Relax = mongoose.Schema({
tagged_nwk_tree: String,
analysis_type: Number,
original_extension: String,
last_status_msg: String,
results: Object,
});

Relax.add(AnalysisSchema);

Relax.virtual("analysistype").get(function () {
return "relax";
});
Expand Down
6 changes: 3 additions & 3 deletions app/models/slac.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ const mongoose = require("mongoose"),
path = require("path"),
helpers = require("../../lib/helpers");

require("mongoose-schema-extend");

const AnalysisSchema = require(__dirname + "/analysis");

const SLAC = AnalysisSchema.extend({
const SLAC = mongoose.Schema({
analysis_type: Number,
last_status_msg: String,
results: Object,
});

SLAC.add(AnalysisSchema);

SLAC.virtual("pmid").get(function () {
return "22807683";
});
Expand Down
1 change: 1 addition & 0 deletions app/routes/absrel.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ exports.uploadFile = function (req, res) {
absrel.save(function (err, absrel_result) {
if (err) {
logger.error("absrel save failed");
console.log(err);
res.json(500, { error: err });
return;
}
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
"main-bower-files": "^2.9.0",
"moment": "^2.29.4",
"mongodb": "^2.0.0",
"mongoose": "^4.11.7",
"mongoose-schema-extend": "^0.1.0",
"mongoose": "5",
"morgan": "x.x.x",
"multer": "^1.3.0",
"nodemailer": "^1.0.0",
Expand Down
Loading

0 comments on commit 4977e66

Please sign in to comment.