Bläddra i källkod

revert some changes

Enzo 1 år sedan
förälder
incheckning
33e6b0ccb4
3 ändrade filer med 15 tillägg och 10 borttagningar
  1. 1 1
      dependencies/log
  2. 1 1
      package.json
  3. 13 8
      test/test4.ts

+ 1 - 1
dependencies/log

@@ -1 +1 @@
-Subproject commit 684420881d1ff3742eb42f347451baef119ac529
+Subproject commit 4c1fd6ea154499e9045cb8e2480ee3ff69a3f326

+ 1 - 1
package.json

@@ -14,7 +14,7 @@
     "start3a": "node test/test3a.js",
     "start3b": "node test/test3b.js",
     "start3c": "node test/test3c.js",
-    "start4": "node test/test4a.js",
+    "start4": "node test/test4.js",
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "repository": {

+ 13 - 8
test/test4.ts

@@ -128,8 +128,8 @@ setTimeout(() => {
 countdown()
 
 // Convert all the existing cdms into message log
-convertDataInMongo('mongodb://192.168.100.59:27017/primary')
-convertDataInMongo('mongodb+srv://testDB:h1nt1OyXw6QeUnzS@cluster0.29sklte.mongodb.net/secondary')
+convertDataInMongo(primary_storage.customSetting.url)
+convertDataInMongo(secondary_storage.customSetting.url)
 
 // These declaration are for the secondary to log the converted missing data back in it's own collection at their corresponding servers
 const dbConnection = mongoose.createConnection("mongodb+srv://testDB:h1nt1OyXw6QeUnzS@cluster0.29sklte.mongodb.net/secondary")
@@ -152,7 +152,6 @@ function convertDataInMongo(url: string) {
     let convertService = new LoggingService()
     let dbConnection = mongoose.createConnection(url)
     let dataModel = dbConnection.model('genericdata', fingerPrintSchema)
-    let messages = dbConnection.model('message', messageSchema)
 
     // Once the data is queried, it will be streamed into the data Subject declared earlier
     dataModel.find().then((res) => {
@@ -166,16 +165,22 @@ function convertDataInMongo(url: string) {
     // This is where the transformation happens. The logic is written on the logging service side.
     // Once that is done, the transformed data will be saved again bacn in the mongo database in a different databse/collection
     data.subscribe((element) => {
-        let res = convertService.convertCDMStoMessageLog(element, settings.incomingSource.tags)
-        console.log(`Converting fingerprint .... ${res.appData.msgId}`)
-        messages.create(res)
+        convertService.convertCDMStoMessageLog(element, settings.incomingSource.tags).then((result: MessageLog) => {
+            console.log(`Converting fingerprint .... ${result.appData.msgId}`)
+            primary.next(result)
+        }).catch((err) => {
+            console.error(err.message)
+        });
     })
 }
 
 // TO be used by the secondary Subject to convert the message log it receives to complete the synchronization process.
 function convertMessageLogToCDMS(args: MessageLog) {
-    let converted = secondary_log.convertMessageLogtoCDMS(args)
-    dataModel.create(converted)
+    secondary_log.convertMessageLogtoCDMS(args).then((result) => {
+        dataModel.create(result)
+    }).catch((err) => {
+        console.error(err.message)
+    });
 }