|
@@ -4,7 +4,6 @@ import { ErrorTrigger, MessageAuditorServiceInterface, MessageSynchronisationSer
|
|
import { LoggingService } from "../dependencies/log/src/export";
|
|
import { LoggingService } from "../dependencies/log/src/export";
|
|
import { MessageLog } from "../dependencies/log/src/type/interface";
|
|
import { MessageLog } from "../dependencies/log/src/type/interface";
|
|
import { BaseMessage } from "../dependencies/log/src/dependencies/msgutil/interface/export";
|
|
import { BaseMessage } from "../dependencies/log/src/dependencies/msgutil/interface/export";
|
|
-let processedMsgIds = new Set();
|
|
|
|
require('dotenv').config();
|
|
require('dotenv').config();
|
|
|
|
|
|
export class MessageAuditorService implements MessageAuditorServiceInterface {
|
|
export class MessageAuditorService implements MessageAuditorServiceInterface {
|
|
@@ -52,7 +51,7 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
|
|
|
|
|
|
/* ________________ Private Functions _________________ */
|
|
/* ________________ Private Functions _________________ */
|
|
// Filtering functions to filters out messages
|
|
// Filtering functions to filters out messages
|
|
- private filterData(filters: any, message: MessageLog): boolean {
|
|
|
|
|
|
+ private filterData(message: MessageLog, filters?: any): boolean {
|
|
let response: boolean = true //Just using this like a statemanagement
|
|
let response: boolean = true //Just using this like a statemanagement
|
|
let payload: BaseMessage = JSON.parse(message.appData.msgPayload as string) // Extract the payload from the messageLog first
|
|
let payload: BaseMessage = JSON.parse(message.appData.msgPayload as string) // Extract the payload from the messageLog first
|
|
this.checkIfIsInPayloadDataFormat(payload) // Convert stringified nested payload if there's any
|
|
this.checkIfIsInPayloadDataFormat(payload) // Convert stringified nested payload if there's any
|
|
@@ -91,25 +90,22 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
|
|
this.acquireData().then((data: { arr1: MessageLog[], arr2: MessageLog[] }) => {
|
|
this.acquireData().then((data: { arr1: MessageLog[], arr2: MessageLog[] }) => {
|
|
// In the case where there are differences in the array length, then extensive comparison
|
|
// 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.
|
|
// 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);
|
|
|
|
|
|
+ console.log(`Checking Audit ${process.env.CheckAudit}`)
|
|
|
|
+ if (process.env.CheckAudit == `Yes`) {
|
|
|
|
+ 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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- if(process.env.CheckAudit)
|
|
|
|
- {
|
|
|
|
- console.log("[CheckAudit] Record set 1: ", _.keys(_.countBy(data.arr1,function(data:MessageLog){return data.appData['msgId']})).length);
|
|
|
|
- console.log("[CheckAudit] Record set 2: ", _.keys(_.countBy(data.arr2,function(data:MessageLog){return data.appData['msgId']})).length);
|
|
|
|
|
|
+ if (process.env.CheckAudit == `Yes`) {
|
|
|
|
+ console.log("[CheckAudit] Record set 1: ", _.keys(_.countBy(data.arr1, function (data: MessageLog) { return data.appData['msgId'] })).length);
|
|
|
|
+ console.log("[CheckAudit] Record set 2: ", _.keys(_.countBy(data.arr2, function (data: MessageLog) { return data.appData['msgId'] })).length);
|
|
}
|
|
}
|
|
|
|
|
|
this.checkArrayDifferences(data).then((data: MessageLog[]) => {
|
|
this.checkArrayDifferences(data).then((data: MessageLog[]) => {
|
|
|
|
|
|
- if(process.env.CheckAudit)
|
|
|
|
- {
|
|
|
|
- console.log("Difference: ",data.length);
|
|
|
|
|
|
+ if (process.env.CheckAudit) {
|
|
|
|
+ console.log("Difference: ", data.length);
|
|
}
|
|
}
|
|
|
|
|
|
data.forEach(msgElement => {
|
|
data.forEach(msgElement => {
|
|
@@ -140,14 +136,15 @@ export class MessageAuditorService implements MessageAuditorServiceInterface {
|
|
// Filter also carries out the query aspect of the operation, allowing it to acquire all the relevant data.
|
|
// 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[]) => {
|
|
this.sourceSrc.filter({ msgTag: this.settings.incomingSource.tags[0] }).then((data: MessageLog[]) => {
|
|
data.forEach((message: MessageLog) => {
|
|
data.forEach((message: MessageLog) => {
|
|
- if (this.filterData(this.settings.filters, message)) set1.push(message)
|
|
|
|
|
|
+ if (this.filterData(message, this.settings.filters)) set1.push(message)
|
|
})
|
|
})
|
|
}).catch((err) => {
|
|
}).catch((err) => {
|
|
console.error(err.message)
|
|
console.error(err.message)
|
|
}).then(() => {
|
|
}).then(() => {
|
|
|
|
+ console.log(set1.length)
|
|
this.targetSrc.filter({ msgTag: this.settings.target.tags[0] }).then((data: MessageLog[]) => {
|
|
this.targetSrc.filter({ msgTag: this.settings.target.tags[0] }).then((data: MessageLog[]) => {
|
|
data.forEach(message => {
|
|
data.forEach(message => {
|
|
- if (this.filterData(this.settings.filters, message)) set2.push(message)
|
|
|
|
|
|
+ if (this.filterData(message, this.settings.filters)) set2.push(message)
|
|
})
|
|
})
|
|
allSets.arr1 = set1
|
|
allSets.arr1 = set1
|
|
allSets.arr2 = set2
|
|
allSets.arr2 = set2
|