tango-app-api-infra 3.9.5-vms.73 → 3.9.5-vms.75

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.73",
3
+ "version": "3.9.5-vms.75",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -265,25 +265,10 @@ export async function tangoReviewTicket( req, res ) {
265
265
  record.mappingInfo = record.mappingInfo.map( ( item ) => {
266
266
  return {
267
267
  ...item,
268
- status: 'Closed',
268
+ status: item.type === 'approve'? 'Tango Review Done':'Closed',
269
269
  };
270
270
  } );
271
271
  }
272
- // If no review mapping existed, push a new one
273
- // if ( record.mappingInfo.length === 0 ) {
274
- // record.mappingInfo.push( {
275
- // type: 'tangoreview',
276
- // mode: inputData.mappingInfo?.mode,
277
- // revicedFootfall: inputData.mappingInfo?.revicedFootfall,
278
- // revicedPerc: inputData.mappingInfo?.revicedPerc,
279
- // count: inputData.mappingInfo?.count,
280
- // revisedDetail: inputData.mappingInfo?.revisedDetail,
281
- // status: 'Closed',
282
- // createdByEmail: req?.user?.email,
283
- // createdByUserName: req?.user?.userName,
284
- // createdByRole: req?.user?.role,
285
- // } );
286
- // }
287
272
  }
288
273
  record.mappingInfo.push(
289
274
  {
@@ -323,29 +308,6 @@ export async function tangoReviewTicket( req, res ) {
323
308
 
324
309
  record.mappingInfo = [ ...ticketData?.[0]?._source?.mappingInfo.slice( 0, -1 ),
325
310
  ...temp ];
326
- // if ( Array.isArray( record.mappingInfo ) ) {
327
- // record.mappingInfo = record.mappingInfo.map( ( item ) => {
328
- // return {
329
- // ...item,
330
- // status: 'Closed',
331
- // };
332
- // } );
333
- // }
334
- // If no review mapping existed, push a new one
335
- // if ( record.mappingInfo.length === 0 ) {
336
- // record.mappingInfo.push( {
337
- // type: 'tangoreview',
338
- // mode: inputData.mappingInfo?.mode,
339
- // revicedFootfall: inputData.mappingInfo?.revicedFootfall,
340
- // revicedPerc: inputData.mappingInfo?.revicedPerc,
341
- // count: inputData.mappingInfo?.count,
342
- // revisedDetail: inputData.mappingInfo?.revisedDetail,
343
- // status: 'Closed',
344
- // createdByEmail: req?.user?.email,
345
- // createdByUserName: req?.user?.userName,
346
- // createdByRole: req?.user?.role,
347
- // } );
348
- // }
349
311
  }
350
312
  } else {
351
313
  if ( Array.isArray( record.mappingInfo ) ) {
@@ -370,25 +332,10 @@ export async function tangoReviewTicket( req, res ) {
370
332
  record.mappingInfo = record.mappingInfo.map( ( item ) => {
371
333
  return {
372
334
  ...item,
373
- status: 'Closed',
335
+ status: item.type === 'approve'?'Tango Review Done': 'Closed',
374
336
  };
375
337
  } );
376
338
  }
377
- // If no review mapping existed, push a new one
378
- // if ( record.mappingInfo.length === 0 ) {
379
- // record.mappingInfo.push( {
380
- // type: 'tangoreview',
381
- // mode: inputData.mappingInfo?.mode,
382
- // revicedFootfall: inputData.mappingInfo?.revicedFootfall,
383
- // revicedPerc: inputData.mappingInfo?.revicedPerc,
384
- // count: inputData.mappingInfo?.count,
385
- // revisedDetail: inputData.mappingInfo?.revisedDetail,
386
- // status: 'Closed',
387
- // createdByEmail: req?.user?.email,
388
- // createdByUserName: req?.user?.userName,
389
- // createdByRole: req?.user?.role,
390
- // } );
391
- // }
392
339
  }
393
340
  record.mappingInfo.push(
394
341
  {
@@ -774,7 +721,7 @@ export async function ticketSummary( req, res ) {
774
721
  let result = '';
775
722
  const userInfo = req.user;
776
723
  const ticketsFeature = userInfo?.rolespermission?.some( ( f ) => f.featureName === 'FootfallDirectory' && ( f.modules.find( ( m ) => m.name == 'reviewer' && ( m.isAdd == true || m.isEdit == true ) ) ) );
777
-
724
+ // const ticketsApproveFeature = userInfo?.rolespermission?.some( ( f ) => f.featureName === 'FootfallDirectory' && ( f.modules.find( ( m ) => m.name == 'approver' && ( m.isAdd == true || m.isEdit == true ) ) ) );
778
725
  if ( req.user.userType == 'tango' ) {
779
726
  result = {
780
727
  totalTickets: 0,
@@ -1090,10 +1037,7 @@ export async function ticketList( req, res ) {
1090
1037
  if ( inputData.sortBy ) {
1091
1038
  let sortOrder = inputData.sortOrder === 1 ? 'asc' : 'desc';
1092
1039
 
1093
- // Remove default sort so we don't duplicate/conflict
1094
- // INSERT_YOUR_CODE
1095
- // If sortBy is present, check if the field needs ".keyword" (for string fields like storeName, storeId, ticketId)
1096
- // This avoids OpenSearch errors about sorting on text fields.
1040
+
1097
1041
  const stringKeywordFields = [ 'storeName', 'storeId', 'ticketId', 'status', 'type', 'clientId' ];
1098
1042
  let sortField = inputData.sortBy == 'footfall' ? 'footfallCount' : inputData.sortBy == 'issueDate' ? 'dateString' : inputData.sortBy;
1099
1043
  if ( stringKeywordFields.includes( sortField ) ) {
@@ -1217,6 +1161,160 @@ export async function ticketList( req, res ) {
1217
1161
  }
1218
1162
  }
1219
1163
 
1164
+ if ( inputData.filterByStatus && inputData.filterByStatus!=='' ) {
1165
+ if ( req?.user?.userType == 'tango' ) {
1166
+ {
1167
+ switch ( inputData?.tangoType ) {
1168
+ case 'store':
1169
+ searchQuery.query.bool.must.push( {
1170
+ nested: {
1171
+ path: 'mappingInfo',
1172
+ query: {
1173
+ bool: {
1174
+ must: [
1175
+ {
1176
+ term: {
1177
+ 'mappingInfo.type': 'tangoreview',
1178
+ },
1179
+ },
1180
+ {
1181
+ terms: {
1182
+ 'mappingInfo.status': inputData?.filterByStatus,
1183
+ },
1184
+ },
1185
+ ],
1186
+ },
1187
+ },
1188
+ },
1189
+ } );
1190
+ break;
1191
+ case 'internal':
1192
+ searchQuery.query.bool.must.push( {
1193
+ 'terms': {
1194
+ 'status': Array.isArray( inputData?.filterByStatus ) ?
1195
+ inputData?.filterByStatus :
1196
+ [ inputData?.filterByStatus ],
1197
+ },
1198
+ } );
1199
+ break;
1200
+ defaut:
1201
+ searchQuery.query.bool.must.push( {
1202
+ nested: {
1203
+ path: 'mappingInfo',
1204
+ query: {
1205
+ bool: {
1206
+ must: [
1207
+ {
1208
+ term: {
1209
+ 'mappingInfo.type': 'tangoreview',
1210
+ },
1211
+ },
1212
+ {
1213
+ terms: {
1214
+ 'mappingInfo.status': inputData?.filterByStatus,
1215
+ },
1216
+ },
1217
+ ],
1218
+ },
1219
+ },
1220
+ },
1221
+ } );
1222
+ }
1223
+ }
1224
+ } else if ( ticketsFeature && !ticketsApproveFeature ) {
1225
+ searchQuery.query.bool.must.push( {
1226
+ nested: {
1227
+ path: 'mappingInfo',
1228
+ query: {
1229
+ bool: {
1230
+ must: [
1231
+ {
1232
+ term: {
1233
+ 'mappingInfo.type': 'review',
1234
+ },
1235
+ },
1236
+ {
1237
+ terms: {
1238
+ 'mappingInfo.status': inputData?.filterByStatus,
1239
+ },
1240
+ },
1241
+ ],
1242
+ },
1243
+ },
1244
+ },
1245
+ } );
1246
+ } else if ( ticketsFeature && ticketsApproveFeature ) {
1247
+ switch ( inputData.permisisionType ) {
1248
+ case 'review':
1249
+ searchQuery.query.bool.must.push( {
1250
+ nested: {
1251
+ path: 'mappingInfo',
1252
+ query: {
1253
+ bool: {
1254
+ must: [
1255
+ {
1256
+ term: {
1257
+ 'mappingInfo.type': 'review',
1258
+ },
1259
+ },
1260
+ {
1261
+ terms: {
1262
+ 'mappingInfo.status': inputData?.filterByStatus,
1263
+ },
1264
+ },
1265
+ ],
1266
+ },
1267
+ },
1268
+ },
1269
+ } );
1270
+ break;
1271
+ case 'approve':
1272
+ searchQuery.query.bool.must.push( {
1273
+ nested: {
1274
+ path: 'mappingInfo',
1275
+ query: {
1276
+ bool: {
1277
+ must: [
1278
+ {
1279
+ term: {
1280
+ 'mappingInfo.type': 'approve',
1281
+ },
1282
+ },
1283
+ {
1284
+ terms: {
1285
+ 'mappingInfo.status': inputData?.filterByStatus,
1286
+ },
1287
+ },
1288
+ ],
1289
+ },
1290
+ },
1291
+ },
1292
+ } );
1293
+ default: searchQuery.query.bool.must.push( {
1294
+ nested: {
1295
+ path: 'mappingInfo',
1296
+ query: {
1297
+ bool: {
1298
+ must: [
1299
+ {
1300
+ term: {
1301
+ 'mappingInfo.type': 'approve',
1302
+ },
1303
+ },
1304
+ {
1305
+ terms: {
1306
+ 'mappingInfo.status': inputData?.filterByStatus,
1307
+ },
1308
+ },
1309
+ ],
1310
+ },
1311
+ },
1312
+ },
1313
+ } );
1314
+ }
1315
+ }
1316
+ }
1317
+
1220
1318
  if ( req?.user?.userType === 'tango' && inputData.tangoType !== 'internal' ) {
1221
1319
  searchQuery.query.bool.must.push(
1222
1320
  {
@@ -2701,15 +2799,28 @@ export async function openTicketList( req, res ) {
2701
2799
  },
2702
2800
  },
2703
2801
  {
2704
- term: {
2705
- 'mappingInfo.type': inputData.type,
2706
- },
2707
- },
2708
- {
2709
- term: {
2710
- 'mappingInfo.status.keyword': 'Open',
2802
+ nested: {
2803
+ path: 'mappingInfo',
2804
+ query: {
2805
+ bool: {
2806
+ must: [
2807
+ {
2808
+ term: {
2809
+ 'mappingInfo.type': inputData.type,
2810
+ },
2811
+ },
2812
+ {
2813
+ term: {
2814
+ 'mappingInfo.status': 'Open',
2815
+ },
2816
+ },
2817
+
2818
+ ],
2819
+ },
2820
+ },
2711
2821
  },
2712
2822
  },
2823
+
2713
2824
  {
2714
2825
  range: {
2715
2826
  dateString: {
@@ -16,7 +16,6 @@ footfallDirectoryRouter.post( '/tango-review-accuracy-ticket', isAllowedSessionH
16
16
  footfallDirectoryRouter.get( '/ticket-summary', isAllowedSessionHandler, bulkValidate( ticketSummaryValid ), ticketSummary );
17
17
 
18
18
  footfallDirectoryRouter.get( '/ticket-list', isAllowedSessionHandler, bulkValidate( ticketListValid ), ticketList );
19
- // footfallDirectoryRouter.get( '/ticket-list', isAllowedSessionHandler, bulkValidate( ticketListValid ), ticketList );
20
19
  footfallDirectoryRouter.get( '/get-tickets', isAllowedSessionHandler, bulkValidate( getTicketsValid ), getTickets );
21
20
  footfallDirectoryRouter.get( '/get-tagged-stores', isAllowedSessionHandler, bulkValidate( getTaggedStoresValid ), getAssinedStore, getClusters, getTaggedStores );
22
21
  footfallDirectoryRouter.put( '/update-status', isAllowedSessionHandler, bulkValidate( updateStatusValid ), updateStatus );
@@ -1639,7 +1639,7 @@ export async function ticketApprove( req, res, next ) {
1639
1639
  revicedPerc: Math.round( ( revisedFootfall / footfallCount ) * 100 || 0 ) + '%',
1640
1640
  count: tempAcc,
1641
1641
  revisedDetail: formattedTaggingData,
1642
- status: 'Closed',
1642
+ status: 'Under Tango Review',
1643
1643
  createdByEmail: req?.user?.email,
1644
1644
  createdByUserName: req?.user?.userName,
1645
1645
  createdByRole: req?.user?.role,