tango-app-api-audit 3.5.55 → 3.5.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
mapCustomer,
|
|
52
52
|
mapEmployee,
|
|
53
53
|
mapJunk,
|
|
54
|
+
openSearchLog,
|
|
54
55
|
splitB20000,
|
|
55
56
|
splitE0,
|
|
56
57
|
splitG20000,
|
|
@@ -148,7 +149,7 @@ export async function auditStoreList( req, res ) {
|
|
|
148
149
|
const err = error.message || 'Internal Server Error';
|
|
149
150
|
logger.error( {
|
|
150
151
|
error: error,
|
|
151
|
-
|
|
152
|
+
message: req.body,
|
|
152
153
|
function: 'auditStoreList',
|
|
153
154
|
} );
|
|
154
155
|
return res.sendError( err, 500 );
|
|
@@ -191,7 +192,7 @@ export async function auditUserList( req, res ) {
|
|
|
191
192
|
const err = error.message || 'Internal Server Error';
|
|
192
193
|
logger.error( {
|
|
193
194
|
error: error,
|
|
194
|
-
|
|
195
|
+
message: req.query,
|
|
195
196
|
function: 'auditUserList',
|
|
196
197
|
} );
|
|
197
198
|
return res.sendError( err, 500 );
|
|
@@ -234,9 +235,9 @@ export async function getAuditFile( req, res ) {
|
|
|
234
235
|
];
|
|
235
236
|
|
|
236
237
|
const userDetails = await aggregateUserAudit( userQuery );
|
|
237
|
-
let
|
|
238
|
+
let insertQuery = null;
|
|
238
239
|
if ( userDetails && userDetails.length > 0 ) {
|
|
239
|
-
|
|
240
|
+
insertQuery = [
|
|
240
241
|
{
|
|
241
242
|
$match: {
|
|
242
243
|
$and: [
|
|
@@ -255,7 +256,7 @@ export async function getAuditFile( req, res ) {
|
|
|
255
256
|
},
|
|
256
257
|
];
|
|
257
258
|
}
|
|
258
|
-
const auditInsertData =
|
|
259
|
+
const auditInsertData = insertQuery? await aggregateAuditStoreData( insertQuery ): null;
|
|
259
260
|
const auditStatus = userDetails && userDetails.length > 0 ? userDetails[0].auditStatus : null;
|
|
260
261
|
switch ( auditStatus ) {
|
|
261
262
|
case null:
|
|
@@ -273,6 +274,23 @@ export async function getAuditFile( req, res ) {
|
|
|
273
274
|
];
|
|
274
275
|
const userAssign = await aggregateAssignAudit( query );
|
|
275
276
|
if ( userAssign.length > 0 ) {
|
|
277
|
+
// openSearch log
|
|
278
|
+
const id = `${req.query.moduleType}_${req.query.queueName}_getAuditFile_Info_${req?.user?.userEmail}_${Date.now()}`;
|
|
279
|
+
let temp = inputData;
|
|
280
|
+
temp.logType='audit';
|
|
281
|
+
temp.logSubType='get-audit-file';
|
|
282
|
+
temp.functionName='audit-controller-getAuditFile';
|
|
283
|
+
temp.messageType = 'log';
|
|
284
|
+
temp.message ='Hit in user assign';
|
|
285
|
+
temp.storeId =userAssign?.[0]?.storeId;
|
|
286
|
+
temp.fileDate =userAssign?.[0]?.fileDate;
|
|
287
|
+
temp.totalCount =userAssign?.[0]?.fileCount;
|
|
288
|
+
temp.zoneName =userAssign?.[0]?.zoneName;
|
|
289
|
+
temp.indexName= auditInsertData?.[0]?.index_name;
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
await openSearchLog( temp, req.user, id );
|
|
293
|
+
/** ******* end *******/
|
|
276
294
|
logger.info( 'Hit in user assign', { inputData } );
|
|
277
295
|
userAssign[0].auditType == 'Audit' ?
|
|
278
296
|
( msg = {
|
|
@@ -300,6 +318,18 @@ export async function getAuditFile( req, res ) {
|
|
|
300
318
|
} );
|
|
301
319
|
} else {
|
|
302
320
|
logger.info( 'Hit in new file', { inputData } );
|
|
321
|
+
/* openSearch logs start*/
|
|
322
|
+
|
|
323
|
+
// declare basic details
|
|
324
|
+
const id = `${req.query.moduleType}_${req.query.queueName}_getAuditFile_Info_${req?.user?.userEmail}_${Date.now()}`;
|
|
325
|
+
let temp = inputData;
|
|
326
|
+
temp.logType='audit';
|
|
327
|
+
temp.logSubType='get-audit-file';
|
|
328
|
+
temp.functionName='audit-controller-getAuditFile';
|
|
329
|
+
temp.messageType = 'log';
|
|
330
|
+
temp.message ='Hit in new file';
|
|
331
|
+
|
|
332
|
+
|
|
303
333
|
const consumer = await sqsReceive( inputData.queueName );
|
|
304
334
|
if ( !consumer ) {
|
|
305
335
|
logger.error( {
|
|
@@ -309,12 +339,37 @@ export async function getAuditFile( req, res ) {
|
|
|
309
339
|
} );
|
|
310
340
|
return res.sendError( `${inputData.queueName} is Empty`, 204 );
|
|
311
341
|
}
|
|
342
|
+
|
|
312
343
|
msg = JSON.parse( consumer );
|
|
344
|
+
|
|
345
|
+
// declare consumer data
|
|
346
|
+
temp.storeId =msg?.store_id;
|
|
347
|
+
temp.fileDate =msg?.curr_date;
|
|
348
|
+
temp.totalCount =msg?.total_count;
|
|
349
|
+
temp.zoneName =msg?.zone_id;
|
|
350
|
+
temp.indexName= msg?.index_name;
|
|
351
|
+
await openSearchLog( temp, req.user, id );
|
|
352
|
+
/* openSearch logs end */
|
|
313
353
|
}
|
|
314
354
|
break;
|
|
315
355
|
|
|
316
356
|
case 'drafted':
|
|
317
357
|
logger.info( 'userDetails drafted', { inputData } );
|
|
358
|
+
/* openSearch logs start */
|
|
359
|
+
const id = `${req.query.moduleType}_${req.query.queueName}_getAuditFile_Info_${req?.user?.userEmail}_${Date.now()}`;
|
|
360
|
+
let temp = inputData;
|
|
361
|
+
temp.logType='audit';
|
|
362
|
+
temp.logSubType='get-audit-file';
|
|
363
|
+
temp.functionName='audit-controller-getAuditFile';
|
|
364
|
+
temp.messageType = 'log';
|
|
365
|
+
temp.message ='Hit in drafted file';
|
|
366
|
+
msg = JSON.parse( consumer );
|
|
367
|
+
temp.storeId =userDetails[0].storeId;
|
|
368
|
+
temp.fileDate =userDetails[0].fileDate;
|
|
369
|
+
temp.totalCount =userDetails[0].beforeCount;
|
|
370
|
+
temp.zoneName =userDetails[0].zoneName;
|
|
371
|
+
await openSearchLog( temp, req.user, id );
|
|
372
|
+
/* openSearch logs end */
|
|
318
373
|
const log = await findOneAuditLog(
|
|
319
374
|
{
|
|
320
375
|
userId: userDetails[0].userId,
|
|
@@ -420,16 +475,32 @@ export async function getAuditFile( req, res ) {
|
|
|
420
475
|
break;
|
|
421
476
|
}
|
|
422
477
|
if ( msg.audit_type === 'ReAudit' && msg.zone_id !== 'track' ) {
|
|
478
|
+
/* openSearch logs start */
|
|
479
|
+
const id = `${req.query.moduleType}_${req.query.queueName}_getAuditFile_Info_${req?.user?.userEmail}_${Date.now()}`;
|
|
480
|
+
let temp = inputData;
|
|
481
|
+
temp.logType='audit';
|
|
482
|
+
temp.logSubType='get-audit-file';
|
|
483
|
+
temp.functionName='audit-controller-getAuditFile';
|
|
484
|
+
temp.messageType = 'log';
|
|
485
|
+
temp.message ='Hit in user ReAudit';
|
|
486
|
+
temp.storeId =msg?.store_id;
|
|
487
|
+
temp.fileDate =msg?.curr_date;
|
|
488
|
+
temp.totalCount =msg?.total_count;
|
|
489
|
+
temp.zoneName =msg?.zone_id;
|
|
490
|
+
temp.auditType = msg?.audit_type;
|
|
491
|
+
temp.indexName= msg?.index_name;
|
|
492
|
+
await openSearchLog( temp, req.user, id );
|
|
493
|
+
/* openSearch logs end */
|
|
423
494
|
logger.info( 'Hit in user ReAudit', { inputData } );
|
|
424
|
-
let
|
|
495
|
+
let reAuditInsert = {};
|
|
425
496
|
const [ filterData, auditImage ] = await Promise.all( [
|
|
426
|
-
getFilterData( msg ),
|
|
427
|
-
getAuditImage( msg ),
|
|
497
|
+
getFilterData( msg, req.user ),
|
|
498
|
+
getAuditImage( msg, req.user ),
|
|
428
499
|
] );
|
|
429
500
|
if ( filterData.statusCode == 404 || auditImage.statusCode == 404 ) {
|
|
430
501
|
return res.sendError( 'No Data found', 204 );
|
|
431
502
|
}
|
|
432
|
-
const
|
|
503
|
+
const reAuditImg = await getReAuditImg( filterData, auditImage );
|
|
433
504
|
if ( userDetails.length === 0 ) {
|
|
434
505
|
const [ day, month, year ] = msg.curr_date.split( '-' );
|
|
435
506
|
const temp = `${year}-${month}-${day}`;
|
|
@@ -444,7 +515,7 @@ export async function getAuditFile( req, res ) {
|
|
|
444
515
|
auditType: msg.audit_type || 'ReAudit',
|
|
445
516
|
fileDate: msg.curr_date,
|
|
446
517
|
queueName: inputData.queueName,
|
|
447
|
-
beforeCount:
|
|
518
|
+
beforeCount: reAuditImg.length,
|
|
448
519
|
auditStatus: 'inprogress',
|
|
449
520
|
fileDateISO: start,
|
|
450
521
|
timeSpent: 0,
|
|
@@ -464,11 +535,11 @@ export async function getAuditFile( req, res ) {
|
|
|
464
535
|
status: 'inprogress',
|
|
465
536
|
timeSpent: 0,
|
|
466
537
|
};
|
|
467
|
-
|
|
538
|
+
reAuditInsert = await createUserAudit( record );
|
|
468
539
|
|
|
469
540
|
await updateOneStoreAudit( query, storeRecord );
|
|
470
541
|
} else {
|
|
471
|
-
|
|
542
|
+
reAuditInsert = userDetails[0];
|
|
472
543
|
}
|
|
473
544
|
const userdata = await findOneUser( { _id: req.user._id } );
|
|
474
545
|
if ( inputData.nextId ) {
|
|
@@ -482,7 +553,7 @@ export async function getAuditFile( req, res ) {
|
|
|
482
553
|
auditType: msg.audit_type,
|
|
483
554
|
storeId: msg.store_id,
|
|
484
555
|
clientName: inputData.queueName,
|
|
485
|
-
auditId:
|
|
556
|
+
auditId: reAuditInsert._id,
|
|
486
557
|
zoneName: msg.zone_id,
|
|
487
558
|
moduleType: inputData.moduleType,
|
|
488
559
|
beforeCount: msg.total_count,
|
|
@@ -502,8 +573,8 @@ export async function getAuditFile( req, res ) {
|
|
|
502
573
|
};
|
|
503
574
|
const storeInfo = await findOneStore( storeQuery, storeFields );
|
|
504
575
|
return res.sendSuccess( {
|
|
505
|
-
result:
|
|
506
|
-
count:
|
|
576
|
+
result: reAuditImg,
|
|
577
|
+
count: reAuditImg.length,
|
|
507
578
|
storeId: storeInfo?.storeId,
|
|
508
579
|
storeName: storeInfo?.storeName,
|
|
509
580
|
address: storeInfo?.address || '',
|
|
@@ -512,12 +583,12 @@ export async function getAuditFile( req, res ) {
|
|
|
512
583
|
file_date: msg.curr_date,
|
|
513
584
|
type: msg.audit_type || 'ReAudit',
|
|
514
585
|
queueName: inputData.queueName,
|
|
515
|
-
auditId:
|
|
516
|
-
userId:
|
|
586
|
+
auditId: reAuditInsert._id,
|
|
587
|
+
userId: reAuditInsert.userId,
|
|
517
588
|
zoneName: msg.zone_id,
|
|
518
589
|
moduleType: inputData.moduleType,
|
|
519
590
|
},
|
|
520
|
-
isDraft:
|
|
591
|
+
isDraft: reAuditInsert.isDraft,
|
|
521
592
|
} );
|
|
522
593
|
}
|
|
523
594
|
const storeId = msg.store_id;
|
|
@@ -597,6 +668,23 @@ export async function getAuditFile( req, res ) {
|
|
|
597
668
|
|
|
598
669
|
};
|
|
599
670
|
logger.info( { fetchData: fetchData, msg: msg, inputData: inputData, type: 'debug-bucketNameIssue' } );
|
|
671
|
+
/* openSearch logs start */
|
|
672
|
+
const _id = `${req.query.moduleType}_${req.query.queueName}_getAuditFile_Info_${req?.user?.userEmail}_${Date.now()}`;
|
|
673
|
+
let temp = inputData;
|
|
674
|
+
temp.logType='audit';
|
|
675
|
+
temp.logSubType='get-audit-file';
|
|
676
|
+
temp.functionName='audit-controller-getAuditFile';
|
|
677
|
+
temp.messageType = 'log';
|
|
678
|
+
temp.message ='debug-bucketNameIssue';
|
|
679
|
+
temp.storeId =msg?.store_id;
|
|
680
|
+
temp.fileDate =msg?.curr_date;
|
|
681
|
+
temp.totalCount =msg?.total_count;
|
|
682
|
+
temp.zoneName =msg?.zone_id;
|
|
683
|
+
temp.auditType = msg?.audit_type;
|
|
684
|
+
temp.indexName= msg?.index_name;
|
|
685
|
+
temp.params = JSON.stringify( fetchData );
|
|
686
|
+
await openSearchLog( temp, req.user, _id );
|
|
687
|
+
/* openSearch logs end */
|
|
600
688
|
const list = msg.zone_id === 'track' ? inputData.nextId? await scrollResponse( inputData.nextId ):await searchOpenSearchData( msg.index_name, getQuery ): await listFileByPath( fetchData );
|
|
601
689
|
const folderPath = msg.zone_id === 'track' ? list?.body?.hits?.hits : list.data;
|
|
602
690
|
const nextQuery =msg.zone_id !== 'track' ? list.pageToken: '';
|
|
@@ -614,7 +702,7 @@ export async function getAuditFile( req, res ) {
|
|
|
614
702
|
const indexes = msg.zone_id === 'track' ? msg.audit_type === 'ReAudit'? folderPath[i]?._source?.outputCluster ===50000? folderPath[i]?._source?.REIDCluster:folderPath[i]?._source?.outputCluster:folderPath[i]?._source?.REIDCluster: image[0]?.split( '_' );
|
|
615
703
|
fetchData.file_path = msg.zone_id === 'track' ?folderPath[i]?._source?.personPath:folderPath[i].Key;
|
|
616
704
|
const data =msg.zone_id === 'track' ? `${url.trackInput}${folderPath[i]?._source?.personPath}` :await signedUrl( fetchData );
|
|
617
|
-
const
|
|
705
|
+
const mapImg = {
|
|
618
706
|
img_path: data,
|
|
619
707
|
img_name: msg.zone_id === 'track' ?indexes: indexes[1],
|
|
620
708
|
img_id: image[0],
|
|
@@ -627,7 +715,7 @@ export async function getAuditFile( req, res ) {
|
|
|
627
715
|
dropped: false,
|
|
628
716
|
demographic: '',
|
|
629
717
|
count: 1,
|
|
630
|
-
mappedid: [
|
|
718
|
+
mappedid: [ mapImg ],
|
|
631
719
|
} ):
|
|
632
720
|
files.push( {
|
|
633
721
|
img_path: data,
|
|
@@ -637,7 +725,7 @@ export async function getAuditFile( req, res ) {
|
|
|
637
725
|
dropped: false,
|
|
638
726
|
demographic: '',
|
|
639
727
|
count: 1,
|
|
640
|
-
mappedid: [
|
|
728
|
+
mappedid: [ mapImg ],
|
|
641
729
|
} );
|
|
642
730
|
}
|
|
643
731
|
if ( userDetails.length === 0 ) {
|
|
@@ -701,10 +789,27 @@ export async function getAuditFile( req, res ) {
|
|
|
701
789
|
list.body._scroll_id = '';
|
|
702
790
|
insertData = userDetails[0];
|
|
703
791
|
} else {
|
|
792
|
+
/* openSearch logs start*/
|
|
793
|
+
const id = `${req.query.moduleType}_${req.query.queueName}_getAuditFile_Error_${req?.user?.userEmail}_${Date.now()}`;
|
|
794
|
+
let temp = inputData;
|
|
795
|
+
temp.logType='audit';
|
|
796
|
+
temp.logSubType='get-audit-file';
|
|
797
|
+
temp.functionName='audit-controller-getAuditFile';
|
|
798
|
+
temp.messageType = 'error';
|
|
799
|
+
temp.message ='Bucket image data not available';
|
|
800
|
+
temp.storeId =msg?.store_id;
|
|
801
|
+
temp.fileDate =msg?.curr_date;
|
|
802
|
+
temp.totalCount =msg?.total_count;
|
|
803
|
+
temp.zoneName =msg?.zone_id;
|
|
804
|
+
temp.auditType = msg?.audit_type;
|
|
805
|
+
temp.indexName= msg?.index_name;
|
|
806
|
+
temp.folderPath= folderPath;
|
|
807
|
+
await openSearchLog( temp, req.user, id );
|
|
808
|
+
/* openSearch logs end*/
|
|
704
809
|
logger.error( {
|
|
705
810
|
error: { folderPath: folderPath, nextQuery: nextQuery },
|
|
706
811
|
function: 'getAuditFile',
|
|
707
|
-
message: 'Bucket image data not
|
|
812
|
+
message: 'Bucket image data not available',
|
|
708
813
|
} );
|
|
709
814
|
return res.sendError( 'Bucket is Empty', 204 );
|
|
710
815
|
}
|
|
@@ -757,6 +862,22 @@ export async function getAuditFile( req, res ) {
|
|
|
757
862
|
isDraft: insertData.isDraft,
|
|
758
863
|
} );
|
|
759
864
|
} catch ( error ) {
|
|
865
|
+
/* openSearch logs start*/
|
|
866
|
+
const id = `${req.query.moduleType}_${req.query.queueName}_getAuditFile_Error_${req?.user?.userEmail}_${Date.now()}`;
|
|
867
|
+
let temp = inputData;
|
|
868
|
+
temp.logType='audit';
|
|
869
|
+
temp.logSubType='get-audit-file';
|
|
870
|
+
temp.functionName='audit-controller-getAuditFile';
|
|
871
|
+
temp.messageType = 'error';
|
|
872
|
+
temp.message =error.message || 'Internal Server Error';
|
|
873
|
+
temp.storeId =msg?.store_id;
|
|
874
|
+
temp.fileDate =msg?.curr_date;
|
|
875
|
+
temp.totalCount =msg?.total_count;
|
|
876
|
+
temp.zoneName =msg?.zone_id;
|
|
877
|
+
temp.auditType = msg?.audit_type;
|
|
878
|
+
temp.indexName= msg?.index_name;
|
|
879
|
+
await openSearchLog( temp, req.user, id );
|
|
880
|
+
/* openSearch logs end*/
|
|
760
881
|
logger.error( {
|
|
761
882
|
error: error,
|
|
762
883
|
message: req.query,
|
|
@@ -772,7 +893,7 @@ function addUniqueFile( files, newFile ) {
|
|
|
772
893
|
}
|
|
773
894
|
}
|
|
774
895
|
|
|
775
|
-
export async function getFilterData( msg ) {
|
|
896
|
+
export async function getFilterData( msg, user ) {
|
|
776
897
|
try {
|
|
777
898
|
const bucket = JSON.parse( process.env.BUCKET );
|
|
778
899
|
const params = {
|
|
@@ -781,6 +902,23 @@ export async function getFilterData( msg ) {
|
|
|
781
902
|
};
|
|
782
903
|
const mappingFile = await getJsonFileData( params );
|
|
783
904
|
if ( mappingFile.statusCode ) {
|
|
905
|
+
/* openSearch logs start*/
|
|
906
|
+
const id = `${msg.store_id}_${msg.zone_id}_${msg.curr_date}_${bucket.masterJsonFile}_getFilterData_Error_${user?.userEmail}_${Date.now()}`;
|
|
907
|
+
let temp = msg;
|
|
908
|
+
temp.logType='audit';
|
|
909
|
+
temp.logSubType='get-audit-file';
|
|
910
|
+
temp.functionName='audit-controller-getFilterData';
|
|
911
|
+
temp.messageType = 'error';
|
|
912
|
+
temp.message ='Hit in user ReAudit-getFilterData';
|
|
913
|
+
temp.storeId =msg?.store_id;
|
|
914
|
+
temp.fileDate =msg?.curr_date;
|
|
915
|
+
temp.totalCount =msg?.total_count;
|
|
916
|
+
temp.zoneName =msg?.zone_id;
|
|
917
|
+
temp.auditType = msg?.audit_type;
|
|
918
|
+
temp.indexName= msg?.index_name;
|
|
919
|
+
temp.params = JSON.stringify( params );
|
|
920
|
+
await openSearchLog( temp, user, id );
|
|
921
|
+
/* openSearch logs end*/
|
|
784
922
|
return mappingFile;
|
|
785
923
|
} else {
|
|
786
924
|
const mappingData = await JSON.parse( mappingFile.toString( 'utf-8' ) );
|
|
@@ -796,6 +934,23 @@ export async function getFilterData( msg ) {
|
|
|
796
934
|
return finalResult;
|
|
797
935
|
}
|
|
798
936
|
} catch ( error ) {
|
|
937
|
+
/* openSearch logs start*/
|
|
938
|
+
const id = `${msg.store_id}_${msg.zone_id}_${msg.curr_date}_${bucket.masterJsonFile}_getFilterData_Error_${user?.userEmail}_${Date.now()}`;
|
|
939
|
+
let temp = msg;
|
|
940
|
+
temp.logType='audit';
|
|
941
|
+
temp.logSubType='get-audit-file';
|
|
942
|
+
temp.functionName='audit-controller-getFilterData';
|
|
943
|
+
temp.messageType = 'error';
|
|
944
|
+
temp.message =error.message ||'Internal Server Error';
|
|
945
|
+
temp.storeId =msg?.store_id;
|
|
946
|
+
temp.fileDate =msg?.curr_date;
|
|
947
|
+
temp.totalCount =msg?.total_count;
|
|
948
|
+
temp.zoneName =msg?.zone_id;
|
|
949
|
+
temp.auditType = msg?.audit_type;
|
|
950
|
+
temp.indexName= msg?.index_name;
|
|
951
|
+
temp.params = JSON.stringify( params );
|
|
952
|
+
await openSearchLog( temp, user, id );
|
|
953
|
+
/* openSearch logs end*/
|
|
799
954
|
logger.error( {
|
|
800
955
|
error: error,
|
|
801
956
|
type: 'MAPPING JSON getFilterData',
|
|
@@ -805,7 +960,7 @@ export async function getFilterData( msg ) {
|
|
|
805
960
|
}
|
|
806
961
|
}
|
|
807
962
|
|
|
808
|
-
export async function getAuditImage( msg ) {
|
|
963
|
+
export async function getAuditImage( msg, user ) {
|
|
809
964
|
try {
|
|
810
965
|
const bucket = JSON.parse( process.env.BUCKET );
|
|
811
966
|
const storeId = msg.store_id;
|
|
@@ -816,6 +971,23 @@ export async function getAuditImage( msg ) {
|
|
|
816
971
|
fetchData.filePath = `${fileDate}/${storeId}/${msg.zone_id}/`;
|
|
817
972
|
const folderPath = await listFileWithoutLimit( fetchData );
|
|
818
973
|
if ( folderPath.statusCode == 404 ) {
|
|
974
|
+
/* openSearch logs start */
|
|
975
|
+
const id = `${fileDate}_${storeId}_${msg.zone_id}_${bucket.auditInput}_getAuditImage_Error_${user?.userEmail}_${Date.now()}`;
|
|
976
|
+
let temp = msg;
|
|
977
|
+
temp.logType='audit';
|
|
978
|
+
temp.logSubType='get-audit-file';
|
|
979
|
+
temp.functionName='audit-controller-getFilterData';
|
|
980
|
+
temp.messageType = 'error';
|
|
981
|
+
temp.message =JSON.stringify( folderPath );
|
|
982
|
+
temp.storeId =msg?.store_id;
|
|
983
|
+
temp.fileDate =msg?.curr_date;
|
|
984
|
+
temp.totalCount =msg?.total_count;
|
|
985
|
+
temp.zoneName =msg?.zone_id;
|
|
986
|
+
temp.auditType = msg?.audit_type;
|
|
987
|
+
temp.indexName= msg?.index_name;
|
|
988
|
+
temp.params = JSON.stringify( fetchData );
|
|
989
|
+
await openSearchLog( temp, user, id );
|
|
990
|
+
/* openSearch logs end */
|
|
819
991
|
return folderPath;
|
|
820
992
|
}
|
|
821
993
|
const auditImages = folderPath;
|
|
@@ -829,7 +1001,7 @@ export async function getAuditImage( msg ) {
|
|
|
829
1001
|
Bucket: fetchData.Bucket,
|
|
830
1002
|
};
|
|
831
1003
|
const data = await signedUrl( params );
|
|
832
|
-
const
|
|
1004
|
+
const mapImg = {
|
|
833
1005
|
img_path: data,
|
|
834
1006
|
img_name: indexes[1],
|
|
835
1007
|
img_id: image[0],
|
|
@@ -841,19 +1013,36 @@ export async function getAuditImage( msg ) {
|
|
|
841
1013
|
selected: false,
|
|
842
1014
|
dropped: false,
|
|
843
1015
|
count: 1,
|
|
844
|
-
mappedid: [
|
|
1016
|
+
mappedid: [ mapImg ],
|
|
845
1017
|
} );
|
|
846
1018
|
}
|
|
847
1019
|
logger.info( { files: files, level: 4 } );
|
|
848
1020
|
return files;
|
|
849
1021
|
}
|
|
850
1022
|
} catch ( error ) {
|
|
1023
|
+
/* openSearch logs start*/
|
|
1024
|
+
const id = `${fileDate}_${storeId}_${msg.zone_id}_${bucket.auditInput}_getAuditImage_Error_${user?.userEmail}_${Date.now()}`;
|
|
1025
|
+
let temp = msg;
|
|
1026
|
+
temp.logType='audit';
|
|
1027
|
+
temp.logSubType='get-audit-file';
|
|
1028
|
+
temp.functionName='audit-controller-getFilterData';
|
|
1029
|
+
temp.messageType = 'error';
|
|
1030
|
+
temp.message =error.message ||'Internal Server Error';
|
|
1031
|
+
temp.storeId =msg?.store_id;
|
|
1032
|
+
temp.fileDate =msg?.curr_date;
|
|
1033
|
+
temp.totalCount =msg?.total_count;
|
|
1034
|
+
temp.zoneName =msg?.zone_id;
|
|
1035
|
+
temp.auditType = msg?.audit_type;
|
|
1036
|
+
temp.indexName= msg?.index_name;
|
|
1037
|
+
temp.params = JSON.stringify( fetchData );
|
|
1038
|
+
await openSearchLog( temp, user, id );
|
|
1039
|
+
/* openSearch logs end */
|
|
851
1040
|
logger.error( { error: error, type: 'AWS BUCKET --getAuditImage' } );
|
|
852
1041
|
return error;
|
|
853
1042
|
}
|
|
854
1043
|
}
|
|
855
1044
|
|
|
856
|
-
export const
|
|
1045
|
+
export const getReAuditImg = async ( filter, image ) => {
|
|
857
1046
|
const chunkedMappingData = await chunkArray( image, 10 );
|
|
858
1047
|
const promises = chunkedMappingData.map( async ( chunk ) => {
|
|
859
1048
|
return mapFunction( chunk, filter );
|
|
@@ -1408,6 +1597,22 @@ export async function save( req, res ) {
|
|
|
1408
1597
|
const fileData = await getJsonFileData( params );
|
|
1409
1598
|
|
|
1410
1599
|
if ( fileData?.statusCode ) {
|
|
1600
|
+
/* openSearch logs start*/
|
|
1601
|
+
const id = `${inputData.moduleType}_${inputData.auditId}_${inputData.storeId}_${inputData.moduleType}_${inputData.auditType}_save_Error_${req?.user?.userEmail}_${Date.now()}`;
|
|
1602
|
+
let temp = inputData;
|
|
1603
|
+
temp.logType='audit';
|
|
1604
|
+
temp.logSubType='get-audit-file';
|
|
1605
|
+
temp.functionName='audit-controller-getAuditFile';
|
|
1606
|
+
temp.messageType = 'error';
|
|
1607
|
+
temp.message =`ERROR IN UPLOAD PATH: ${inputData.storeId}/${inputData.fileDate}/${bucket.masterJsonFile}`;
|
|
1608
|
+
temp.storeId =inputData.storeId;
|
|
1609
|
+
temp.fileDate =inputData.fileDate;
|
|
1610
|
+
temp.totalCount =inputData.beforeCount;
|
|
1611
|
+
temp.zoneName =inputData.zoneName;
|
|
1612
|
+
temp.auditType = inputData.auditType;
|
|
1613
|
+
temp.params= JSON.stringify( params );
|
|
1614
|
+
await openSearchLog( temp, req.user, id );
|
|
1615
|
+
/* openSearch logs end*/
|
|
1411
1616
|
logger.error( {
|
|
1412
1617
|
error: `ERROR IN UPLOAD PATH: ${inputData.storeId}/${inputData.fileDate}/${bucket.masterJsonFile}`,
|
|
1413
1618
|
type: 'UPLOAD_ERROR',
|
|
@@ -1443,6 +1648,22 @@ export async function save( req, res ) {
|
|
|
1443
1648
|
const mappingUpload = await fileUpload( uploadDataParams );
|
|
1444
1649
|
|
|
1445
1650
|
if ( mappingUpload?.statusCode ) {
|
|
1651
|
+
/* openSearch logs start*/
|
|
1652
|
+
const id = `${inputData.moduleType}_${inputData.auditId}_${inputData.storeId}_${inputData.moduleType}_${inputData.auditType}_save_Error_${req?.user?.userEmail}_${Date.now()}`;
|
|
1653
|
+
let temp = inputData;
|
|
1654
|
+
temp.logType='audit';
|
|
1655
|
+
temp.logSubType='get-audit-file';
|
|
1656
|
+
temp.functionName='audit-controller-getAuditFile';
|
|
1657
|
+
temp.messageType = 'error';
|
|
1658
|
+
temp.message =`ERROR IN UPLOAD PATH: ${inputData.storeId}/${inputData.fileDate}/${bucket.masterJsonFile}`;
|
|
1659
|
+
temp.storeId =inputData.storeId;
|
|
1660
|
+
temp.fileDate =inputData.fileDate;
|
|
1661
|
+
temp.totalCount =inputData.beforeCount;
|
|
1662
|
+
temp.zoneName =inputData.zoneName;
|
|
1663
|
+
temp.auditType = inputData.auditType;
|
|
1664
|
+
temp.params = uploadDataParams;
|
|
1665
|
+
await openSearchLog( temp, req.user, id );
|
|
1666
|
+
/* openSearch logs end*/
|
|
1446
1667
|
logger.error( {
|
|
1447
1668
|
error: `ERROR IN UPLOAD PATH: ${inputData.storeId}/${inputData.zoneName}/${inputData.fileDate}/${bucket.masterJsonFile}`,
|
|
1448
1669
|
type: 'UPLOAD_ERROR',
|
|
@@ -1709,7 +1930,6 @@ export async function save( req, res ) {
|
|
|
1709
1930
|
const cusIds = getCusId?.body?.hits?.total?.value || null;
|
|
1710
1931
|
if ( cusIds ) {
|
|
1711
1932
|
const temp = getCusId?.body?.hits?.hits.map( ( item ) => item._id );
|
|
1712
|
-
logger.info( { custoemrTemp: temp } );
|
|
1713
1933
|
const body = temp.flatMap( ( id ) => [
|
|
1714
1934
|
{ update: { _index: openSearch.trackerInput, _id: id } },
|
|
1715
1935
|
{ doc: { outputCluster: 50000, auditOutputCluster: 50000 } },
|
|
@@ -1763,8 +1983,8 @@ export async function save( req, res ) {
|
|
|
1763
1983
|
inputData.moduleType == 'traffic'
|
|
1764
1984
|
) {
|
|
1765
1985
|
logger.info(
|
|
1766
|
-
`Hit in
|
|
1767
|
-
'
|
|
1986
|
+
`Hit in ReAudit pushing queue Store Id=${inputData.storeId},File Date=${inputData.fileDate}, /n \nQueue Name = ${clientData[0].auditConfigs.queueName}`,
|
|
1987
|
+
'ReAudit',
|
|
1768
1988
|
);
|
|
1769
1989
|
const queueName = inputData.moduleType == 'zone' ? clientData[0].auditConfigs.zoneQueueName : clientData[0].auditConfigs.trafficQueueName;
|
|
1770
1990
|
if ( !queueName ) {
|
|
@@ -1834,6 +2054,22 @@ export async function save( req, res ) {
|
|
|
1834
2054
|
|
|
1835
2055
|
await insertOpenSearchData( openSearch.auditLog, logData );
|
|
1836
2056
|
} else {
|
|
2057
|
+
/* openSearch logs start*/
|
|
2058
|
+
let id = `${inputData.moduleType}_${inputData.auditId}_${inputData.storeId}_${inputData.moduleType}_${inputData.auditType}_save_Info_${req?.user?.userEmail}_${Date.now()}`;
|
|
2059
|
+
let temp = inputData;
|
|
2060
|
+
temp.logType='audit';
|
|
2061
|
+
temp.logSubType='get-audit-file';
|
|
2062
|
+
temp.functionName='audit-controller-getAuditFile';
|
|
2063
|
+
temp.messageType = 'info';
|
|
2064
|
+
temp.message ='Hit in Features';
|
|
2065
|
+
temp.storeId =inputData.storeId;
|
|
2066
|
+
temp.fileDate =inputData.fileDate;
|
|
2067
|
+
temp.totalCount =inputData.beforeCount;
|
|
2068
|
+
temp.zoneName =inputData.zoneName;
|
|
2069
|
+
temp.auditType = inputData.auditType;
|
|
2070
|
+
await openSearchLog( temp, req.user, id );
|
|
2071
|
+
|
|
2072
|
+
/* openSearch logs end */
|
|
1837
2073
|
logger.info( 'Hit in Features', {
|
|
1838
2074
|
data: _.omit( inputData, [ 'junk', 'employee', 'customer' ] ),
|
|
1839
2075
|
} );
|
|
@@ -1914,9 +2150,20 @@ export async function save( req, res ) {
|
|
|
1914
2150
|
sqsProduceQueue.MessageBody,
|
|
1915
2151
|
|
|
1916
2152
|
);
|
|
1917
|
-
|
|
1918
|
-
|
|
2153
|
+
/* openSearch logs start */
|
|
2154
|
+
id = `${inputData.moduleType}_${inputData.auditId}_${inputData.storeId}_${inputData.moduleType}_${inputData.auditType}_save_Info_${req?.user?.userEmail}_${Date.now()}`;
|
|
2155
|
+
const message = {
|
|
2156
|
+
getBody: getBody,
|
|
2157
|
+
streams: streams,
|
|
2158
|
+
sqsProduceQueue: sqsProduceQueue,
|
|
2159
|
+
sqsQueue: sqsQueue,
|
|
2160
|
+
};
|
|
2161
|
+
temp.message =JSON.stringify( message );
|
|
2162
|
+
await openSearchLog( temp, req.user, id );
|
|
2163
|
+
/* openSearch logs end */
|
|
1919
2164
|
if ( inputData.moduleType === 'track' ) {
|
|
2165
|
+
// declare id
|
|
2166
|
+
id = `${inputData.moduleType}_${inputData.auditId}_${inputData.storeId}_${inputData.moduleType}_${inputData.auditType}_save_Info_${req?.user?.userEmail}_${Date.now()}`;
|
|
1920
2167
|
const query =
|
|
1921
2168
|
{
|
|
1922
2169
|
module: 'REID-TRACKER-V1',
|
|
@@ -1926,6 +2173,10 @@ export async function save( req, res ) {
|
|
|
1926
2173
|
timestamp: new Date(),
|
|
1927
2174
|
};
|
|
1928
2175
|
await upsertOpenSearchData( openSearch.trackerInput, `${inputData.storeId}_${inputData.fileDate}_23:00`, { doc: query } );
|
|
2176
|
+
/* update message */
|
|
2177
|
+
temp.message =JSON.stringify( query );
|
|
2178
|
+
await openSearchLog( temp, req.user, id );
|
|
2179
|
+
/* openSearch logs end */
|
|
1929
2180
|
}
|
|
1930
2181
|
}
|
|
1931
2182
|
|
|
@@ -4363,13 +4614,13 @@ export async function auditImages( req, res ) {
|
|
|
4363
4614
|
return res.sendError( { error: error }, code );
|
|
4364
4615
|
}
|
|
4365
4616
|
|
|
4366
|
-
const
|
|
4367
|
-
if (
|
|
4617
|
+
const reAuditImg = await getReAuditImg( filterData, auditImageAC );
|
|
4618
|
+
if ( reAuditImg?.length == 0 ) {
|
|
4368
4619
|
return res.sendError( 'No Data Found', 204 );
|
|
4369
4620
|
}
|
|
4370
4621
|
|
|
4371
4622
|
if ( inputData.export == true ) {
|
|
4372
|
-
auditImageDownload = await zipDownloadImage(
|
|
4623
|
+
auditImageDownload = await zipDownloadImage( reAuditImg, inputData?.moduleType );
|
|
4373
4624
|
// Set response headers for the zip file
|
|
4374
4625
|
res.set( 'Content-Type', 'application/zip' );
|
|
4375
4626
|
res.set( 'Content-Disposition', `attachment; filename=${inputData.storeId}_${inputData.fileDate}_${inputData.imageType}.zip` );
|
|
@@ -4377,7 +4628,7 @@ export async function auditImages( req, res ) {
|
|
|
4377
4628
|
// Send the zip file as the API response
|
|
4378
4629
|
return res.send( auditImageDownload );
|
|
4379
4630
|
}
|
|
4380
|
-
return res.sendSuccess( { result:
|
|
4631
|
+
return res.sendSuccess( { result: reAuditImg } );
|
|
4381
4632
|
break;
|
|
4382
4633
|
default:
|
|
4383
4634
|
return res.sendError( 'No Data Found', 204 );
|
|
@@ -5421,7 +5672,7 @@ export async function rePushAuditStores( req, res ) {
|
|
|
5421
5672
|
fileDate: { $eq: inputData.fileDate },
|
|
5422
5673
|
},
|
|
5423
5674
|
{
|
|
5424
|
-
moduleType: { $eq:
|
|
5675
|
+
moduleType: { $eq: inputData.moduleType },
|
|
5425
5676
|
},
|
|
5426
5677
|
],
|
|
5427
5678
|
},
|
|
@@ -5449,7 +5700,7 @@ export async function rePushAuditStores( req, res ) {
|
|
|
5449
5700
|
clientId: { $eq: inputData?.clientId },
|
|
5450
5701
|
},
|
|
5451
5702
|
{
|
|
5452
|
-
moduleType: { $eq:
|
|
5703
|
+
moduleType: { $eq: inputData.moduleType },
|
|
5453
5704
|
},
|
|
5454
5705
|
];
|
|
5455
5706
|
if ( getStoreAudit && getStoreAudit?.length > 0 && getStoreAudit?.[0]?.storeList?.length > 0 ) {
|
|
@@ -5496,7 +5747,7 @@ export async function rePushAuditStores( req, res ) {
|
|
|
5496
5747
|
}
|
|
5497
5748
|
} catch ( error ) {
|
|
5498
5749
|
const err = error.message || 'Internal Server Error';
|
|
5499
|
-
logger.error( { error: error, message: req.query, function: 'rePushAuditStores-audit
|
|
5750
|
+
logger.error( { error: error, message: req.query, function: 'rePushAuditStores-audit-controller' } );
|
|
5500
5751
|
return res.sendError( err, 500 );
|
|
5501
5752
|
}
|
|
5502
5753
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { checkFileExist, chunkArray, getJsonFileData, getObject, getQueueUrl, listFileWithoutLimit, logger, signedUrl } from 'tango-app-api-middleware';
|
|
1
|
+
import { checkFileExist, chunkArray, getJsonFileData, getObject, getQueueUrl, insertWithId, listFileWithoutLimit, logger, signedUrl } from 'tango-app-api-middleware';
|
|
2
2
|
import { findOneUserAudit } from '../service/userAudit.service.js';
|
|
3
3
|
import { aggregateStoreAudit, findOneStoreAudit } from '../service/storeAudit.service.js';
|
|
4
4
|
import AdmZip from 'adm-zip';
|
|
@@ -9,11 +9,31 @@ export async function isExistsQueue( req, res, next ) {
|
|
|
9
9
|
const inputData = req.query;
|
|
10
10
|
const isExist = await getQueueUrl( inputData.queueName );
|
|
11
11
|
if ( isExist.statusCode ) {
|
|
12
|
+
/* openSearch logs start */
|
|
13
|
+
const id = `${inputData.moduleType}_${inputData.queueName}_isExistsQueue_Error_${req?.user?.userEmail}_${Date.now()}`;
|
|
14
|
+
let temp = inputData;
|
|
15
|
+
temp.logType='audit';
|
|
16
|
+
temp.logSubType='get-audit-file';
|
|
17
|
+
temp.functionName='audit-validation-isExistsQueue';
|
|
18
|
+
temp.messageType = 'error';
|
|
19
|
+
temp.message =`Queue doesn't Exist`;
|
|
20
|
+
await openSearchLog( temp, req.user, id );
|
|
21
|
+
/* openSearch logs end */
|
|
12
22
|
return res.sendError( `Queue doesn't Exist`, 400 );
|
|
13
23
|
} else {
|
|
14
24
|
next();
|
|
15
25
|
}
|
|
16
26
|
} catch ( error ) {
|
|
27
|
+
/* openSearch logs start */
|
|
28
|
+
const id = `${req.query.moduleType}_${req.query.queueName}_isExistsQueue_Error_${req?.user?.userEmail}_${Date.now()}`;
|
|
29
|
+
let temp = req.query;
|
|
30
|
+
temp.logType='audit';
|
|
31
|
+
temp.logSubType='get-audit-file';
|
|
32
|
+
temp.functionName='audit-validation-isExistsQueue';
|
|
33
|
+
temp.messageType = 'error';
|
|
34
|
+
temp.message =error.message || 'Internal Server Error';
|
|
35
|
+
await openSearchLog( temp, req.user, id );
|
|
36
|
+
/* openSearch logs end */
|
|
17
37
|
logger.error( { error: error, message: req.query, function: 'isExistsQueue' } );
|
|
18
38
|
return res.sendError( error, 500 );
|
|
19
39
|
}
|
|
@@ -22,7 +42,7 @@ export async function isExistsQueue( req, res, next ) {
|
|
|
22
42
|
export async function validateUserAudit( req, res, next ) {
|
|
23
43
|
try {
|
|
24
44
|
const inputData = req.body;
|
|
25
|
-
const userAuditDetails =await findOneUserAudit( { _id: inputData.auditId } );
|
|
45
|
+
const userAuditDetails = await findOneUserAudit( { _id: inputData.auditId } );
|
|
26
46
|
if ( !userAuditDetails ) {
|
|
27
47
|
return res.sendError( 'No Data Available' );
|
|
28
48
|
} else if ( userAuditDetails && userAuditDetails.auditStatus == 'skipped' ) {
|
|
@@ -41,7 +61,7 @@ export async function isMasterJsonExists( req, res, next ) {
|
|
|
41
61
|
try {
|
|
42
62
|
const bucket = JSON.parse( process.env.BUCKET );
|
|
43
63
|
const inputData = req.body;
|
|
44
|
-
params={
|
|
64
|
+
params = {
|
|
45
65
|
Bucket: bucket.masterJson,
|
|
46
66
|
Key: `${inputData.storeId}/${inputData.fileDate}/${bucket.masterJsonFile}`,
|
|
47
67
|
};
|
|
@@ -155,8 +175,8 @@ const mapFunction = async ( chunkData, filterData ) => {
|
|
|
155
175
|
chunkData.find( ( item ) => {
|
|
156
176
|
if ( mappedId.img_name === item.temp_ids ) {
|
|
157
177
|
item.temp_ids = data.img_name;
|
|
158
|
-
|
|
159
|
-
|
|
178
|
+
( mappedId.img_name !== data.img_name ) ? item.query_status = '' : null;
|
|
179
|
+
item.demographic = data.demographic || '';
|
|
160
180
|
}
|
|
161
181
|
} );
|
|
162
182
|
}
|
|
@@ -169,15 +189,15 @@ export async function isAuditInputFolderExist( req, res, next ) {
|
|
|
169
189
|
try {
|
|
170
190
|
const bucket = JSON.parse( process.env.BUCKET );
|
|
171
191
|
const inputData = req.method === 'POST' ? req.body : req.query;
|
|
172
|
-
const params={
|
|
192
|
+
const params = {
|
|
173
193
|
Bucket: bucket.auditInput,
|
|
174
194
|
Key: `${inputData.fileDate}/${inputData.storeId}/${inputData.zoneName}`,
|
|
175
195
|
};
|
|
176
|
-
const trackParams={
|
|
196
|
+
const trackParams = {
|
|
177
197
|
Bucket: 'v4rnd-audit-input-images',
|
|
178
198
|
Key: `${inputData.storeId}/${inputData.fileDate}`,
|
|
179
199
|
};
|
|
180
|
-
const isExist = await checkFileExist( inputData.moduleType == 'track'? trackParams:params );
|
|
200
|
+
const isExist = await checkFileExist( inputData.moduleType == 'track' ? trackParams : params );
|
|
181
201
|
if ( isExist ) {
|
|
182
202
|
next();
|
|
183
203
|
} else {
|
|
@@ -193,7 +213,7 @@ export async function isAuditInputFolderExist( req, res, next ) {
|
|
|
193
213
|
export async function isAuditDocumentExist( req, res, next ) {
|
|
194
214
|
try {
|
|
195
215
|
const inputData = req.body;
|
|
196
|
-
const query={
|
|
216
|
+
const query = {
|
|
197
217
|
storeId: inputData.storeId,
|
|
198
218
|
fileDate: inputData.fileDate,
|
|
199
219
|
zoneName: inputData.zoneName,
|
|
@@ -230,7 +250,7 @@ export async function getAuditImageData( data ) {
|
|
|
230
250
|
}
|
|
231
251
|
const auditImages = folderPath;
|
|
232
252
|
|
|
233
|
-
if ( data.export==false ) {
|
|
253
|
+
if ( data.export == false ) {
|
|
234
254
|
if ( auditImages && auditImages?.length > 0 ) {
|
|
235
255
|
for ( let i = 0; i < auditImages.length; i++ ) {
|
|
236
256
|
const img = auditImages[i].Key.split( '/' );
|
|
@@ -277,21 +297,21 @@ export async function getAuditImageData( data ) {
|
|
|
277
297
|
}
|
|
278
298
|
}
|
|
279
299
|
|
|
280
|
-
export async function zipDownloadImage( data,
|
|
300
|
+
export async function zipDownloadImage( data, moduleType ) {
|
|
281
301
|
try {
|
|
282
302
|
const bucket = JSON.parse( process.env.BUCKET );
|
|
283
303
|
const zip = new AdmZip();
|
|
284
304
|
const split = await chunkArray( data, 10 );
|
|
285
305
|
const promises = await split.map( async ( chunk ) => {
|
|
286
306
|
for ( let item of chunk ) {
|
|
287
|
-
const params ={
|
|
288
|
-
Bucket:
|
|
289
|
-
Key:
|
|
307
|
+
const params = {
|
|
308
|
+
Bucket: moduleType === 'track' ? bucket.trackInput : `${bucket.auditInput}`,
|
|
309
|
+
Key: moduleType === 'track' ? item.img_path : item.imgFile.Key,
|
|
290
310
|
};
|
|
291
311
|
|
|
292
312
|
const fileBuffer = await getObject( params );
|
|
293
|
-
const splitItem =
|
|
294
|
-
const key =
|
|
313
|
+
const splitItem = moduleType === 'track' ? item.img_path.split( '/' ) : null;
|
|
314
|
+
const key = moduleType === 'track' ? `${splitItem[0]}/${splitItem[1]}/${splitItem[3]}` : item.imgFile.Key;
|
|
295
315
|
zip.addFile( key, fileBuffer.Body );
|
|
296
316
|
}
|
|
297
317
|
return zip;
|
|
@@ -370,7 +390,7 @@ export async function validation( req, res, next ) {
|
|
|
370
390
|
fileDate: { $eq: inputData.fileDate },
|
|
371
391
|
},
|
|
372
392
|
{
|
|
373
|
-
moduleType: { $eq:
|
|
393
|
+
moduleType: { $eq: inputData.moduleType },
|
|
374
394
|
},
|
|
375
395
|
{
|
|
376
396
|
status: { $nin: [ 'not_assign', 'assigned' ] },
|
|
@@ -391,4 +411,48 @@ export async function validation( req, res, next ) {
|
|
|
391
411
|
return res.sendError( error, 500 );
|
|
392
412
|
}
|
|
393
413
|
}
|
|
414
|
+
// openSearch log functions
|
|
415
|
+
export async function openSearchLog( inputData, user, id ) {
|
|
416
|
+
try {
|
|
417
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
418
|
+
const logs = {
|
|
419
|
+
userId: user._id,
|
|
420
|
+
userName: user.userName,
|
|
421
|
+
userEmail: user.email,
|
|
422
|
+
functionName: inputData.functionName,
|
|
423
|
+
messageType: inputData.messageType,
|
|
424
|
+
message: inputData.message,
|
|
425
|
+
logType: inputData.logType,
|
|
426
|
+
logSubType: inputData.logSubType,
|
|
427
|
+
logData: {
|
|
428
|
+
fileDate: inputData.fileDate || '',
|
|
429
|
+
auditType: inputData.auditType || '',
|
|
430
|
+
storeId: inputData.storeId || '',
|
|
431
|
+
clientId: inputData.storeId.split( '-' )[0] || '',
|
|
432
|
+
zoneName: inputData.zoneName || '',
|
|
433
|
+
moduleType: inputData.moduleType || '',
|
|
434
|
+
queueName: inputData.queueName || '',
|
|
435
|
+
beforeCount: inputData.beforeCount || null,
|
|
436
|
+
afterCount: inputData.afterCount || null,
|
|
437
|
+
startTime: inputData.startTime || '',
|
|
438
|
+
endTime: inputData.startTime || '',
|
|
439
|
+
timeSpent: inputData.timeSpent || '',
|
|
440
|
+
auditId: inputData.auditId || '',
|
|
441
|
+
totalCount: inputData.totalCount || null,
|
|
442
|
+
indexName: inputData.indexName || '',
|
|
443
|
+
auditType: inputData.auditType || '',
|
|
444
|
+
folderPath: inputData.folderPath || '',
|
|
445
|
+
params: inputData.params||'',
|
|
446
|
+
createdAt: new Date(),
|
|
447
|
+
updatedAt: new Date(),
|
|
448
|
+
},
|
|
449
|
+
|
|
450
|
+
};
|
|
451
|
+
await insertWithId( openSearch.auditedLogs, id, logs );
|
|
452
|
+
return true;
|
|
453
|
+
} catch ( error ) {
|
|
454
|
+
logger.error( { error: error, message: { logs: logs, id: id }, function: 'openSearchLog-audit.validation' } );
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
394
458
|
|