Skip to content

Commit 834a2c1

Browse files
committed
fix: change of file
after nats branch removes the execute file I had to change where I calculate the elapsed time
1 parent 412818e commit 834a2c1

File tree

2 files changed

+16
-107
lines changed

2 files changed

+16
-107
lines changed

src/controllers/execute.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.

src/services/logic.service.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
12
/* eslint-disable @typescript-eslint/no-explicit-any */
23
import apm from 'elastic-apm-node';
34
import { ChannelResult } from '../classes/channel-result';
@@ -9,15 +10,25 @@ import { CMSRequest } from '../classes/cms-request';
910
import { Alert } from '../classes/alert';
1011
import { TADPResult } from '../classes/tadp-result';
1112

13+
const calculateDuration = (startHrTime: Array<number>, endHrTime: Array<number>): number => {
14+
return (endHrTime[0] - startHrTime[0]) * 1000 + (endHrTime[1] - startHrTime[1]) / 1000000;
15+
};
16+
1217
export const handleExecute = async (rawTransaction: any): Promise<any> => {
1318
try {
19+
const startHrTime = process.hrtime();
1420
// Get the request body and parse it to variables
1521
const transaction = rawTransaction.transaction;
1622
const networkMap = rawTransaction.networkMap as NetworkMap;
1723
const channelResult = rawTransaction.channelResult as ChannelResult;
1824

1925
// Send every channel request to the service function
20-
const toReturn: TADPResult = { id: '', cfg: '', channelResult: [] };
26+
const toReturn: TADPResult = {
27+
id: '',
28+
cfg: '',
29+
channelResult: [],
30+
prcgTm: 0,
31+
};
2132

2233
const message = networkMap.messages.find((tran) => tran.txTp === transaction.TxTp);
2334

@@ -29,10 +40,12 @@ export const handleExecute = async (rawTransaction: any): Promise<any> => {
2940

3041
if (channelResults.some((c) => c.status === 'Review')) review = true;
3142
toReturn.channelResult = channelResults;
32-
43+
toReturn.prcgTm = calculateDuration(startHrTime, process.hrtime());
3344
const alert = new Alert();
3445
alert.tadpResult = toReturn;
3546
alert.status = review === true ? 'ALRT' : 'NALT';
47+
alert.prcgTmCRSP = rawTransaction.prcgTmCRSP;
48+
alert.prcgTmDP = rawTransaction.prcgTmDP;
3649

3750
const result: CMSRequest = {
3851
message: `Successfully completed ${channelResults.length} channels`,
@@ -62,6 +75,7 @@ export const handleChannels = async (
6275
channelResult: ChannelResult,
6376
): Promise<ChannelResult[]> => {
6477
const span = apm.startSpan('handleChannels');
78+
6579
try {
6680
const transactionType = Object.keys(transaction).find((k) => k !== 'TxTp') ?? '';
6781
const transactionID = transaction[transactionType].GrpHdr.MsgId;

0 commit comments

Comments
 (0)