Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/delta-processor.ts5
-rw-r--r--src/server/daemon/Daemon.js7
-rw-r--r--src/server/daemon/controller.js6
-rw-r--r--src/server/db/MongoServerDao.ts4
-rw-r--r--src/system/db/MongoDeltaDao.ts7
-rw-r--r--test/server/db/MongoServerDaoTest.ts6
6 files changed, 26 insertions, 9 deletions
diff --git a/bin/delta-processor.ts b/bin/delta-processor.ts
index e77dd6b..9517d5b 100644
--- a/bin/delta-processor.ts
+++ b/bin/delta-processor.ts
@@ -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( _ =>
diff --git a/src/server/daemon/Daemon.js b/src/server/daemon/Daemon.js
index 15acc31..c3511f9 100644
--- a/src/server/daemon/Daemon.js
+++ b/src/server/daemon/Daemon.js
@@ -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
+ );
}
});
},
diff --git a/src/server/daemon/controller.js b/src/server/daemon/controller.js
index 116ed39..5619c05 100644
--- a/src/server/daemon/controller.js
+++ b/src/server/daemon/controller.js
@@ -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)
diff --git a/src/server/db/MongoServerDao.ts b/src/server/db/MongoServerDao.ts
index 3f8128c..841da60 100644
--- a/src/server/db/MongoServerDao.ts
+++ b/src/server/db/MongoServerDao.ts
@@ -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;
diff --git a/src/system/db/MongoDeltaDao.ts b/src/system/db/MongoDeltaDao.ts
index b01ddc7..cd62a0f 100644
--- a/src/system/db/MongoDeltaDao.ts
+++ b/src/system/db/MongoDeltaDao.ts
@@ -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 ) =>
{
diff --git a/test/server/db/MongoServerDaoTest.ts b/test/server/db/MongoServerDaoTest.ts
index 58e6ab9..fe351d8 100644
--- a/test/server/db/MongoServerDaoTest.ts
+++ b/test/server/db/MongoServerDaoTest.ts
@@ -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(