Skip to content

Commit 2151e6c

Browse files
feat: typology-thresholds
1 parent 9146a85 commit 2151e6c

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/services/helper.service.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,23 @@ export const handleChannels = async (
4747

4848
const jchannelResults = await databaseManager.getMemberValues(cacheKey);
4949
spanDBMembers?.end();
50-
const channelResults: ChannelResult[] = jchannelResults.map((jchannelResult) => jchannelResult.channelResult as ChannelResult);
5150

51+
const channelResults: ChannelResult[] = jchannelResults.map((jchannelResult) => jchannelResult.channelResult as ChannelResult);
52+
const currentConfiguration = transactionConfiguration[0][0] as TransactionConfiguration;
5253
let review = false;
5354

54-
const currentConfiguration = transactionConfiguration[0][0] as TransactionConfiguration;
5555
for (const configuredChannel of currentConfiguration.channels) {
5656
if (configuredChannel) {
5757
const channelRes = channelResults.find((c) => c.id === configuredChannel.id && c.cfg === configuredChannel.cfg);
58+
const channelCount = channelResults.findIndex((c) => c.id === configuredChannel.id && c.cfg === configuredChannel.cfg);
5859
for (const typology of configuredChannel.typologies) {
5960
const typologyResult = channelRes?.typologyResult.find((t) => t.id === typology.id && t.cfg === typology.cfg);
6061
if (!typologyResult) continue;
61-
62-
if (typologyResult.result >= typology.threshold) {
63-
review = true;
64-
typologyResult.review = true;
65-
}
66-
typologyResult.threshold = typology.threshold;
62+
review = typologyResult.review!;
6763
}
6864

6965
if (channelRes) {
70-
channelRes.status = review ? 'ALRT' : 'NALT';
66+
channelResults[channelCount].status = review ? 'ALRT' : 'NALT';
7167
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
7268
loggerService.log(`Transaction: ${transactionID} has status: ${channelRes.status}`);
7369
}

src/services/logic.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const handleExecute = async (rawTransaction: any): Promise<any> => {
4646
const channelResults: ChannelResult[] = await handleTypologies(transaction, channel, networkMap, typologyResult, metaData);
4747

4848
if (channelResults.length > 0 && channelResults.length === networkMap.messages[0].channels.length) {
49-
if (channelResults.some((c: ChannelResult) => c.status === 'Review')) review = true;
49+
if (channelResults.some((c: ChannelResult) => c.status === 'ALRT')) review = true;
5050
toReturn.id = networkMap.messages[0].id;
5151
toReturn.cfg = networkMap.messages[0].cfg;
5252
toReturn.channelResult = channelResults;

0 commit comments

Comments
 (0)