Quellcode durchsuchen

Added CheckAudit option.

FAMBL vor 1 Jahr
Ursprung
Commit
073a295206
5 geänderte Dateien mit 28 neuen und 10 gelöschten Zeilen
  1. 1 0
      .env
  2. 10 7
      package-lock.json
  3. 1 1
      package.json
  4. 15 1
      services/message-auditor.service.ts
  5. 1 1
      test/test5.ts

+ 1 - 0
.env

@@ -0,0 +1 @@
+CheckAudit = Yes

+ 10 - 7
package-lock.json

@@ -10,7 +10,7 @@
       "license": "ISC",
       "dependencies": {
         "@types/node": "^18.11.18",
-        "dotenv": "^16.0.3",
+        "dotenv": "^16.3.1",
         "jsonschema": "^1.4.1",
         "lodash": "^4.17.21",
         "mongoose": "^6.9.0",
@@ -1193,11 +1193,14 @@
       "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
     },
     "node_modules/dotenv": {
-      "version": "16.0.3",
-      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
-      "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
+      "version": "16.3.1",
+      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
+      "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
       "engines": {
         "node": ">=12"
+      },
+      "funding": {
+        "url": "https://github.com/motdotla/dotenv?sponsor=1"
       }
     },
     "node_modules/fast-xml-parser": {
@@ -2446,9 +2449,9 @@
       }
     },
     "dotenv": {
-      "version": "16.0.3",
-      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
-      "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="
+      "version": "16.3.1",
+      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
+      "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ=="
     },
     "fast-xml-parser": {
       "version": "4.0.11",

+ 1 - 1
package.json

@@ -26,7 +26,7 @@
   "license": "ISC",
   "dependencies": {
     "@types/node": "^18.11.18",
-    "dotenv": "^16.0.3",
+    "dotenv": "^16.3.1",
     "jsonschema": "^1.4.1",
     "lodash": "^4.17.21",
     "mongoose": "^6.9.0",

+ 15 - 1
services/message-auditor.service.ts

@@ -1,9 +1,10 @@
 import { map, Observable, of, Subject } from "rxjs";
 import { ErrorTrigger, MessageAuditorServiceInterface, MessageSynchronisationServiceSetting } from "../type/datatype";
 import { MessageLog } from "../dependencies/log/type/datatype";
-import { _ } from 'lodash'
+import * as _ from 'lodash'
 import { LoggingService } from "../dependencies/log/interface/export";
 import { BaseMessage } from "../dependencies/log/dependencies/msgutil/interface/export";
+require('dotenv').config();
 
 export class MessageAuditorService implements MessageAuditorServiceInterface {
     private settings: MessageSynchronisationServiceSetting
@@ -89,7 +90,20 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
         this.acquireData().then((data: { arr1: MessageLog[], arr2: MessageLog[] }) => {
             // In the case where there are differences in the array length, then extensive comparison
             // will be carried out to filters out the differences. Differences are the missing data.
+
+            if(process.env.CheckAudit)
+            {
+                console.log("Record set 1: ", _.keys(_.countBy(data.arr1,function(data:MessageLog){return data.appData['msgId']})).length);
+                console.log("Record set 2: ", _.keys(_.countBy(data.arr2,function(data:MessageLog){return data.appData['msgId']})).length);
+            }
+
             this.checkArrayDifferences(data).then((data: MessageLog[]) => {
+
+                if(process.env.CheckAudit)
+                {
+                    console.log("Difference: ",data.length);
+                }
+
                 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 

+ 1 - 1
test/test5.ts

@@ -6,7 +6,7 @@ import { Observable, Subject, take } from "rxjs"
 import { MessageAuditorService } from "../services/message-auditor.service"
 import { MessageAuditorServiceInterface, MessageSynchronisationServiceSetting } from "../type/datatype"
 import { LogSetting, MessageLog } from "../dependencies/log/type/datatype"
-import { _ } from 'lodash'
+import * as _ from 'lodash'
 import { StreamingService } from "./test-streamOBS"
 import { LoggingService } from "../dependencies/log/services/logging-service"
 import { ResponseMessage } from "../dependencies/log/dependencies/msgutil/interface/export"