Ver Fonte

minor fixes

Enzo há 1 ano atrás
pai
commit
91f1aedd4b
1 ficheiros alterados com 14 adições e 20 exclusões
  1. 14 20
      services/message-auditor.service.ts

+ 14 - 20
services/message-auditor.service.ts

@@ -29,7 +29,7 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
             next: obsTrigger => {
                 console.log(obsTrigger.message)// just checking the message
 
-                let missingMsg : Observable<MessageLog> = this.synchronize()
+                let missingMsg: Observable<MessageLog> = this.synchronize()
                 missingMsg.subscribe({
                     next: element => {
                         msg.next(element)
@@ -44,25 +44,19 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
 
     /* This is where the 'synching' operation takes place. */
     private synchronize(): Subject<MessageLog> {
-        let subjectOutput : Subject<MessageLog> = new Subject()
+        let subjectOutput: Subject<MessageLog> = new Subject()
         // Acquire the data from both location and return them as an array respectively.
         this.acquireData().then((data: { arr1: MessageLog[], arr2: MessageLog[] }) => {
-            // Check for length first. If the length matches, then there's no need to sync
-            // since there's nothing missing.
-            if (data.arr1.length === data.arr2.length) {
-                console.log(`No synchronization needed`)
-            } else {
-                // In the case where there are differences in the array length, then extensive comparison
-                // will be carried out to filter out the differences. Differences are the missing data.
-                this.checkArrayDifferences(data).then((data: MessageLog[]) => {
-                    data.forEach(msgElement => {
-                        let refined = JSON.parse(JSON.stringify(msgElement))
-                        // Once the missing data has been weeded out, it is then passed into the Subject 
-                        // to be returned for the subscribe method.
-                        subjectOutput.next(refined)
-                    })
+            // In the case where there are differences in the array length, then extensive comparison
+            // will be carried out to filter out the differences. Differences are the missing data.
+            this.checkArrayDifferences(data).then((data: MessageLog[]) => {
+                data.forEach(msgElement => {
+                    let refined = JSON.parse(JSON.stringify(msgElement))
+                    // Once the missing data has been weeded out, it is then passed into the Subject 
+                    // to be returned for the subscribe method.`
+                    subjectOutput.next(refined)
                 })
-            }
+            })
         }).catch((e) => console.error(e))
         return subjectOutput
     }
@@ -78,15 +72,15 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
                 arr1: [],
                 arr2: []
             }
-            let set1 : MessageLog[]
-            let set2 : MessageLog[]
+            let set1: MessageLog[]
+            let set2: MessageLog[]
 
             // Initiate the source to find the location of the targeted data to be synched.
             this.sourceSrc.init(this.settings.incomingSource).then(() => {
                 this.targetSrc.init(this.settings.target).then(() => {
                     // Filter also carries out the query aspect of the operation, allowing it to acquire all the relevant data.
                     this.sourceSrc.filter({ msgTag: this.settings.incomingSource.tags[0] }).then((data: MessageLog[]) => {
-                        set1 = data 
+                        set1 = data
                     }).then(() => {
                         this.targetSrc.filter({ msgTag: this.settings.target.tags[0] }).then((data: MessageLog[]) => {
                             set2 = data