tango-app-api-analysis-traffic 3.8.7-vms.6 → 3.8.7-vms.7

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-analysis-traffic",
3
- "version": "3.8.7-vms.6",
3
+ "version": "3.8.7-vms.7",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -426,85 +426,138 @@ export async function footFallImages( req, res ) {
426
426
  switch ( req.user.role ) {
427
427
  case 'user':
428
428
  const actionTypesUser = [ 'tagging', 'finalreview' ];
429
- temp = actionTypesUser.map( ( type ) => {
429
+
430
+ temp = [];
431
+ actionTypesUser.forEach( ( type ) => {
430
432
  const mapping = getMappingForType( type );
431
- const revisedFootfall = mapping.revisedFootfall ?? 0;
432
- // Do not divide by 0
433
- const revisedPerc =
434
- footfallValue > 0 ?
435
- `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
436
- '0';
437
-
438
- // Since keys in count can be dynamic, just deep copy the count object or empty object
439
- const countObj = mapping.count ? [ ...mapping.count ] : [];
440
-
441
- return {
442
- actionType: type,
443
- footfall: footfallValue,
444
- revicedFootfall: revisedFootfall,
445
- revicedPerc: revisedPerc,
446
- count: countObj,
447
- createdAt: mapping.createdAt ?? '',
448
- createdByEmail: mapping.createdByEmail ??'',
449
- createdByUserName: mapping.createdByUserName ??'',
450
- createdByRole: mapping.createdByRole ??'',
451
- };
433
+ if ( type === 'tagging' ) {
434
+ const revisedFootfall = mapping.revicedFootfall ?? 0;
435
+ const revisedPerc =
436
+ footfallValue > 0 ?
437
+ `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
438
+ '0';
439
+ const countObj = mapping.count ? [ ...mapping.count ] : [];
440
+ temp.push( {
441
+ actionType: type,
442
+ footfall: footfallValue,
443
+ revicedFootfall: revisedFootfall,
444
+ revicedPerc: revisedPerc,
445
+ count: countObj,
446
+ createdAt: mapping.createdAt ?? '',
447
+ createdByEmail: mapping.createdByEmail ?? '',
448
+ createdByUserName: mapping.createdByUserName ?? '',
449
+ createdByRole: mapping.createdByRole ?? '',
450
+ } );
451
+ } else if ( type !== 'tagging' && mapping.status === 'closed' ) {
452
+ const revisedFootfall = mapping.revicedFootfall ?? 0;
453
+ const revisedPerc =
454
+ footfallValue > 0 ?
455
+ `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
456
+ '0';
457
+ const countObj = mapping.count ? [ ...mapping.count ] : [];
458
+ temp.push( {
459
+ actionType: type,
460
+ footfall: footfallValue,
461
+ revicedFootfall: revisedFootfall,
462
+ revicedPerc: revisedPerc,
463
+ count: countObj,
464
+ createdAt: mapping.createdAt ?? '',
465
+ createdByEmail: mapping.createdByEmail ?? '',
466
+ createdByUserName: mapping.createdByUserName ?? '',
467
+ createdByRole: mapping.createdByRole ?? '',
468
+ } );
469
+ }
452
470
  } );
453
471
  break;
454
472
  case 'admin':
455
473
  const actionTypesAdmin = [ 'tagging', 'review', 'finalreview' ];
456
- temp = actionTypesAdmin.map( ( type ) => {
474
+ temp = [];
475
+ actionTypesAdmin.forEach( ( type ) => {
457
476
  const mapping = getMappingForType( type );
458
-
459
- const revisedFootfall = mapping.revisedFootfall ?? 0;
460
- // Do not divide by 0
461
- const revisedPerc =
462
- footfallValue > 0 ?
463
- `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
464
- '0';
465
-
466
- // Since keys in count can be dynamic, just deep copy the count object or empty object
467
- const countObj = mapping.count ? [ ...mapping.count ] : [];
468
-
469
- return {
470
- actionType: type,
471
- footfall: footfallValue,
472
- revicedFootfall: revisedFootfall,
473
- revicedPerc: revisedPerc,
474
- count: countObj,
475
- createdAt: mapping.createdAt ?? '',
476
- createdByEmail: mapping.createdByEmail ??'',
477
- createdByUserName: mapping.createdByUserName ??'',
478
- createdByRole: mapping.createdByRole ??'',
479
- };
477
+ if ( type === 'tagging' ) {
478
+ const revisedFootfall = mapping.revicedFootfall ?? 0;
479
+ const revisedPerc =
480
+ footfallValue > 0 ?
481
+ `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
482
+ '0';
483
+ const countObj = mapping.count ? [ ...mapping.count ] : [];
484
+ temp.push( {
485
+ actionType: type,
486
+ footfall: footfallValue,
487
+ revicedFootfall: revisedFootfall,
488
+ revicedPerc: revisedPerc,
489
+ count: countObj,
490
+ createdAt: mapping.createdAt ?? '',
491
+ createdByEmail: mapping.createdByEmail ?? '',
492
+ createdByUserName: mapping.createdByUserName ?? '',
493
+ createdByRole: mapping.createdByRole ?? '',
494
+ } );
495
+ } else if ( type !== 'tagging' && mapping.status === 'closed' ) {
496
+ const revisedFootfall = mapping.revicedFootfall ?? 0;
497
+ const revisedPerc =
498
+ footfallValue > 0 ?
499
+ `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
500
+ '0';
501
+ const countObj = mapping.count ? [ ...mapping.count ] : [];
502
+ temp.push( {
503
+ actionType: type,
504
+ footfall: footfallValue,
505
+ revicedFootfall: revisedFootfall,
506
+ revicedPerc: revisedPerc,
507
+ count: countObj,
508
+ createdAt: mapping.createdAt ?? '',
509
+ createdByEmail: mapping.createdByEmail ?? '',
510
+ createdByUserName: mapping.createdByUserName ?? '',
511
+ createdByRole: mapping.createdByRole ?? '',
512
+ } );
513
+ }
480
514
  } );
481
- break;
482
515
  }
483
516
  } else {
484
517
  const actionTypes = [ 'tagging', 'review', 'approve', 'finalreview' ];
485
- temp = actionTypes.map( ( type ) => {
518
+
519
+ // Dynamically add to temp only if actionType matches and status is 'closed',
520
+ // except for 'tagging' where status must be 'raised'
521
+ temp = [];
522
+ actionTypes.forEach( ( type ) => {
486
523
  const mapping = getMappingForType( type );
487
- const revisedFootfall = mapping.revicedFootfall ?? 0;
488
- // Do not divide by 0
489
- const revisedPerc =
490
- footfallValue > 0 ?
491
- `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
492
- '0';
493
-
494
- // Since keys in count can be dynamic, just deep copy the count object or empty object
495
- const countObj = mapping.count ? [ ...mapping.count ] : [];
496
-
497
- return {
498
- actionType: type,
499
- footfall: footfallValue,
500
- revicedFootfall: revisedFootfall,
501
- revicedPerc: revisedPerc,
502
- count: countObj,
503
- createdAt: mapping.createdAt ?? '',
504
- createdByEmail: mapping.createdByEmail ??'',
505
- createdByUserName: mapping.createdByUserName ??'',
506
- createdByRole: mapping.createdByRole ??'',
507
- };
524
+ if ( type === 'tagging' ) {
525
+ const revisedFootfall = mapping.revicedFootfall ?? 0;
526
+ const revisedPerc =
527
+ footfallValue > 0 ?
528
+ `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
529
+ '0';
530
+ const countObj = mapping.count ? [ ...mapping.count ] : [];
531
+ temp.push( {
532
+ actionType: type,
533
+ footfall: footfallValue,
534
+ revicedFootfall: revisedFootfall,
535
+ revicedPerc: revisedPerc,
536
+ count: countObj,
537
+ createdAt: mapping.createdAt ?? '',
538
+ createdByEmail: mapping.createdByEmail ?? '',
539
+ createdByUserName: mapping.createdByUserName ?? '',
540
+ createdByRole: mapping.createdByRole ?? '',
541
+ } );
542
+ } else if ( type !== 'tagging' && mapping.status === 'closed' ) {
543
+ const revisedFootfall = mapping.revicedFootfall ?? 0;
544
+ const revisedPerc =
545
+ footfallValue > 0 ?
546
+ `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
547
+ '0';
548
+ const countObj = mapping.count ? [ ...mapping.count ] : [];
549
+ temp.push( {
550
+ actionType: type,
551
+ footfall: footfallValue,
552
+ revicedFootfall: revisedFootfall,
553
+ revicedPerc: revisedPerc,
554
+ count: countObj,
555
+ createdAt: mapping.createdAt ?? '',
556
+ createdByEmail: mapping.createdByEmail ?? '',
557
+ createdByUserName: mapping.createdByUserName ?? '',
558
+ createdByRole: mapping.createdByRole ?? '',
559
+ } );
560
+ }
508
561
  } );
509
562
  }
510
563
 
@@ -514,7 +567,7 @@ export async function footFallImages( req, res ) {
514
567
  if ( resultData ) {
515
568
  // temp.length? temp[0].status = 'open': null;
516
569
  if ( resultData.status_code == '200' ) {
517
- return res.sendSuccess( { ...resultData, ticketStatus: temp?.length > 0? temp : null, config: req?.store?.footfallDirectoryConfigs } );
570
+ return res.sendSuccess( { ...resultData, ticketStatus: temp?.length > 0 && ticketDetails? temp : null, config: req?.store?.footfallDirectoryConfigs } );
518
571
  } else {
519
572
  return res.sendError( 'No Content', 204 );
520
573
  }