1
0
Fork 0

[DEV-6710] [WIP] Save environment on quote save

master
Austin Schaffer 2019-12-18 13:10:32 -05:00 committed by Schaffer, Austin
parent e819edc53b
commit 1cb47d4acf
6 changed files with 26 additions and 9 deletions

View File

@ -82,7 +82,10 @@ let process_interval: NodeJS.Timer;
let dao: MongoDeltaDao;
getMongoCollection( db, db_conf )
.then( ( conn: MongoCollection ) => { return new MongoDeltaDao( conn ); } )
.then( ( conn: MongoCollection ) =>
{
return new MongoDeltaDao( conn, env );
} )
.then( ( mongoDao: MongoDeltaDao ) => { dao = mongoDao; } )
.then( _ => amqp_connection.connect() )
.then( _ =>

View File

@ -528,7 +528,12 @@ module.exports = AbstractClass( 'Daemon',
{
if ( router.init instanceof Function )
{
router.init( _self._debugLog, _self._encService, _self._conf );
router.init(
_self._debugLog,
_self._encService,
_self._conf,
process.env.NODE_ENV
);
}
});
},

View File

@ -124,10 +124,10 @@ exports.skey = "";
exports.post_rate_publish = {};
exports.init = function( logger, enc_service, conf )
exports.init = function( logger, enc_service, conf, env )
{
var db = _createDB( logger );
const dao = new MongoServerDao( db );
const dao = new MongoServerDao( db, env );
db.collection( 'quotes', function( err, collection )
{
@ -178,6 +178,8 @@ exports.init = function( logger, enc_service, conf )
} );
}
// TODO: Remove this and use the new MongoFactory.ts
function _createDB( logger )
{
if(process.env.LIZA_MONGODB_HA==1)

View File

@ -64,7 +64,8 @@ export class MongoServerDao extends EventEmitter implements ServerDao
* @param {Mongo.Db} db mongo database connection
*/
constructor(
private readonly _db: MongoDb
private readonly _db: MongoDb,
private readonly _env: string,
)
{
super();
@ -307,6 +308,7 @@ export class MongoServerDao extends EventEmitter implements ServerDao
// some data should always be saved because the quote will be created if
// it does not yet exist
save_data.id = id;
save_data.env = this._env;
save_data.pver = quote.getProgramVersion();
save_data.importDirty = 1;
save_data.published = false;

View File

@ -59,6 +59,7 @@ export class MongoDeltaDao implements DeltaDao
*/
constructor(
private readonly _collection: MongoCollection,
private readonly _env: string,
) {}
@ -75,6 +76,7 @@ export class MongoDeltaDao implements DeltaDao
{
published: false,
deltaError: { $ne: true },
env: this._env,
},
{ fields: this.RESULT_FIELDS },
( e, cursor ) =>
@ -243,7 +245,10 @@ export class MongoDeltaDao implements DeltaDao
return new Promise( ( resolve, reject ) =>
{
this._collection.find(
{ deltaError: true },
{
deltaError: true,
env: this._env,
},
{},
( e, cursor ) =>
{

View File

@ -64,7 +64,7 @@ describe( 'MongoServerDao', () =>
done();
}
) );
), 'test' );
sut.init( () =>
sut.saveQuote( quote, () => {}, () => {} )
@ -95,7 +95,7 @@ describe( 'MongoServerDao', () =>
done();
}
) );
), 'test' );
sut.init( () =>
sut.saveQuote(
@ -122,7 +122,7 @@ describe( 'MongoServerDao', () =>
done();
}
) );
), 'test' );
sut.init( () =>
sut.saveQuote(