tango-app-api-analysis-traffic 3.8.7-vms.3 → 3.8.7-vms.5
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
|
@@ -406,40 +406,112 @@ export async function footFallImages( req, res ) {
|
|
|
406
406
|
],
|
|
407
407
|
},
|
|
408
408
|
},
|
|
409
|
-
|
|
409
|
+
'_source': [ 'dateString', 'storeId', 'mappingInfo', 'revicedFootfall', 'revicedPerc', 'createdAt', 'updatedAt', 'footfallCount' ],
|
|
410
410
|
|
|
411
411
|
};
|
|
412
412
|
|
|
413
413
|
const getData = await getOpenSearchData( opensearch.footfallDirectory, query );
|
|
414
414
|
const ticketDetails = getData?.body?.hits?.hits[0];
|
|
415
415
|
let temp = [];
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
416
|
+
const footfallValue = ticketDetails?._source?.footfallCount ?? 0;
|
|
417
|
+
const mappingInfoArray = ticketDetails?._source?.mappingInfo ?? [];
|
|
418
|
+
|
|
419
|
+
// Helper to get mappingInfo for an actionType
|
|
420
|
+
function getMappingForType( type ) {
|
|
421
|
+
return mappingInfoArray.find( ( m ) => m.type === type ) || {};
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// List of actionTypes to process in sequence
|
|
425
|
+
|
|
426
|
+
if ( req.user.userType !== 'tango' && req.user.role !== 'superadmin' ) {
|
|
427
|
+
switch ( req.user.role ) {
|
|
428
|
+
case 'user':
|
|
429
|
+
const actionTypesUser = [ 'tagging', 'finalreview' ];
|
|
430
|
+
temp = actionTypesUser.map( ( type ) => {
|
|
431
|
+
const mapping = getMappingForType( type );
|
|
432
|
+
|
|
433
|
+
const revisedFootfall = mapping.revisedFootfall ?? 0;
|
|
434
|
+
// Do not divide by 0
|
|
435
|
+
const revisedPerc =
|
|
436
|
+
footfallValue > 0 ?
|
|
437
|
+
`${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
|
|
438
|
+
'0';
|
|
439
|
+
|
|
440
|
+
// Since keys in count can be dynamic, just deep copy the count object or empty object
|
|
441
|
+
const countObj = mapping.count ? { ...mapping.count } : {};
|
|
442
|
+
|
|
443
|
+
return {
|
|
444
|
+
actionType: type,
|
|
445
|
+
footfall: footfallValue,
|
|
446
|
+
revicedFootfall: revisedFootfall,
|
|
447
|
+
revicedPerc: revisedPerc,
|
|
448
|
+
count: countObj,
|
|
449
|
+
};
|
|
450
|
+
} );
|
|
451
|
+
break;
|
|
452
|
+
case 'admin':
|
|
453
|
+
const actionTypesAdmin = [ 'tagging', 'review', 'finalreview' ];
|
|
454
|
+
temp = actionTypesAdmin.map( ( type ) => {
|
|
455
|
+
const mapping = getMappingForType( type );
|
|
456
|
+
|
|
457
|
+
const revisedFootfall = mapping.revisedFootfall ?? 0;
|
|
458
|
+
// Do not divide by 0
|
|
459
|
+
const revisedPerc =
|
|
460
|
+
footfallValue > 0 ?
|
|
461
|
+
`${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
|
|
462
|
+
'0';
|
|
463
|
+
|
|
464
|
+
// Since keys in count can be dynamic, just deep copy the count object or empty object
|
|
465
|
+
const countObj = mapping.count ? { ...mapping.count } : {};
|
|
466
|
+
|
|
467
|
+
return {
|
|
468
|
+
actionType: type,
|
|
469
|
+
footfall: footfallValue,
|
|
470
|
+
revicedFootfall: revisedFootfall,
|
|
471
|
+
revicedPerc: revisedPerc,
|
|
472
|
+
count: countObj,
|
|
473
|
+
};
|
|
474
|
+
} );
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
} else {
|
|
478
|
+
const actionTypes = [ 'tagging', 'review', 'approve', 'finalreview' ];
|
|
479
|
+
temp = actionTypes.map( ( type ) => {
|
|
480
|
+
const mapping = getMappingForType( type );
|
|
481
|
+
|
|
482
|
+
const revisedFootfall = mapping.revisedFootfall ?? 0;
|
|
483
|
+
// Do not divide by 0
|
|
484
|
+
const revisedPerc =
|
|
485
|
+
footfallValue > 0 ?
|
|
486
|
+
`${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
|
|
487
|
+
'0';
|
|
488
|
+
|
|
489
|
+
// Since keys in count can be dynamic, just deep copy the count object or empty object
|
|
490
|
+
const countObj = mapping.count ? { ...mapping.count } : {};
|
|
491
|
+
|
|
492
|
+
return {
|
|
493
|
+
actionType: type,
|
|
494
|
+
footfall: footfallValue,
|
|
495
|
+
revicedFootfall: revisedFootfall,
|
|
496
|
+
revicedPerc: revisedPerc,
|
|
497
|
+
count: countObj,
|
|
498
|
+
};
|
|
499
|
+
} );
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
const LamdaURL = revop.getImages;
|
|
504
|
+
let resultData = await LamdaServiceCall( LamdaURL, inputData );
|
|
505
|
+
if ( resultData ) {
|
|
506
|
+
// temp.length? temp[0].status = 'open': null;
|
|
507
|
+
if ( resultData.status_code == '200' ) {
|
|
508
|
+
return res.sendSuccess( { ...resultData, ticketStatus: temp?.length > 0? temp : null, config: req?.store?.footfallDirectoryConfigs } );
|
|
509
|
+
} else {
|
|
510
|
+
return res.sendError( 'No Content', 204 );
|
|
511
|
+
}
|
|
512
|
+
} else {
|
|
513
|
+
return res.sendError( 'No Content', 204 );
|
|
514
|
+
}
|
|
443
515
|
} catch ( error ) {
|
|
444
516
|
logger.error( { message: error, data: req.query, function: 'storeProcessedData' } );
|
|
445
517
|
const err = error.message || 'Internal Server Error';
|
|
@@ -476,6 +548,7 @@ export async function tagTempId( req, res ) {
|
|
|
476
548
|
action: 'submitted',
|
|
477
549
|
},
|
|
478
550
|
],
|
|
551
|
+
comments: inputData.comments || '',
|
|
479
552
|
createdAt: new Date(),
|
|
480
553
|
updatedAt: new Date(),
|
|
481
554
|
|
|
@@ -529,6 +602,7 @@ export async function tagTempId( req, res ) {
|
|
|
529
602
|
isParent: false,
|
|
530
603
|
type: 'tagging-reflect',
|
|
531
604
|
ticketStatus: 'submitted',
|
|
605
|
+
comments: inputData.comments || '',
|
|
532
606
|
actions: [
|
|
533
607
|
{
|
|
534
608
|
actionType: 'tagging',
|
package/src/dtos/revop.dtos.js
CHANGED