tango-app-api-audit 3.6.38 → 3.6.40

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.38",
3
+ "version": "3.6.40",
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,6 +1107,11 @@ 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
+ if ( inputData?.moduleType === 'unattended-customer' ) {
1112
+ clientConfig = await findOneClient( { 'auditConfigs.traxQueueName.unattendedCustomer': inputData?.queueName }, { clientId: 1, auditConfigs: 1 } );
1113
+ }
1114
+ const isZoneAudit = clientConfig?.auditConfigs?.unattendedAuditZone || false;
1101
1115
  const url = JSON.parse( process.env.URL );
1102
1116
  const sqs = JSON.parse( process.env.SQS );
1103
1117
  const inputData = req.body;
@@ -1127,17 +1141,21 @@ export async function saveBinary( req, res ) {
1127
1141
  if ( updatDataunattended.modifiedCount==0 ) {
1128
1142
  return res.sendError( 'Update failed, it may be invalid request', 400 );
1129
1143
  }
1144
+
1145
+ const getupdatedData = await findOneBinaryAudit( { _id: inputData.auditId } );
1130
1146
  const getQuery = {
1147
+
1131
1148
  storeId: inputData.storeId,
1149
+ ...( isZoneAudit && { zoneName: getupdatedData?.zoneName } ),
1132
1150
  fileDate: inputData.fileDate,
1133
1151
  tempId: inputData.tempId,
1134
1152
  moduleType: inputData.moduleType,
1135
1153
  };
1136
- const getupdatedData = await findOneBinaryAudit( getQuery );
1137
1154
  const getTraxInsertData = await findOneTraxAuditData( getQuery, { sqs: 1 } );
1138
1155
  const OpenSearchOutput = {
1139
1156
  clientId: getupdatedData?.clientId,
1140
1157
  storeId: getupdatedData?.storeId,
1158
+ ...( isZoneAudit && { zoneName: getupdatedData?.zoneName } ),
1141
1159
  moduleType: getupdatedData?.moduleType,
1142
1160
  fileDate: getupdatedData?.fileDate,
1143
1161
  auditStatus: getupdatedData?.auditStatus,
@@ -1159,6 +1177,7 @@ export async function saveBinary( req, res ) {
1159
1177
  fileDate: req.userAudit?.fileDate,
1160
1178
  auditType: req.userAudit?.auditType,
1161
1179
  storeId: req.userAudit?.storeId,
1180
+ zoneName: req?.userAudit?.zoneName,
1162
1181
  moduleType: req.userAudit?.moduleType,
1163
1182
  queueName: req.userAudit?.queueName,
1164
1183
  clientId: req.userAudit?.clientId,
@@ -1874,7 +1893,7 @@ export async function userAuditHistory( req, res ) {
1874
1893
  switch ( inputData.moduleType ) {
1875
1894
  case 'unattended-customer':
1876
1895
  traxAuditDataQuery= {
1877
- fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
1896
+ fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType', zoneName: { $ifNull: [ '$zoneName', '' ] },
1878
1897
  };
1879
1898
  traxAuditDataFilter=[ {
1880
1899
  $eq: [ '$fileDate', '$$fileDate' ],
@@ -1888,6 +1907,12 @@ export async function userAuditHistory( req, res ) {
1888
1907
  {
1889
1908
  $eq: [ '$moduleType', '$$moduleType' ],
1890
1909
  },
1910
+ {
1911
+ $eq: [
1912
+ { $ifNull: [ '$zoneName', '' ] },
1913
+ { $ifNull: [ '$$zoneName', '' ] },
1914
+ ],
1915
+ },
1891
1916
  ];
1892
1917
  break;
1893
1918
  case 'left-in-middle':
@@ -2644,7 +2669,7 @@ export async function storeMetrics( req, res ) {
2644
2669
  switch ( inputData.moduleType ) {
2645
2670
  case 'unattended-customer':
2646
2671
  traxAuditDataQuery= {
2647
- fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
2672
+ fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType', zoneName: { $ifNull: [ '$zoneName', '' ] },
2648
2673
  };
2649
2674
  traxAuditDataFilter=[ {
2650
2675
  $eq: [ '$fileDate', '$$fileDate' ],
@@ -2658,6 +2683,12 @@ export async function storeMetrics( req, res ) {
2658
2683
  {
2659
2684
  $eq: [ '$moduleType', '$$moduleType' ],
2660
2685
  },
2686
+ {
2687
+ $eq: [
2688
+ { $ifNull: [ '$zoneName', '' ] },
2689
+ { $ifNull: [ '$$zoneName', '' ] },
2690
+ ],
2691
+ },
2661
2692
  ];
2662
2693
  break;
2663
2694
  case 'left-in-middle':
@@ -3658,7 +3689,7 @@ export async function pendingSummaryTable( req, res ) {
3658
3689
  switch ( inputData.moduleType ) {
3659
3690
  case 'unattended-customer':
3660
3691
  traxAuditDataQuery= {
3661
- fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
3692
+ fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType', zoneName: { $ifNull: [ '$zoneName', '' ] },
3662
3693
  };
3663
3694
  traxAuditDataFilter=[ {
3664
3695
  $eq: [ '$fileDate', '$$fileDate' ],
@@ -3672,6 +3703,12 @@ export async function pendingSummaryTable( req, res ) {
3672
3703
  {
3673
3704
  $eq: [ '$moduleType', '$$moduleType' ],
3674
3705
  },
3706
+ {
3707
+ $or: [
3708
+ { $eq: [ '$zoneName', '$$zoneName' ] },
3709
+ { $not: [ { $ifNull: [ '$zoneName', false ] } ] },
3710
+ ],
3711
+ },
3675
3712
  ];
3676
3713
  break;
3677
3714
  case 'left-in-middle':
@@ -4359,7 +4396,7 @@ export async function overviewTable( req, res ) {
4359
4396
  switch ( inputData.moduleType ) {
4360
4397
  case 'unattended-customer':
4361
4398
  traxAuditDataQuery= {
4362
- fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
4399
+ fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType', zoneName: { $ifNull: [ '$zoneName', '' ] },
4363
4400
  };
4364
4401
  traxAuditDataFilter=[ {
4365
4402
  $eq: [ '$fileDate', '$$fileDate' ],
@@ -4373,6 +4410,12 @@ export async function overviewTable( req, res ) {
4373
4410
  {
4374
4411
  $eq: [ '$moduleType', '$$moduleType' ],
4375
4412
  },
4413
+ {
4414
+ $eq: [
4415
+ { $ifNull: [ '$zoneName', '' ] },
4416
+ { $ifNull: [ '$$zoneName', '' ] },
4417
+ ],
4418
+ },
4376
4419
  ];
4377
4420
  break;
4378
4421
  case 'left-in-middle':
@@ -217,7 +217,7 @@ Looking forward to working together on this, Below is a copy of your submitted r
217
217
 
218
218
  <div class="compliance-box">Compliance Percentage: ${compliancePercentage}%</div>
219
219
 
220
- <p class="attachment">Here’s the Eye test compliance video for your review</p>
220
+ <p class="attachment">Here’s the Eye test compliance video for your review 👇</p>
221
221
  <!-- Video Embed (only if provided) -->
222
222
  ${
223
223
  videoUrl ?