tango-app-api-infra 3.9.5-vms.77 → 3.9.5-vms.79

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.
@@ -86,7 +86,8 @@ export const tangoReviewAccuracyClosedTicketValid = {
86
86
 
87
87
  export const ticketSummarySchema = Joi.object().keys( {
88
88
  clientId: Joi.string().required(),
89
-
89
+ tangoType: Joi.string().valid( 'store', 'internal' ).optional(),
90
+ permissionType: Joi.string().valid( 'approve', 'review' ).optional(),
90
91
  fromDate: Joi.string()
91
92
  .pattern( /^\d{4}-\d{2}-\d{2}$/, 'YYYY-MM-DD format' )
92
93
  .required()
@@ -159,6 +160,7 @@ export const ticketListSchema = Joi.object().keys( {
159
160
  tangoType: Joi.string().valid( 'store', 'internal', '' ).optional(),
160
161
  permissionType: Joi.string().valid( 'review', 'approve' ).optional(),
161
162
  filterByStatus: Joi.string().optional().allow( '' ),
163
+ filterByStore: Joi.string().optional().allow( '' ),
162
164
  filterByReviewer: Joi.string().optional().allow( '' ),
163
165
  filterByApprover: Joi.string().optional().allow( '' ),
164
166
  filterByTango: Joi.string().optional().allow( '' ),
@@ -527,7 +529,8 @@ export const openTicketListSchema = Joi.object().keys( {
527
529
  Joi.string().required(),
528
530
  ).required(),
529
531
  type: Joi.string().required().allow( 'review', 'approve' ),
530
- sortOrder: Joi.number().allow( 1, -1 ).optional(),
532
+ sortOrder: Joi.number().valid( 1, -1 ).optional(),
533
+ searchValue: Joi.string().allow( '' ).optional(),
531
534
 
532
535
 
533
536
  } );
@@ -513,6 +513,7 @@ export async function ticketCreation( req, res, next ) {
513
513
  count: tempAcc,
514
514
  revisedDetail: formattedTaggingData,
515
515
  status: 'Open',
516
+ dueDate: new Date( Date.now() + 3 * 24 * 60 * 60 * 1000 ), // Current date plus 3 days
516
517
 
517
518
  };
518
519
  } else if ( r.actionType === 'approver' && r.isChecked === true ) {
@@ -523,6 +524,7 @@ export async function ticketCreation( req, res, next ) {
523
524
  count: tempAcc,
524
525
  revisedDetail: formattedTaggingData,
525
526
  status: 'Open',
527
+ dueDate: new Date( Date.now() + 4 * 24 * 60 * 60 * 1000 ), // Current date plus 3 days
526
528
  };
527
529
  } else if ( r.actionType === 'tango' && r.isChecked === true ) {
528
530
  tangoReviewMapping = {
@@ -532,6 +534,7 @@ export async function ticketCreation( req, res, next ) {
532
534
  count: tempAcc,
533
535
  revisedDetail: formattedTaggingData,
534
536
  status: 'Open',
537
+ dueDate: new Date( Date.now() + 4 * 24 * 60 * 60 * 1000 ), // Current date plus 3 days
535
538
  };
536
539
  }
537
540
  }
@@ -1228,6 +1231,7 @@ export async function ticketReview( req, res, next ) {
1228
1231
  count: tempAcc,
1229
1232
  revisedDetail: formattedTaggingData,
1230
1233
  status: 'Open',
1234
+ dueDate: new Date( Date.now() + 4 * 24 * 60 * 60 * 1000 ), // Current date plus 3 days
1231
1235
  };
1232
1236
  } else if ( r.actionType === 'tango' && r.isChecked === true ) {
1233
1237
  tangoReviewMapping = {
@@ -1237,6 +1241,7 @@ export async function ticketReview( req, res, next ) {
1237
1241
  count: tempAcc,
1238
1242
  revisedDetail: formattedTaggingData,
1239
1243
  status: 'Open',
1244
+ dueDate: new Date( Date.now() + 4 * 24 * 60 * 60 * 1000 ), // Current date plus 3 days
1240
1245
  };
1241
1246
  }
1242
1247
  }
@@ -1302,6 +1307,85 @@ export async function ticketReview( req, res, next ) {
1302
1307
  const insertResult = await updateOpenSearchData( openSearch.footfallDirectory, id, { doc: record } );
1303
1308
 
1304
1309
  if ( insertResult && insertResult.statusCode === 201 || insertResult.statusCode === 200 ) {
1310
+ if ( record.status = 'Closed' ) {
1311
+ const query = {
1312
+ storeId: inputData?.storeId,
1313
+ isVideoStream: true,
1314
+ };
1315
+ const getStoreType = await countDocumnetsCamera( query );
1316
+ const revopInfoQuery = {
1317
+ size: 10000,
1318
+ query: {
1319
+ bool: {
1320
+ must: [
1321
+ {
1322
+ term: {
1323
+ 'storeId.keyword': inputData.storeId,
1324
+ },
1325
+ },
1326
+ {
1327
+ term: {
1328
+ 'dateString': inputData.dateString,
1329
+ },
1330
+ },
1331
+ {
1332
+ term: {
1333
+ 'isParent': false,
1334
+ },
1335
+ },
1336
+ {
1337
+ term: {
1338
+ isChecked: true,
1339
+ },
1340
+ },
1341
+ ],
1342
+ },
1343
+ },
1344
+ _source: [ 'tempId' ],
1345
+
1346
+ };
1347
+ const revopInfo = await getOpenSearchData( openSearch.revop, revopInfoQuery );
1348
+ // Get all tempIds from revopInfo response
1349
+ const tempIds = revopInfo?.body?.hits?.hits?.map( ( hit ) => hit?._source?.tempId ).filter( Boolean ) || [];
1350
+ // Prepare management eyeZone query based on storeId and dateString
1351
+ const managerEyeZoneQuery = {
1352
+ size: 1,
1353
+ query: {
1354
+ bool: {
1355
+ must: [
1356
+ {
1357
+ term: {
1358
+ 'storeId.keyword': inputData.storeId,
1359
+ },
1360
+ },
1361
+ {
1362
+ term: {
1363
+ 'storeDate': inputData.dateString,
1364
+ },
1365
+ },
1366
+ ],
1367
+ },
1368
+ },
1369
+ _source: [ 'originalToTrackerCustomerMapping' ],
1370
+ };
1371
+
1372
+ // Query the managerEyeZone index for the matching document
1373
+ const managerEyeZoneResp = await getOpenSearchData( openSearch.managerEyeZone, managerEyeZoneQuery );
1374
+ const managerEyeZoneHit = managerEyeZoneResp?.body?.hits?.hits?.[0]?._source;
1375
+ // Extract originalToTrackerCustomerMapping if it exists
1376
+ const mapping =
1377
+ managerEyeZoneHit && managerEyeZoneHit.originalToTrackerCustomerMapping ?
1378
+ managerEyeZoneHit.originalToTrackerCustomerMapping :
1379
+ {};
1380
+
1381
+ // Find tempIds that exist in both revopInfo results and manager mapping
1382
+ const temp = [];
1383
+ tempIds.filter( ( tid ) => mapping[tid] !== null ? temp.push( { tempId: mapping[tid] } ) :'' );
1384
+ const isSendMessge = await sendSqsMessage( inputData, temp, getStoreType, inputData.storeId );
1385
+ if ( isSendMessge == true ) {
1386
+ logger.info( '....1' );
1387
+ }
1388
+ }
1305
1389
  return res.sendSuccess( 'Ticket closed successfully' );
1306
1390
  } else {
1307
1391
  return res.sendError( 'Internal Server Error', 500 );
@@ -1647,14 +1731,7 @@ export async function ticketApprove( req, res, next ) {
1647
1731
 
1648
1732
  record.mappingInfo = [ ...ticketData?.[0]?._source?.mappingInfo.slice( 0, -1 ),
1649
1733
  ...temp ];
1650
- // if ( Array.isArray( record.mappingInfo ) ) {
1651
- // record.mappingInfo = record.mappingInfo.map( ( item ) => {
1652
- // return {
1653
- // ...item,
1654
- // status: 'Closed',
1655
- // };
1656
- // } );
1657
- // }
1734
+
1658
1735
  // If no review mapping existed, push a new one
1659
1736
  if ( record.mappingInfo.length === 0 ) {
1660
1737
  record.mappingInfo.push( {
@@ -1683,6 +1760,7 @@ export async function ticketApprove( req, res, next ) {
1683
1760
  count: tempAcc,
1684
1761
  revisedDetail: formattedTaggingData,
1685
1762
  status: 'Open',
1763
+ dueDate: new Date( Date.now() + 4 * 24 * 60 * 60 * 1000 ), // Current date plus 3 days
1686
1764
  };
1687
1765
  // }
1688
1766
  // }
@@ -1803,6 +1881,85 @@ export async function ticketApprove( req, res, next ) {
1803
1881
 
1804
1882
 
1805
1883
  if ( insertResult && ( insertResult.statusCode === 201 || insertResult.statusCode === 200 ) ) {
1884
+ if ( record.status = 'Closed' ) {
1885
+ const query = {
1886
+ storeId: inputData?.storeId,
1887
+ isVideoStream: true,
1888
+ };
1889
+ const getStoreType = await countDocumnetsCamera( query );
1890
+ const revopInfoQuery = {
1891
+ size: 10000,
1892
+ query: {
1893
+ bool: {
1894
+ must: [
1895
+ {
1896
+ term: {
1897
+ 'storeId.keyword': inputData.storeId,
1898
+ },
1899
+ },
1900
+ {
1901
+ term: {
1902
+ 'dateString': inputData.dateString,
1903
+ },
1904
+ },
1905
+ {
1906
+ term: {
1907
+ 'isParent': false,
1908
+ },
1909
+ },
1910
+ {
1911
+ term: {
1912
+ isChecked: true,
1913
+ },
1914
+ },
1915
+ ],
1916
+ },
1917
+ },
1918
+ _source: [ 'tempId' ],
1919
+
1920
+ };
1921
+ const revopInfo = await getOpenSearchData( openSearch.revop, revopInfoQuery );
1922
+ // Get all tempIds from revopInfo response
1923
+ const tempIds = revopInfo?.body?.hits?.hits?.map( ( hit ) => hit?._source?.tempId ).filter( Boolean ) || [];
1924
+ // Prepare management eyeZone query based on storeId and dateString
1925
+ const managerEyeZoneQuery = {
1926
+ size: 1,
1927
+ query: {
1928
+ bool: {
1929
+ must: [
1930
+ {
1931
+ term: {
1932
+ 'storeId.keyword': inputData.storeId,
1933
+ },
1934
+ },
1935
+ {
1936
+ term: {
1937
+ 'storeDate': inputData.dateString,
1938
+ },
1939
+ },
1940
+ ],
1941
+ },
1942
+ },
1943
+ _source: [ 'originalToTrackerCustomerMapping' ],
1944
+ };
1945
+
1946
+ // Query the managerEyeZone index for the matching document
1947
+ const managerEyeZoneResp = await getOpenSearchData( openSearch.managerEyeZone, managerEyeZoneQuery );
1948
+ const managerEyeZoneHit = managerEyeZoneResp?.body?.hits?.hits?.[0]?._source;
1949
+ // Extract originalToTrackerCustomerMapping if it exists
1950
+ const mapping =
1951
+ managerEyeZoneHit && managerEyeZoneHit.originalToTrackerCustomerMapping ?
1952
+ managerEyeZoneHit.originalToTrackerCustomerMapping :
1953
+ {};
1954
+
1955
+ // Find tempIds that exist in both revopInfo results and manager mapping
1956
+ const temp = [];
1957
+ tempIds.filter( ( tid ) => mapping[tid] !== null ? temp.push( { tempId: mapping[tid] } ) :'' );
1958
+ const isSendMessge = await sendSqsMessage( inputData, temp, getStoreType, inputData.storeId );
1959
+ if ( isSendMessge == true ) {
1960
+ logger.info( '....1' );
1961
+ }
1962
+ }
1806
1963
  return res.sendSuccess( 'Ticket closed successfully' );
1807
1964
  } else {
1808
1965
  return res.sendError( 'Internal Server Error', 500 );