tango-app-api-infra 3.9.5-vms.66 → 3.9.5-vms.68

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,11 +1,11 @@
1
1
  {
2
2
  "name": "tango-app-api-infra",
3
- "version": "3.9.5-vms.66",
3
+ "version": "3.9.5-vms.68",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "start": "nodemon --exec \"eslint --fix . && node index.js\""
8
+ "start": "nodemon --exec \"eslint --fix . && node app.js\""
9
9
  },
10
10
  "engines": {
11
11
  "node": ">=18.10.0"
@@ -157,7 +157,7 @@ export async function tangoReviewTicket( req, res ) {
157
157
  };
158
158
  let findTicket = await getOpenSearchData( openSearch.footfallDirectory, findQuery );
159
159
  let Ticket = findTicket.body?.hits?.hits;
160
- console.log( '🚀 ~ tangoReviewTicket ~ Ticket:', Ticket );
160
+
161
161
  if ( Ticket.length === 0 ) {
162
162
  return res.sendError( 'Ticket not found', 400 );
163
163
  }
@@ -182,11 +182,25 @@ export async function tangoReviewTicket( req, res ) {
182
182
  },
183
183
  };
184
184
  if ( Ticket[0]?._source?.type != 'internal' ) {
185
- getTicket.query.bool.must.push( {
186
- term: {
187
- 'mappingInfo.type': 'tangoreview',
188
- },
189
- } );
185
+ getTicket.query.bool.must.push(
186
+ {
187
+ nested: {
188
+ path: 'mappingInfo',
189
+ query: {
190
+ bool: {
191
+ must: [
192
+ {
193
+ term: {
194
+ 'mappingInfo.type': 'tangoreview',
195
+ },
196
+ },
197
+
198
+ ],
199
+ },
200
+ },
201
+ },
202
+ },
203
+ );
190
204
  }
191
205
  const getFootfallticketData = await getOpenSearchData( openSearch.footfallDirectory, getTicket );
192
206
  const ticketData = getFootfallticketData?.body?.hits?.hits;
@@ -255,20 +269,20 @@ export async function tangoReviewTicket( req, res ) {
255
269
  } );
256
270
  }
257
271
  // If no review mapping existed, push a new one
258
- if ( record.mappingInfo.length === 0 ) {
259
- record.mappingInfo.push( {
260
- type: 'tangoreview',
261
- mode: inputData.mappingInfo?.mode,
262
- revicedFootfall: inputData.mappingInfo?.revicedFootfall,
263
- revicedPerc: inputData.mappingInfo?.revicedPerc,
264
- count: inputData.mappingInfo?.count,
265
- revisedDetail: inputData.mappingInfo?.revisedDetail,
266
- status: 'Closed',
267
- createdByEmail: req?.user?.email,
268
- createdByUserName: req?.user?.userName,
269
- createdByRole: req?.user?.role,
270
- } );
271
- }
272
+ // if ( record.mappingInfo.length === 0 ) {
273
+ // record.mappingInfo.push( {
274
+ // type: 'tangoreview',
275
+ // mode: inputData.mappingInfo?.mode,
276
+ // revicedFootfall: inputData.mappingInfo?.revicedFootfall,
277
+ // revicedPerc: inputData.mappingInfo?.revicedPerc,
278
+ // count: inputData.mappingInfo?.count,
279
+ // revisedDetail: inputData.mappingInfo?.revisedDetail,
280
+ // status: 'Closed',
281
+ // createdByEmail: req?.user?.email,
282
+ // createdByUserName: req?.user?.userName,
283
+ // createdByRole: req?.user?.role,
284
+ // } );
285
+ // }
272
286
  }
273
287
  record.mappingInfo.push(
274
288
  {
@@ -317,20 +331,20 @@ export async function tangoReviewTicket( req, res ) {
317
331
  } );
318
332
  }
319
333
  // If no review mapping existed, push a new one
320
- if ( record.mappingInfo.length === 0 ) {
321
- record.mappingInfo.push( {
322
- type: 'tangoreview',
323
- mode: inputData.mappingInfo?.mode,
324
- revicedFootfall: inputData.mappingInfo?.revicedFootfall,
325
- revicedPerc: inputData.mappingInfo?.revicedPerc,
326
- count: inputData.mappingInfo?.count,
327
- revisedDetail: inputData.mappingInfo?.revisedDetail,
328
- status: 'Closed',
329
- createdByEmail: req?.user?.email,
330
- createdByUserName: req?.user?.userName,
331
- createdByRole: req?.user?.role,
332
- } );
333
- }
334
+ // if ( record.mappingInfo.length === 0 ) {
335
+ // record.mappingInfo.push( {
336
+ // type: 'tangoreview',
337
+ // mode: inputData.mappingInfo?.mode,
338
+ // revicedFootfall: inputData.mappingInfo?.revicedFootfall,
339
+ // revicedPerc: inputData.mappingInfo?.revicedPerc,
340
+ // count: inputData.mappingInfo?.count,
341
+ // revisedDetail: inputData.mappingInfo?.revisedDetail,
342
+ // status: 'Closed',
343
+ // createdByEmail: req?.user?.email,
344
+ // createdByUserName: req?.user?.userName,
345
+ // createdByRole: req?.user?.role,
346
+ // } );
347
+ // }
334
348
  }
335
349
  } else {
336
350
  if ( Array.isArray( record.mappingInfo ) ) {
@@ -393,23 +407,26 @@ export async function tangoReviewTicket( req, res ) {
393
407
  }
394
408
 
395
409
  if ( Ticket[0]?._source?.type==='store' ) {
396
- let userData = await findOneUser( { email: Ticket[0]?._source?.createdByEmail } );
397
- let title = `Received response for the Footfall ticket raised.`;
398
- let createdOn = dayjs( Ticket[0]?._source?.dateString ).format( 'DD MMM YYYY' );
399
- let description = `Raised on ${createdOn}`;
400
- console.log( '🚀 ~ ticketCreation ~ userData.role:', userData.email );
401
- let Data = {
402
- 'title': title,
403
- 'body': description,
404
- 'type': 'closed',
405
- 'date': Ticket[0]?._source?.dateString,
406
- 'storeId': Ticket[0]?._source?.storeId,
407
- 'clientId': Ticket[0]?._source?.clientId,
408
- 'ticketId': Ticket[0]?._source?.ticketId,
409
- };
410
- if ( userData && userData.fcmToken ) {
411
- const fcmToken = userData.fcmToken;
412
- await sendPushNotification( title, description, fcmToken, Data );
410
+ let findTagging = Ticket[0]?._source?.mappingInfo.filter( ( data ) => data.type==='tagging' );
411
+ if ( findTagging?.length>0&&findTagging[0].createdByEmail!='' ) {
412
+ let userData = await findOneUser( { email: findTagging[0]?.createdByEmail } );
413
+ let title = `Received response for the Footfall ticket raised.`;
414
+ let createdOn = dayjs( Ticket[0]?._source?.dateString ).format( 'DD MMM YYYY' );
415
+ let description = `Raised on ${createdOn}`;
416
+
417
+ let Data = {
418
+ 'title': title,
419
+ 'body': description,
420
+ 'type': 'closed',
421
+ 'date': Ticket[0]?._source?.dateString,
422
+ 'storeId': Ticket[0]?._source?.storeId,
423
+ 'clientId': Ticket[0]?._source?.clientId,
424
+ 'ticketId': Ticket[0]?._source?.ticketId,
425
+ };
426
+ if ( userData && userData.fcmToken ) {
427
+ const fcmToken = userData.fcmToken;
428
+ await sendPushNotification( title, description, fcmToken, Data );
429
+ }
413
430
  }
414
431
  }
415
432
  // return;
@@ -870,6 +887,7 @@ export async function ticketList( req, res ) {
870
887
  const offset = inputData.offset == 0 ? 0 : ( inputData.offset - 1 ) * limit || 0;
871
888
  inputData.clientId = inputData?.clientId?.split( ',' ); // convert strig to array
872
889
 
890
+
873
891
  const ticketsFeature = userInfo?.rolespermission?.some( ( f ) => f.featureName === 'FootfallDirectory' && ( f.modules.find( ( m ) => m.name == 'reviewer' && ( m.isAdd == true || m.isEdit == true ) ) ) );
874
892
 
875
893
  const ticketsApproveFeature = userInfo?.rolespermission?.some( ( f ) => f.featureName === 'FootfallDirectory' && ( f.modules.find( ( m ) => m.name == 'approver' && ( m.isAdd == true || m.isEdit == true ) ) ) );
@@ -934,42 +952,185 @@ export async function ticketList( req, res ) {
934
952
  },
935
953
  } );
936
954
  }
955
+ if ( inputData.status && inputData.status!=='' ) {
956
+ inputData.status = inputData?.status?.split( ',' );
957
+ if ( req.user.userType === 'tango' ) {
958
+ searchQuery.query.bool.must.push( {
959
+ terms: {
960
+ 'status': Array.isArray( inputData?.status ) ?
961
+ inputData?.status :
962
+ [ inputData?.status ],
963
+ },
964
+ } );
965
+ } else if ( inputData?.permissionType === 'approve' ) {
966
+ searchQuery.query.bool.must.push( {
967
+ nested: {
968
+ path: 'mappingInfo',
969
+ query: {
970
+ bool: {
971
+ must: [
972
+ {
973
+ term: {
974
+ 'mappingInfo.type': 'approve',
975
+ },
976
+ },
977
+ {
978
+ term: {
979
+ 'mappingInfo.status': inputData.status[0],
980
+ },
981
+ },
982
+ ],
983
+ },
984
+ },
985
+ },
986
+ } );
987
+ } else if ( inputData?.permissionType === 'review' ) {
988
+ searchQuery.query.bool.must.push( {
989
+ nested: {
990
+ path: 'mappingInfo',
991
+ query: {
992
+ bool: {
993
+ must: [
994
+ {
995
+ term: {
996
+ 'mappingInfo.type': 'review',
997
+ },
998
+ },
999
+ {
1000
+ term: {
1001
+ 'mappingInfo.status': inputData.status[0],
1002
+ },
1003
+ },
1004
+ ],
1005
+ },
1006
+ },
1007
+ },
1008
+ } );
1009
+ } else if ( ticketsFeature ) {
1010
+ searchQuery.query.bool.must.push( {
1011
+ nested: {
1012
+ path: 'mappingInfo',
1013
+ query: {
1014
+ bool: {
1015
+ must: [
1016
+ {
1017
+ term: {
1018
+ 'mappingInfo.type': 'review',
1019
+ },
1020
+ },
1021
+ {
1022
+ term: {
1023
+ 'mappingInfo.status': inputData.status[0],
1024
+ },
1025
+ },
1026
+ ],
1027
+ },
1028
+ },
1029
+ },
1030
+ } );
1031
+ } else if ( ticketsApproveFeature ) {
1032
+ searchQuery.query.bool.must.push( {
1033
+ nested: {
1034
+ path: 'mappingInfo',
1035
+ query: {
1036
+ bool: {
1037
+ must: [
1038
+ {
1039
+ term: {
1040
+ 'mappingInfo.type': 'approve',
1041
+ },
1042
+ },
1043
+ {
1044
+ term: {
1045
+ 'mappingInfo.status': inputData.status[0],
1046
+ },
1047
+ },
1048
+ ],
1049
+ },
1050
+ },
1051
+ },
1052
+ } );
1053
+ }
1054
+ }
937
1055
 
938
1056
  if ( req?.user?.userType == 'tango' && inputData.tangoType !== 'internal' ) {
939
- searchQuery.query.bool.must.push( {
940
- term: {
941
- 'mappingInfo.type': 'tangoreview',
942
- },
943
- },
944
- {
945
- term: {
946
- 'type.keyword': 'store',
947
- },
948
- },
1057
+ searchQuery.query.bool.must.push(
1058
+ {
1059
+ term: {
1060
+ 'type.keyword': 'store',
1061
+ },
1062
+ },
1063
+ {
1064
+ nested: {
1065
+ path: 'mappingInfo',
1066
+ query: {
1067
+ bool: {
1068
+ must: [
1069
+ {
1070
+ term: {
1071
+ 'mappingInfo.type': 'review',
1072
+ },
1073
+ },
1074
+
1075
+ ],
1076
+ },
1077
+ },
1078
+ },
1079
+
1080
+ },
949
1081
 
950
1082
 
951
1083
  );
952
1084
  } else if ( inputData.tangoType !== 'internal' ) {
953
- searchQuery.query.bool.must.push( {
954
- term: {
955
- 'mappingInfo.type': ticketsFeature ? 'review' : ticketsApproveFeature ?
956
- 'approve' : 'tagging',
957
- },
958
- },
959
- {
960
- term: {
961
- 'type.keyword': 'store',
962
- },
963
- } );
1085
+ searchQuery.query.bool.must.push(
1086
+ {
1087
+ term: {
1088
+ 'type.keyword': 'store',
1089
+ },
1090
+ },
1091
+ {
1092
+ nested: {
1093
+ path: 'mappingInfo',
1094
+ query: {
1095
+ bool: {
1096
+ must: [
1097
+ {
1098
+ term: {
1099
+ 'mappingInfo.type': ticketsFeature ? 'review' : ticketsApproveFeature ?
1100
+ 'approve' : 'tagging',
1101
+ },
1102
+ },
1103
+
1104
+ ],
1105
+ },
1106
+ },
1107
+ },
1108
+ },
1109
+
1110
+ );
964
1111
  }
965
1112
 
966
1113
  if ( inputData?.permissionType ) {
967
- searchQuery.query.bool.must.push( {
968
- term: {
969
- 'mappingInfo.type': inputData?.permissionType == 'review' ? 'review' :
970
- 'approve',
971
- },
972
- } );
1114
+ searchQuery.query.bool.must.push(
1115
+ {
1116
+ nested: {
1117
+ path: 'mappingInfo',
1118
+ query: {
1119
+ bool: {
1120
+ must: [
1121
+ {
1122
+ term: {
1123
+ 'mappingInfo.type': inputData?.permissionType == 'review' ? 'review' :
1124
+ 'approve',
1125
+ },
1126
+ },
1127
+
1128
+ ],
1129
+ },
1130
+ },
1131
+ },
1132
+ },
1133
+ );
973
1134
  }
974
1135
 
975
1136
  if ( inputData.searchValue && inputData.searchValue !== '' ) {
@@ -1004,7 +1165,6 @@ export async function ticketList( req, res ) {
1004
1165
  }
1005
1166
  // You can add more filters as needed
1006
1167
  const searchResult = await getOpenSearchData( openSearch.footfallDirectory, searchQuery );
1007
- logger.info( { searchResult } );
1008
1168
  const count = searchResult?.body?.hits?.total?.value || 0;
1009
1169
 
1010
1170
  if ( count === 0 ) {
@@ -1075,7 +1235,7 @@ export async function ticketList( req, res ) {
1075
1235
  reviewerRevisedAccuracy: item?.mappingInfo?.find( ( f ) => f.type === 'review' )?.revicedPerc || '--',
1076
1236
  approverRevisedAccuracy: item?.mappingInfo?.find( ( f ) => f.type === 'approve' )?.revicedPerc || '--',
1077
1237
  tangoRevisedAccuracy: item?.mappingInfo?.find( ( f ) => f.type === 'tangoreview' )?.revicedPerc || '--',
1078
- status: item?.status,
1238
+ status: item?.mappingInfo?.find( ( f ) => f.type === 'approve' )?.status || '--',
1079
1239
  tangoStatus: item?.mappingInfo?.find( ( f ) => f.type === 'tangoreview' )?.revicedPerc || '--',
1080
1240
  approvedBy: item?.mappingInfo?.find( ( f ) => f.type === 'approve' )?.createdByEmail || '--',
1081
1241
 
@@ -1383,90 +1543,89 @@ export async function getTickets( req, res ) {
1383
1543
  // If mappingInfo is an array, update revisedDetail for each mappingInfo object
1384
1544
  if ( Array.isArray( item._source.mappingInfo ) ) {
1385
1545
  item._source.mappingInfo.forEach( ( mappingObj ) => {
1386
- if ( mappingObj.status == 'In-Progress' ) {
1387
- commentsResponse = commentsRes?.body?.hits?.hits?.map( ( hit ) => hit._source ) || [];
1546
+ commentsResponse = commentsRes?.body?.hits?.hits?.map( ( hit ) => hit._source ) || [];
1388
1547
 
1389
- // Check if duplicate condition exists in commentsResponse
1548
+ // Check if duplicate condition exists in commentsResponse
1390
1549
 
1391
- // Structure comments output
1392
- let commentsDetails = [];
1550
+ // Structure comments output
1551
+ let commentsDetails = [];
1393
1552
 
1394
1553
 
1395
- const types = [ 'tagging', 'review', 'approve' ];
1554
+ const types = [ 'tagging', 'review', 'approve' ];
1396
1555
 
1397
- // Process each type
1398
- types.forEach( ( typeValue ) => {
1399
- if ( typeValue === 'tagging' ) {
1400
- // For tagging, group by category and create separate objects for each category
1401
- const taggingComments = commentsResponse.filter( ( c ) => c.type === typeValue );
1556
+ // Process each type
1557
+ types.forEach( ( typeValue ) => {
1558
+ if ( typeValue === 'tagging' ) {
1559
+ // For tagging, group by category and create separate objects for each category
1560
+ const taggingComments = commentsResponse.filter( ( c ) => c.type === typeValue );
1402
1561
 
1403
- // Group by category
1404
- const categoryGroups = {};
1405
- taggingComments.forEach( ( c ) => {
1406
- const category = c.category || 'other';
1407
- if ( !categoryGroups[category] ) {
1408
- categoryGroups[category] = [];
1562
+ // Group by category
1563
+ const categoryGroups = {};
1564
+ taggingComments.forEach( ( c ) => {
1565
+ const category = c.category || 'other';
1566
+ if ( !categoryGroups[category] ) {
1567
+ categoryGroups[category] = [];
1568
+ }
1569
+ categoryGroups[category].push( c );
1570
+ } );
1571
+
1572
+ // Create separate objects for each category
1573
+ Object.keys( categoryGroups ).forEach( ( category ) => {
1574
+ const categoryComments = categoryGroups[category];
1575
+ let parent = null;
1576
+
1577
+ const comms = categoryComments.map( ( c ) => {
1578
+ if ( category === 'duplicate' ) {
1579
+ if ( !parent && c.parent ) {
1580
+ parent = c.parent;
1581
+ }
1582
+ return {
1583
+ createdByEmail: c.createdByEmail,
1584
+ createdByUserName: c.createdByUserName,
1585
+ createdByRole: c.createdByRole,
1586
+ message: c.message,
1587
+ };
1588
+ } else {
1589
+ return {
1590
+ id: c.id,
1591
+ tempId: c.tempId,
1592
+ timeRange: c.timeRange,
1593
+ entryTime: c.entryTime,
1594
+ exitTime: c.exitTime,
1595
+ filePath: c.filePath,
1596
+ isChecked: c.isChecked,
1597
+ createdAt: c.createdAt,
1598
+ message: c.message,
1599
+ createdByEmail: c.createdByEmail,
1600
+ createdByUserName: c.createdByUserName,
1601
+ createdByRole: c.createdByRole,
1602
+ };
1409
1603
  }
1410
- categoryGroups[category].push( c );
1411
1604
  } );
1412
1605
 
1413
- // Create separate objects for each category
1414
- Object.keys( categoryGroups ).forEach( ( category ) => {
1415
- const categoryComments = categoryGroups[category];
1416
- let parent = null;
1606
+ const taggingObj = {
1607
+ category: category,
1608
+ type: typeValue,
1609
+ comments: comms,
1610
+ };
1417
1611
 
1418
- const comms = categoryComments.map( ( c ) => {
1419
- if ( category === 'duplicate' ) {
1420
- if ( !parent && c.parent ) {
1421
- parent = c.parent;
1422
- }
1423
- return {
1424
- createdByEmail: c.createdByEmail,
1425
- createdByUserName: c.createdByUserName,
1426
- createdByRole: c.createdByRole,
1427
- message: c.message,
1428
- };
1429
- } else {
1430
- return {
1431
- id: c.id,
1432
- tempId: c.tempId,
1433
- timeRange: c.timeRange,
1434
- entryTime: c.entryTime,
1435
- exitTime: c.exitTime,
1436
- filePath: c.filePath,
1437
- isChecked: c.isChecked,
1438
- createdAt: c.createdAt,
1439
- message: c.message,
1440
- createdByEmail: c.createdByEmail,
1441
- createdByUserName: c.createdByUserName,
1442
- createdByRole: c.createdByRole,
1443
- };
1444
- }
1445
- } );
1446
-
1447
- const taggingObj = {
1448
- category: category,
1449
- type: typeValue,
1450
- comments: comms,
1451
- };
1452
-
1453
- // Add parent only for duplicate category
1454
- if ( category === 'duplicate' && parent !== null ) {
1455
- taggingObj.parent = parent;
1456
- }
1612
+ // Add parent only for duplicate category
1613
+ if ( category === 'duplicate' && parent !== null ) {
1614
+ taggingObj.parent = parent;
1615
+ }
1457
1616
 
1458
- commentsDetails.push( taggingObj );
1459
- } );
1460
- } else if ( typeValue === 'review' || typeValue === 'approve' ) {
1461
- // For review and approve, keep existing structure
1462
- const comms = commentsResponse
1463
- .filter( ( c ) => c.type === typeValue )
1464
- .map( ( c ) => {
1465
- if ( c.category === 'duplicate' ) {
1466
- return {
1467
- parent: c?.taggedImages[0]?._source?.parent,
1468
- category: c.category,
1469
- taggedImages: Array.isArray( c.taggedImages ) ?
1617
+ commentsDetails.push( taggingObj );
1618
+ } );
1619
+ } else if ( typeValue === 'review' || typeValue === 'approve' ) {
1620
+ // For review and approve, keep existing structure
1621
+ const comms = commentsResponse
1622
+ .filter( ( c ) => c.type === typeValue )
1623
+ .map( ( c ) => {
1624
+ if ( c.category === 'duplicate' ) {
1625
+ return {
1626
+ parent: c?.taggedImages[0]?._source?.parent,
1627
+ category: c.category,
1628
+ taggedImages: Array.isArray( c.taggedImages ) ?
1470
1629
  c.taggedImages.map( ( img ) => ( {
1471
1630
  id: img?._source?.id,
1472
1631
  tempId: img?._source?.tempId,
@@ -1477,16 +1636,16 @@ export async function getTickets( req, res ) {
1477
1636
  isChecked: img?._source?.isChecked,
1478
1637
  } ) ) :
1479
1638
  [],
1480
- createdByEmail: c.createdByEmail,
1481
- createdByUserName: c.createdByUserName,
1482
- createdByRole: c.createdByRole,
1483
- status: c.status,
1484
- message: c.message,
1485
- };
1486
- } else {
1487
- return {
1488
- category: c.category,
1489
- taggedImages: Array.isArray( c.taggedImages ) ?
1639
+ createdByEmail: c.createdByEmail,
1640
+ createdByUserName: c.createdByUserName,
1641
+ createdByRole: c.createdByRole,
1642
+ status: c.status,
1643
+ message: c.message,
1644
+ };
1645
+ } else {
1646
+ return {
1647
+ category: c.category,
1648
+ taggedImages: Array.isArray( c.taggedImages ) ?
1490
1649
  c.taggedImages.map( ( img ) => ( {
1491
1650
  id: img?._source?.id,
1492
1651
  tempId: img?._source?.tempId,
@@ -1497,34 +1656,34 @@ export async function getTickets( req, res ) {
1497
1656
  isChecked: img?._source?.isChecked,
1498
1657
  } ) ) :
1499
1658
  [],
1500
- createdByEmail: c.createdByEmail,
1501
- createdByUserName: c.createdByUserName,
1502
- createdByRole: c.createdByRole,
1503
- status: c.status,
1504
- message: c.message,
1505
- };
1506
- }
1507
- } );
1508
-
1509
- // Only add if there are comments
1510
- if ( comms.length > 0 ) {
1511
- commentsDetails.push( {
1512
- type: typeValue,
1513
- comments: comms,
1514
- } );
1515
- } else {
1516
- // Add empty comments array if no comments
1517
- commentsDetails.push( {
1518
- type: typeValue,
1519
- comments: [],
1659
+ createdByEmail: c.createdByEmail,
1660
+ createdByUserName: c.createdByUserName,
1661
+ createdByRole: c.createdByRole,
1662
+ status: c.status,
1663
+ message: c.message,
1664
+ };
1665
+ }
1520
1666
  } );
1521
- }
1667
+
1668
+ // Only add if there are comments
1669
+ if ( comms.length > 0 ) {
1670
+ commentsDetails.push( {
1671
+ type: typeValue,
1672
+ comments: comms,
1673
+ } );
1674
+ } else {
1675
+ // Add empty comments array if no comments
1676
+ commentsDetails.push( {
1677
+ type: typeValue,
1678
+ comments: [],
1679
+ } );
1522
1680
  }
1523
- } );
1681
+ }
1682
+ } );
1524
1683
 
1525
1684
 
1526
- item._source.commentsDetails = commentsDetails;
1527
- }
1685
+ item._source.commentsDetails = commentsDetails;
1686
+
1528
1687
  if (
1529
1688
  Object.prototype.hasOwnProperty.call( mappingObj, 'revisedDetail' ) &&
1530
1689
  mappingObj.type !== 'tangoreview'
@@ -2297,7 +2456,6 @@ export async function downloadTickets( req, res ) {
2297
2456
  }
2298
2457
 
2299
2458
  async function extractTempIds( document ) {
2300
- logger.info( { document: document } );
2301
2459
  const source = document?._source || {};
2302
2460
  const result = [];
2303
2461
 
@@ -2417,7 +2575,6 @@ export async function openTicketList( req, res ) {
2417
2575
 
2418
2576
  // Assuming getOpenSearchData and openSearch.footfallDirectoryTagging are available
2419
2577
  const result = await getOpenSearchData( openSearch.footfallDirectory, openSearchQuery );
2420
- logger.info( { result } );
2421
2578
  const getUserlist = result?.body?.hits?.hits?.map( ( hit ) => hit._source ) || [];
2422
2579
  return res.sendSuccess( getUserlist || [] );
2423
2580
  } catch ( error ) {
@@ -2432,8 +2589,7 @@ export async function assignTicket( req, res ) {
2432
2589
  const inputData = req.body;
2433
2590
  const openSearch = JSON.parse( process.env.OPENSEARCH );
2434
2591
 
2435
- const { email, userName, role, actionType, storeId, dateString } = inputData;
2436
- logger.info( { actionType } );
2592
+ const { email, userName, role, storeId, dateString } = inputData;
2437
2593
  const _id = `${storeId}_${dateString}_footfall-directory-tagging`;
2438
2594
 
2439
2595
  const getTicket = await getOpenSearchById( openSearch.footfallDirectory, _id );
@@ -143,7 +143,7 @@ export const ticketListSchema = Joi.object().keys( {
143
143
  offset: Joi.number().optional(),
144
144
  isExport: Joi.boolean().optional(),
145
145
  sortBy: Joi.string().optional().allow( '' ),
146
- status: Joi.array().items( Joi.string().required() ).optional(),
146
+ status: Joi.string().optional(),
147
147
  sortOrder: Joi.number().valid( -1, 1 ).optional(),
148
148
  tangoType: Joi.string().valid( 'store', 'internal', '' ).optional(),
149
149
  permissionType: Joi.string().valid( 'review', 'approve' ).optional(),
@@ -513,12 +513,13 @@ export async function ticketCreation( req, res, next ) {
513
513
  count: tempAcc,
514
514
  revisedDetail: formattedTaggingData,
515
515
  status: 'Open',
516
+
516
517
  };
517
518
  } else if ( r.actionType === 'approver' && r.isChecked === true ) {
518
519
  approverMapping = {
519
520
  type: 'approve',
520
- revicedFootfall: revisedFootfall,
521
- revicedPerc: Math.round( ( revisedFootfall / footfallCount ) * 100 || 0 ) + '%',
521
+ // revicedFootfall: revisedFootfall,
522
+ // revicedPerc: Math.round( ( revisedFootfall / footfallCount ) * 100 || 0 ) + '%',
522
523
  count: tempAcc,
523
524
  revisedDetail: formattedTaggingData,
524
525
  status: 'Open',
@@ -601,7 +602,6 @@ export async function ticketCreation( req, res, next ) {
601
602
  if ( !ticketsFeature ) return;
602
603
 
603
604
  const notifyUser = await getAssinedStore( userData, req.body.storeId );
604
-
605
605
  if ( !notifyUser || !userData?.fcmToken ) return;
606
606
 
607
607
  await sendPushNotification( title, description, userData.fcmToken, Data );
@@ -1083,9 +1083,9 @@ export async function ticketReview( req, res, next ) {
1083
1083
  revicedFootfall: revisedFootfall,
1084
1084
  revicedPerc: Math.round( ( revisedFootfall / footfallCount ) * 100 || 0 ) + '%',
1085
1085
  mappingInfo: ticketData?.[0]?._source?.mappingInfo,
1086
- createdByEmail: req?.user?.email,
1087
- createdByUserName: req?.user?.userName,
1088
- createdByRole: req?.user?.role,
1086
+ // createdByEmail: req?.user?.email,
1087
+ // createdByUserName: req?.user?.userName,
1088
+ // createdByRole: req?.user?.role,
1089
1089
 
1090
1090
  };
1091
1091
 
@@ -1163,14 +1163,14 @@ export async function ticketReview( req, res, next ) {
1163
1163
  .map( ( item ) => ( {
1164
1164
  ...item,
1165
1165
  mode: inputData.mode,
1166
- revicedFootfall: revisedFootfall,
1167
- revicedPerc: Math.round( ( revisedFootfall / footfallCount ) * 100 || 0 ) + '%',
1168
- count: tempAcc,
1169
- revisedDetail: formattedTaggingData,
1166
+ // revicedFootfall: revisedFootfall,
1167
+ // revicedPerc: Math.round( ( revisedFootfall / footfallCount ) * 100 || 0 ) + '%',
1168
+ // count: tempAcc,
1169
+ // revisedDetail: formattedTaggingData,
1170
1170
  status: 'Closed',
1171
- createdByEmail: req?.user?.email,
1172
- createdByUserName: req?.user?.userName,
1173
- createdByRole: req?.user?.role,
1171
+ // createdByEmail: req?.user?.email,
1172
+ // createdByUserName: req?.user?.userName,
1173
+ // createdByRole: req?.user?.role,
1174
1174
  } ) );
1175
1175
  record.mappingInfo = [ ...temp2, ...temp ];
1176
1176
  // If no review mapping existed, push a new one
@@ -1534,9 +1534,9 @@ export async function ticketApprove( req, res, next ) {
1534
1534
  revicedFootfall: revisedFootfall,
1535
1535
  revicedPerc: Math.round( ( revisedFootfall / footfallCount ) * 100 || 0 ) + '%',
1536
1536
  mappingInfo: ticketData?.[0]?._source?.mappingInfo,
1537
- createdByEmail: req?.user?.email,
1538
- createdByUserName: req?.user?.userName,
1539
- createdByRole: req?.user?.role,
1537
+ // createdByEmail: req?.user?.email,
1538
+ // createdByUserName: req?.user?.userName,
1539
+ // createdByRole: req?.user?.role,
1540
1540
 
1541
1541
  };
1542
1542