tango-app-api-audit 3.4.46 → 3.4.48

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-audit",
3
- "version": "3.4.46",
3
+ "version": "3.4.48",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -828,10 +828,10 @@ export async function getAuditFile( req, res ) {
828
828
 
829
829
  export async function getUpdatedFile( req, res ) {
830
830
  try {
831
+ const url = JSON.parse( process.env.URL );
831
832
  const openSearch = JSON.parse( process.env.OPENSEARCH );
832
833
  const inputData = req.body;
833
834
  const msg = req?.TraxData?.sqs?.Body;
834
- logger.info( { msg: msg } );
835
835
  let result =[];
836
836
  switch ( inputData.moduleType ) {
837
837
  case 'camera-angle-change':
@@ -900,11 +900,12 @@ export async function getUpdatedFile( req, res ) {
900
900
  logger.info( { folderPath: list, params: params, list: list } );
901
901
  if ( folderPath?.length ) {
902
902
  for ( let i = 0; i < folderPath.length; i++ ) {
903
- const signedParams ={
904
- Bucket: msg.inputBucketName,
905
- file_path: folderPath[i].Key,
906
- };
907
- const data = await signedUrl( signedParams );
903
+ // const signedParams ={
904
+ // Bucket: msg.inputBucketName,
905
+ // file_path: folderPath[i].Key,
906
+ // };
907
+ const BucketCDN = url.traxAuditInput;
908
+ const data = `${BucketCDN}${ folderPath[i].Key}`;
908
909
 
909
910
  files.push(
910
911
  data,
@@ -913,7 +914,7 @@ export async function getUpdatedFile( req, res ) {
913
914
  } else {
914
915
  logger.error( {
915
916
  error: { folderPath: folderPath },
916
- function: `getAuditFile - ${inputData.moduleType}`,
917
+ function: `getUpdatedFile - ${inputData.moduleType}`,
917
918
  message: 'Bucket image data not availale',
918
919
  } );
919
920
  return res.sendError( 'Bucket is Empty', 204 );
@@ -994,7 +995,7 @@ export async function getUpdatedFile( req, res ) {
994
995
  address: storeInfo?.address,
995
996
  customerId: msg.tempId,
996
997
  moduleType: inputData.moduleType,
997
- value: inputData.moduleType == 'left-in-middle'? 'Employee Left in Middle ' : ( inputData.moduleType ).split( '-' ).join( ' ' ),
998
+ value: inputData.moduleType == 'left-in-middle'? 'Employee Left in Middle ' : inputData.moduleType == 'cleaning'? 'Store Cleaning Audit ': inputData.moduleType == 'scrum'? 'Scrum Identification':( inputData.moduleType ).split( '-' ).join( ' ' ),
998
999
  fileDate: msg.fileDate,
999
1000
  question: msg.question,
1000
1001
  questionType: msg.questionType,
@@ -3605,7 +3606,123 @@ export async function overviewTable( req, res ) {
3605
3606
  if ( inputData.filterByStatus.length > 0 ) {
3606
3607
  [ 'mobile-detection', 'uniform-detection', 'hygiene' ].includes( inputData.moduleType )? filters.push( { status: { $in: inputData.filterByStatus } } ):filters.push( { auditStatus: { $in: inputData.filterByStatus } } );
3607
3608
  }
3608
-
3609
+ let traxAuditDataQuery={};
3610
+ let traxAuditDataFilter = [];
3611
+ switch ( inputData.moduleType ) {
3612
+ case 'unattended-customer':
3613
+ traxAuditDataQuery= {
3614
+ fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
3615
+ };
3616
+ traxAuditDataFilter=[ {
3617
+ $eq: [ '$fileDate', '$$fileDate' ],
3618
+ },
3619
+ {
3620
+ $eq: [ '$storeId', '$$storeId' ],
3621
+ },
3622
+ {
3623
+ $eq: [ '$tempId', '$$tempId' ],
3624
+ },
3625
+ {
3626
+ $eq: [ '$moduleType', '$$moduleType' ],
3627
+ },
3628
+ ];
3629
+ break;
3630
+ case 'left-in-middle':
3631
+ traxAuditDataQuery= {
3632
+ fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
3633
+ };
3634
+ traxAuditDataFilter=[ {
3635
+ $eq: [ '$fileDate', '$$fileDate' ],
3636
+ },
3637
+ {
3638
+ $eq: [ '$storeId', '$$storeId' ],
3639
+ },
3640
+ {
3641
+ $eq: [ '$question', '$$question' ],
3642
+ },
3643
+ {
3644
+ $eq: [ '$moduleType', '$$moduleType' ],
3645
+ },
3646
+ ];
3647
+ break;
3648
+ case 'uniform-detection':
3649
+ case 'mobile-detection':
3650
+ case 'scrum':
3651
+ case 'cleaning':
3652
+ traxAuditDataQuery= {
3653
+ fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType',
3654
+ };
3655
+ traxAuditDataFilter=[ {
3656
+ $eq: [ '$fileDate', '$$fileDate' ],
3657
+ },
3658
+ {
3659
+ $eq: [ '$storeId', '$$storeId' ],
3660
+ },
3661
+ {
3662
+ $eq: [ '$moduleType', '$$moduleType' ],
3663
+ },
3664
+ ];
3665
+ break;
3666
+ case 'camera-angle-change':
3667
+ traxAuditDataQuery= {
3668
+ fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
3669
+ };
3670
+ traxAuditDataFilter=[ {
3671
+ $eq: [ '$fileDate', '$$fileDate' ],
3672
+ },
3673
+ {
3674
+ $eq: [ '$storeId', '$$storeId' ],
3675
+ },
3676
+ {
3677
+ $eq: [ '$streamName', '$$streamName' ],
3678
+ },
3679
+ {
3680
+ $eq: [ '$moduleType', '$$moduleType' ],
3681
+ },
3682
+ ];
3683
+ break;
3684
+ case 'hygiene':
3685
+ traxAuditDataQuery= {
3686
+ fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', zoneName: '$zoneName',
3687
+ };
3688
+ traxAuditDataFilter=[ {
3689
+ $eq: [ '$fileDate', '$$fileDate' ],
3690
+ },
3691
+ {
3692
+ $eq: [ '$storeId', '$$storeId' ],
3693
+ },
3694
+ {
3695
+ $eq: [ '$zoneName', '$$zoneName' ],
3696
+ },
3697
+ {
3698
+ $eq: [ '$moduleType', '$$moduleType' ],
3699
+ },
3700
+ ];
3701
+ break;
3702
+ case 'eye-test-camera':
3703
+ traxAuditDataQuery= {
3704
+ fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', question: '$question', streamName: '$streamName',
3705
+ };
3706
+ traxAuditDataFilter=[ {
3707
+ $eq: [ '$fileDate', '$$fileDate' ],
3708
+ },
3709
+ {
3710
+ $eq: [ '$storeId', '$$storeId' ],
3711
+ },
3712
+ {
3713
+ $eq: [ '$question', '$$question' ],
3714
+ },
3715
+ {
3716
+ $eq: [ '$streamName', '$$streamName' ],
3717
+ },
3718
+ {
3719
+ $eq: [ '$moduleType', '$$moduleType' ],
3720
+ },
3721
+ ];
3722
+ break;
3723
+ default:
3724
+ return res.sendError( 'Please give valid modueType', 400 );
3725
+ }
3609
3726
  const query =[
3610
3727
  {
3611
3728
  $match: {
@@ -3616,24 +3733,12 @@ export async function overviewTable( req, res ) {
3616
3733
  {
3617
3734
  $lookup: {
3618
3735
  from: 'traxAuditData',
3619
- let: {
3620
- fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
3621
- },
3736
+ let: traxAuditDataQuery,
3622
3737
  pipeline: [
3623
3738
  {
3624
3739
  $match: {
3625
3740
  $expr: {
3626
- $and: [
3627
- {
3628
- $eq: [ '$fileDate', '$$fileDate' ],
3629
- },
3630
- {
3631
- $eq: [ '$storeId', '$$storeId' ],
3632
- },
3633
- {
3634
- $eq: [ '$zoneName', '$$zoneName' ],
3635
- },
3636
- ],
3741
+ $and: traxAuditDataFilter,
3637
3742
  },
3638
3743
  },
3639
3744
  },
@@ -3887,7 +3992,7 @@ export async function getDetectionAuditFile( req, res ) {
3887
3992
  if ( !consumer ) {
3888
3993
  logger.error( {
3889
3994
  error: consumer,
3890
- function: `getAuditFile - ${inputData.moduleType}`,
3995
+ function: `getDetectionAuditFile - ${inputData.moduleType}`,
3891
3996
  message: 'SQS Receive queue is empty',
3892
3997
  } );
3893
3998
  return res.sendError( `${inputData.queueName} is Empty`, 204 );
@@ -80,14 +80,9 @@ export async function isTraxAuditDocumentExist( req, res, next ) {
80
80
  };
81
81
  break;
82
82
  case 'uniform-detection':
83
- query ={
84
- storeId: inputData.storeId,
85
- fileDate: inputData.fileDate,
86
- // tempId: inputData.tempId,
87
- moduleType: inputData.moduleType,
88
- };
89
- break;
90
83
  case 'mobile-detection':
84
+ case 'scrum':
85
+ case 'cleaning':
91
86
  query ={
92
87
  storeId: inputData.storeId,
93
88
  fileDate: inputData.fileDate,
@@ -95,18 +90,10 @@ export async function isTraxAuditDocumentExist( req, res, next ) {
95
90
  };
96
91
  break;
97
92
  case 'camera-angle-change':
98
- query ={
99
- storeId: inputData.storeId,
100
- fileDate: inputData.fileDate,
101
- streamName: inputData.streamName,
102
- moduleType: inputData.moduleType,
103
- };
104
- break;
105
93
  case 'eye-test-camera':
106
94
  query ={
107
95
  storeId: inputData.storeId,
108
96
  fileDate: inputData.fileDate,
109
- // question: inputData.question,
110
97
  streamName: inputData.streamName,
111
98
  moduleType: inputData.moduleType,
112
99
  };