tango-app-api-audit 3.6.39 → 3.6.41

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.6.39",
3
+ "version": "3.6.41",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  "nodemailer": "^7.0.10",
29
29
  "nodemon": "^3.1.3",
30
30
  "swagger-ui-express": "^5.0.1",
31
- "tango-api-schema": "^2.3.28",
31
+ "tango-api-schema": "^2.5.27",
32
32
  "tango-app-api-middleware": "^3.6.8",
33
33
  "winston": "^3.13.0",
34
34
  "winston-daily-rotate-file": "^5.0.0"
@@ -483,6 +483,11 @@ export async function getAuditFile( req, res ) {
483
483
  const start = data.start;
484
484
  const end = data.end;
485
485
  let msg = {};
486
+ let clientConfig;
487
+ if ( inputData?.moduleType === 'unattended-customer' ) {
488
+ clientConfig = await findOneClient( { 'auditConfigs.traxQueueName.unattendedCustomer': inputData?.queueName }, { clientId: 1, auditConfigs: 1 } );
489
+ }
490
+ const isZoneAudit = clientConfig?.auditConfigs?.unattendedAuditZone || false;
486
491
  const userQuery = [
487
492
  {
488
493
  $match: {
@@ -533,6 +538,7 @@ export async function getAuditFile( req, res ) {
533
538
  storeId: userDetails[0].storeId,
534
539
  fileDate: userDetails[0].fileDate,
535
540
  tempId: userDetails[0].tempId,
541
+ ...( isZoneAudit && { zoneName: userDetails[0].zoneName } ),
536
542
  moduleType: userDetails[0].moduleType,
537
543
  };
538
544
  break;
@@ -759,12 +765,13 @@ export async function getAuditFile( req, res ) {
759
765
  fileDateISO: start,
760
766
  timeSpent: 0,
761
767
  startTime: new Date(),
762
- tempId: msg.tempId,
763
- fileDetails: msg.fileDetails,
764
- inputBucketName: msg.inputBucketName,
765
- question: msg.question,
766
- questionType: msg.questionType,
767
- streamName: msg.streamName,
768
+ tempId: msg?.tempId,
769
+ fileDetails: msg?.fileDetails,
770
+ inputBucketName: msg?.inputBucketName,
771
+ question: msg?.question,
772
+ questionType: msg?.questionType,
773
+ streamName: msg?.streamName,
774
+ zoneName: msg?.zoneName,
768
775
  };
769
776
  record.streamName =[ 'camera-angle-change', 'eye-test-camera', 'anomaly-audit', 'scrum' ].includes( inputData.moduleType )? msg.streamName : '';
770
777
  record.videoDetails = inputData.moduleType == 'left-in-middle'? {
@@ -780,10 +787,11 @@ export async function getAuditFile( req, res ) {
780
787
  switch ( inputData.moduleType ) {
781
788
  case 'unattended-customer':
782
789
  getQuery ={
783
- storeId: msg.storeId,
784
- fileDate: msg.fileDate,
785
- tempId: msg.tempId,
786
- moduleType: inputData.moduleType,
790
+ storeId: msg?.storeId,
791
+ fileDate: msg?.fileDate,
792
+ tempId: msg?.tempId,
793
+ ...( isZoneAudit && { zoneName: msg?.zoneName } ),
794
+ moduleType: inputData?.moduleType,
787
795
  };
788
796
  break;
789
797
  case 'left-in-middle':
@@ -849,6 +857,7 @@ export async function getAuditFile( req, res ) {
849
857
  question: msg.question,
850
858
  questionType: msg.questionType,
851
859
  streamName: msg.streamName,
860
+ zoneName: msg?.zoneName || '',
852
861
  },
853
862
  createdAt: new Date(),
854
863
  };
@@ -1098,9 +1107,15 @@ export async function getUpdatedFile( req, res ) {
1098
1107
  export async function saveBinary( req, res ) {
1099
1108
  try {
1100
1109
  const openSearch = JSON.parse( process.env.OPENSEARCH );
1110
+ let clientConfig;
1111
+ const inputData = req.body;
1112
+ if ( inputData?.moduleType === 'unattended-customer' ) {
1113
+ clientConfig = await findOneClient( { 'auditConfigs.traxQueueName.unattendedCustomer': inputData?.queueName }, { clientId: 1, auditConfigs: 1 } );
1114
+ }
1115
+ const isZoneAudit = clientConfig?.auditConfigs?.unattendedAuditZone || false;
1101
1116
  const url = JSON.parse( process.env.URL );
1102
1117
  const sqs = JSON.parse( process.env.SQS );
1103
- const inputData = req.body;
1118
+
1104
1119
  const isoDate = req.userAudit?.startTime;
1105
1120
  const currentTime = dayjs();
1106
1121
  const isoDateTime = dayjs( isoDate );
@@ -1127,17 +1142,21 @@ export async function saveBinary( req, res ) {
1127
1142
  if ( updatDataunattended.modifiedCount==0 ) {
1128
1143
  return res.sendError( 'Update failed, it may be invalid request', 400 );
1129
1144
  }
1145
+
1146
+ const getupdatedData = await findOneBinaryAudit( { _id: inputData.auditId } );
1130
1147
  const getQuery = {
1148
+
1131
1149
  storeId: inputData.storeId,
1150
+ ...( isZoneAudit && { zoneName: getupdatedData?.zoneName } ),
1132
1151
  fileDate: inputData.fileDate,
1133
1152
  tempId: inputData.tempId,
1134
1153
  moduleType: inputData.moduleType,
1135
1154
  };
1136
- const getupdatedData = await findOneBinaryAudit( getQuery );
1137
1155
  const getTraxInsertData = await findOneTraxAuditData( getQuery, { sqs: 1 } );
1138
1156
  const OpenSearchOutput = {
1139
1157
  clientId: getupdatedData?.clientId,
1140
1158
  storeId: getupdatedData?.storeId,
1159
+ ...( isZoneAudit && { zoneName: getupdatedData?.zoneName } ),
1141
1160
  moduleType: getupdatedData?.moduleType,
1142
1161
  fileDate: getupdatedData?.fileDate,
1143
1162
  auditStatus: getupdatedData?.auditStatus,
@@ -1159,6 +1178,7 @@ export async function saveBinary( req, res ) {
1159
1178
  fileDate: req.userAudit?.fileDate,
1160
1179
  auditType: req.userAudit?.auditType,
1161
1180
  storeId: req.userAudit?.storeId,
1181
+ zoneName: req?.userAudit?.zoneName,
1162
1182
  moduleType: req.userAudit?.moduleType,
1163
1183
  queueName: req.userAudit?.queueName,
1164
1184
  clientId: req.userAudit?.clientId,
@@ -1818,7 +1838,7 @@ export async function saveBinary( req, res ) {
1818
1838
  break;
1819
1839
  }
1820
1840
  } catch ( error ) {
1821
- const err = error.mesage || error.response?.data || error.response?.status ||'Internal Server Error';
1841
+ const err = error.message || error.response?.data || error.response?.status ||'Internal Server Error';
1822
1842
  logger.error( { error: error, data: req.body, function: 'saveBinary' } );
1823
1843
  return res.sendError( err, 500 );
1824
1844
  }
@@ -1874,7 +1894,7 @@ export async function userAuditHistory( req, res ) {
1874
1894
  switch ( inputData.moduleType ) {
1875
1895
  case 'unattended-customer':
1876
1896
  traxAuditDataQuery= {
1877
- fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
1897
+ fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType', zoneName: { $ifNull: [ '$zoneName', '' ] },
1878
1898
  };
1879
1899
  traxAuditDataFilter=[ {
1880
1900
  $eq: [ '$fileDate', '$$fileDate' ],
@@ -1888,6 +1908,12 @@ export async function userAuditHistory( req, res ) {
1888
1908
  {
1889
1909
  $eq: [ '$moduleType', '$$moduleType' ],
1890
1910
  },
1911
+ {
1912
+ $eq: [
1913
+ { $ifNull: [ '$zoneName', '' ] },
1914
+ { $ifNull: [ '$$zoneName', '' ] },
1915
+ ],
1916
+ },
1891
1917
  ];
1892
1918
  break;
1893
1919
  case 'left-in-middle':
@@ -2644,7 +2670,7 @@ export async function storeMetrics( req, res ) {
2644
2670
  switch ( inputData.moduleType ) {
2645
2671
  case 'unattended-customer':
2646
2672
  traxAuditDataQuery= {
2647
- fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
2673
+ fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType', zoneName: { $ifNull: [ '$zoneName', '' ] },
2648
2674
  };
2649
2675
  traxAuditDataFilter=[ {
2650
2676
  $eq: [ '$fileDate', '$$fileDate' ],
@@ -2658,6 +2684,12 @@ export async function storeMetrics( req, res ) {
2658
2684
  {
2659
2685
  $eq: [ '$moduleType', '$$moduleType' ],
2660
2686
  },
2687
+ {
2688
+ $eq: [
2689
+ { $ifNull: [ '$zoneName', '' ] },
2690
+ { $ifNull: [ '$$zoneName', '' ] },
2691
+ ],
2692
+ },
2661
2693
  ];
2662
2694
  break;
2663
2695
  case 'left-in-middle':
@@ -3658,7 +3690,7 @@ export async function pendingSummaryTable( req, res ) {
3658
3690
  switch ( inputData.moduleType ) {
3659
3691
  case 'unattended-customer':
3660
3692
  traxAuditDataQuery= {
3661
- fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
3693
+ fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType', zoneName: { $ifNull: [ '$zoneName', '' ] },
3662
3694
  };
3663
3695
  traxAuditDataFilter=[ {
3664
3696
  $eq: [ '$fileDate', '$$fileDate' ],
@@ -3672,6 +3704,12 @@ export async function pendingSummaryTable( req, res ) {
3672
3704
  {
3673
3705
  $eq: [ '$moduleType', '$$moduleType' ],
3674
3706
  },
3707
+ {
3708
+ $or: [
3709
+ { $eq: [ '$zoneName', '$$zoneName' ] },
3710
+ { $not: [ { $ifNull: [ '$zoneName', false ] } ] },
3711
+ ],
3712
+ },
3675
3713
  ];
3676
3714
  break;
3677
3715
  case 'left-in-middle':
@@ -4359,7 +4397,7 @@ export async function overviewTable( req, res ) {
4359
4397
  switch ( inputData.moduleType ) {
4360
4398
  case 'unattended-customer':
4361
4399
  traxAuditDataQuery= {
4362
- fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
4400
+ fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType', zoneName: { $ifNull: [ '$zoneName', '' ] },
4363
4401
  };
4364
4402
  traxAuditDataFilter=[ {
4365
4403
  $eq: [ '$fileDate', '$$fileDate' ],
@@ -4373,6 +4411,12 @@ export async function overviewTable( req, res ) {
4373
4411
  {
4374
4412
  $eq: [ '$moduleType', '$$moduleType' ],
4375
4413
  },
4414
+ {
4415
+ $eq: [
4416
+ { $ifNull: [ '$zoneName', '' ] },
4417
+ { $ifNull: [ '$$zoneName', '' ] },
4418
+ ],
4419
+ },
4376
4420
  ];
4377
4421
  break;
4378
4422
  case 'left-in-middle':