tango-app-api-infra 3.9.5-vms.63 → 3.9.5-vms.65

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-infra",
3
- "version": "3.9.5-vms.63",
3
+ "version": "3.9.5-vms.65",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1387,101 +1387,116 @@ export async function getTickets( req, res ) {
1387
1387
  commentsResponse = commentsRes?.body?.hits?.hits?.map( ( hit ) => hit._source ) || [];
1388
1388
 
1389
1389
  // Check if duplicate condition exists in commentsResponse
1390
- const isDuplicate = Array.isArray( commentsResponse ) &&
1391
- commentsResponse.some( ( c ) => c.category === 'duplicate' );
1392
1390
 
1393
1391
  // Structure comments output
1394
1392
  let commentsDetails = [];
1395
- if ( isDuplicate ) {
1396
- // Duplicate case - check from commentsResponse
1397
- // Collect for each type (tagging, review, approve)
1398
- const types = [ 'tagging', 'review', 'approve' ];
1399
- commentsDetails = types.map( ( typeValue ) => {
1400
- // parent value from original comment structure
1401
- let parent = null;
1402
- // Get all comments of this type (no filter by category)
1403
- let comms = commentsResponse
1404
- .filter( ( c ) => c.type === typeValue )
1405
- .map( ( c ) => {
1406
- if ( typeValue === 'tagging' ) {
1393
+
1394
+
1395
+ const types = [ 'tagging', 'review', 'approve' ];
1396
+
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 );
1402
+
1403
+ // Group by category
1404
+ const categoryGroups = {};
1405
+ taggingComments.forEach( ( c ) => {
1406
+ const category = c.category || 'other';
1407
+ if ( !categoryGroups[category] ) {
1408
+ categoryGroups[category] = [];
1409
+ }
1410
+ categoryGroups[category].push( c );
1411
+ } );
1412
+
1413
+ // Create separate objects for each category
1414
+ Object.keys( categoryGroups ).forEach( ( category ) => {
1415
+ const categoryComments = categoryGroups[category];
1416
+ let parent = null;
1417
+
1418
+ const comms = categoryComments.map( ( c ) => {
1419
+ if ( category === 'duplicate' ) {
1420
+ if ( !parent && c.parent ) {
1407
1421
  parent = c.parent;
1408
- return {
1409
- createdByEmail: c.createdByEmail,
1410
- createdByUserName: c.createdByUserName,
1411
- createdByRole: c.createdByRole,
1412
- message: c.message,
1413
- };
1414
1422
  }
1415
- if ( typeValue === 'review' || typeValue === 'approve' ) {
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
+ }
1457
+
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' ) {
1416
1466
  return {
1417
- parent: c.parent,
1467
+ parent: c?.taggedImages[0]?._source?.parent,
1418
1468
  category: c.category,
1419
1469
  taggedImages: Array.isArray( c.taggedImages ) ?
1420
- c.taggedImages.map( ( img ) => ( {
1421
- id: img?._source?.id,
1422
- tempId: img?._source?.tempId,
1423
- timeRange: img?._source?.timeRange,
1424
- entryTime: img?._source?.entryTime,
1425
- exitTime: img?._source?.exitTime,
1426
- filePath: img?._source?.filePath,
1427
- isChecked: img?._source?.isChecked,
1428
- } ) ) :
1429
- [],
1470
+ c.taggedImages.map( ( img ) => ( {
1471
+ id: img?._source?.id,
1472
+ tempId: img?._source?.tempId,
1473
+ timeRange: img?._source?.timeRange,
1474
+ entryTime: img?._source?.entryTime,
1475
+ exitTime: img?._source?.exitTime,
1476
+ filePath: img?._source?.filePath,
1477
+ isChecked: img?._source?.isChecked,
1478
+ } ) ) :
1479
+ [],
1430
1480
  createdByEmail: c.createdByEmail,
1431
1481
  createdByUserName: c.createdByUserName,
1432
1482
  createdByRole: c.createdByRole,
1433
1483
  status: c.status,
1434
1484
  message: c.message,
1435
1485
  };
1436
- }
1437
- return {};
1438
- } );
1439
- return {
1440
- ...( typeValue === 'tagging' ? { category: 'duplicate' } : {} ),
1441
- type: typeValue,
1442
- ...( typeValue === 'tagging' ? { parent } : {} ),
1443
- comments: comms,
1444
- };
1445
- } );
1446
- } else {
1447
- // For non-duplicate categories
1448
- // Collect by type/tag (tagging/review/approve) and build similar structure
1449
- const types = [ 'tagging', 'review', 'approve' ];
1450
- commentsDetails = types.map( ( typeValue ) => {
1451
- // parent for these non-duplicate is always null
1452
- let comms = commentsResponse
1453
- .filter( ( c ) => c.type === typeValue )
1454
- .map( ( c ) => {
1455
- if ( typeValue === 'tagging' ) {
1456
- return {
1457
- id: c.id,
1458
- tempId: c.tempId,
1459
- timeRange: c.timeRange,
1460
- entryTime: c.entryTime,
1461
- exitTime: c.exitTime,
1462
- filePath: c.filePath,
1463
- isChecked: c.isChecked,
1464
- createdAt: c.createdAt,
1465
- message: c.message,
1466
- createdByEmail: c.createdByEmail,
1467
- createdByUserName: c.createdByUserName,
1468
- createdByRole: c.createdByRole,
1469
- };
1470
- }
1471
- if ( typeValue === 'review' || typeValue === 'approve' ) {
1486
+ } else {
1472
1487
  return {
1473
1488
  category: c.category,
1474
1489
  taggedImages: Array.isArray( c.taggedImages ) ?
1475
- c.taggedImages.map( ( img ) => ( {
1476
- id: img?._source?.id,
1477
- tempId: img?._source?.tempId,
1478
- timeRange: img?._source?.timeRange,
1479
- entryTime: img?._source?.entryTime,
1480
- exitTime: img?._source?.exitTime,
1481
- filePath: img?._source?.filePath,
1482
- isChecked: img?._source?.isChecked,
1483
- } ) ) :
1484
- [],
1490
+ c.taggedImages.map( ( img ) => ( {
1491
+ id: img?._source?.id,
1492
+ tempId: img?._source?.tempId,
1493
+ timeRange: img?._source?.timeRange,
1494
+ entryTime: img?._source?.entryTime,
1495
+ exitTime: img?._source?.exitTime,
1496
+ filePath: img?._source?.filePath,
1497
+ isChecked: img?._source?.isChecked,
1498
+ } ) ) :
1499
+ [],
1485
1500
  createdByEmail: c.createdByEmail,
1486
1501
  createdByUserName: c.createdByUserName,
1487
1502
  createdByRole: c.createdByRole,
@@ -1489,16 +1504,24 @@ export async function getTickets( req, res ) {
1489
1504
  message: c.message,
1490
1505
  };
1491
1506
  }
1492
- return {};
1493
1507
  } );
1494
- return {
1495
- ...( typeValue === 'tagging' ? { category: 'duplicate' } : {} ),
1496
- parent: null,
1497
- type: typeValue,
1498
- comments: comms,
1499
- };
1500
- } );
1501
- }
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: [],
1520
+ } );
1521
+ }
1522
+ }
1523
+ } );
1524
+
1502
1525
 
1503
1526
  item._source.commentsDetails = commentsDetails;
1504
1527
  }
@@ -564,11 +564,13 @@ export async function ticketCreation( req, res, next ) {
564
564
  $match: {
565
565
  clientId: getstoreName.clientId,
566
566
  role: 'admin',
567
+ isActive: true,
567
568
  },
568
569
  },
569
570
  ];
570
571
 
571
572
  const finduserList = await aggregateUser( userQuery );
573
+ console.log( '🚀 ~ ticketCreation ~ finduserList:', finduserList.length );
572
574
 
573
575
  const createdOn = dayjs().format( 'DD MMM YYYY' );
574
576
  const title = `${getstoreName?.storeName} Have raised a ticket for a Footfall Mismatch`;
@@ -594,10 +596,12 @@ export async function ticketCreation( req, res, next ) {
594
596
  m.name === 'reviewer' && ( m.isAdd === true || m.isEdit === true ),
595
597
  ),
596
598
  );
599
+ console.log( '🚀 ~ ticketCreation ~ ticketsFeature:', ticketsFeature );
597
600
 
598
601
  if ( !ticketsFeature ) return;
599
602
 
600
603
  const notifyUser = await getAssinedStore( userData, req.body.storeId );
604
+ console.log( '🚀 ~ ticketCreation ~ notifyUser:', notifyUser );
601
605
  if ( !notifyUser || !userData?.fcmToken ) return;
602
606
 
603
607
  await sendPushNotification( title, description, userData.fcmToken, Data );
@@ -1260,11 +1264,12 @@ export async function ticketReview( req, res, next ) {
1260
1264
  $match: {
1261
1265
  clientId: getstoreName.clientId,
1262
1266
  role: 'admin',
1267
+ isActive: true,
1263
1268
  },
1264
1269
  },
1265
1270
  ];
1266
1271
  let finduserList = await aggregateUser( userQuery );
1267
- console.log( '🚀 ~ ticketReview ~ finduserList:', finduserList );
1272
+ console.log( '🚀 ~ ticketReview ~ finduserList:', finduserList.length );
1268
1273
 
1269
1274
  // return;
1270
1275
  for ( let userData of finduserList ) {
@@ -1759,6 +1764,7 @@ export async function ticketApprove( req, res, next ) {
1759
1764
  $match: {
1760
1765
  clientId: getstoreName.clientId,
1761
1766
  role: 'admin',
1767
+ isActive: true,
1762
1768
  },
1763
1769
  },
1764
1770
  ];