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

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.8",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -426,85 +426,141 @@ 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
+ isUp: false,
451
+ } );
452
+ } else if ( type !== 'tagging' && mapping.status === 'closed' ) {
453
+ const revisedFootfall = mapping.revicedFootfall ?? 0;
454
+ const revisedPerc =
455
+ footfallValue > 0 ?
456
+ `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
457
+ '0';
458
+ const countObj = mapping.count ? [ ...mapping.count ] : [];
459
+ temp.push( {
460
+ actionType: type,
461
+ footfall: footfallValue,
462
+ revicedFootfall: revisedFootfall,
463
+ revicedPerc: revisedPerc,
464
+ count: countObj,
465
+ createdAt: mapping.createdAt ?? '',
466
+ createdByEmail: mapping.createdByEmail ?? '',
467
+ createdByUserName: mapping.createdByUserName ?? '',
468
+ createdByRole: mapping.createdByRole ?? '',
469
+ } );
470
+ }
452
471
  } );
453
472
  break;
454
473
  case 'admin':
455
474
  const actionTypesAdmin = [ 'tagging', 'review', 'finalreview' ];
456
- temp = actionTypesAdmin.map( ( type ) => {
475
+ temp = [];
476
+ actionTypesAdmin.forEach( ( type ) => {
457
477
  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
- };
478
+ if ( type === 'tagging' ) {
479
+ const revisedFootfall = mapping.revicedFootfall ?? 0;
480
+ const revisedPerc =
481
+ footfallValue > 0 ?
482
+ `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
483
+ '0';
484
+ const countObj = mapping.count ? [ ...mapping.count ] : [];
485
+ temp.push( {
486
+ actionType: type,
487
+ footfall: footfallValue,
488
+ revicedFootfall: revisedFootfall,
489
+ revicedPerc: revisedPerc,
490
+ count: countObj,
491
+ createdAt: mapping.createdAt ?? '',
492
+ createdByEmail: mapping.createdByEmail ?? '',
493
+ createdByUserName: mapping.createdByUserName ?? '',
494
+ createdByRole: mapping.createdByRole ?? '',
495
+ isUp: false,
496
+ } );
497
+ } else if ( type !== 'tagging' && mapping.status === 'closed' ) {
498
+ const revisedFootfall = mapping.revicedFootfall ?? 0;
499
+ const revisedPerc =
500
+ footfallValue > 0 ?
501
+ `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
502
+ '0';
503
+ const countObj = mapping.count ? [ ...mapping.count ] : [];
504
+ temp.push( {
505
+ actionType: type,
506
+ footfall: footfallValue,
507
+ revicedFootfall: revisedFootfall,
508
+ revicedPerc: revisedPerc,
509
+ count: countObj,
510
+ createdAt: mapping.createdAt ?? '',
511
+ createdByEmail: mapping.createdByEmail ?? '',
512
+ createdByUserName: mapping.createdByUserName ?? '',
513
+ createdByRole: mapping.createdByRole ?? '',
514
+ } );
515
+ }
480
516
  } );
481
- break;
482
517
  }
483
518
  } else {
484
519
  const actionTypes = [ 'tagging', 'review', 'approve', 'finalreview' ];
485
- temp = actionTypes.map( ( type ) => {
520
+
521
+ // Dynamically add to temp only if actionType matches and status is 'closed',
522
+ // except for 'tagging' where status must be 'raised'
523
+ temp = [];
524
+ actionTypes.forEach( ( type ) => {
486
525
  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
- };
526
+ if ( type === 'tagging' ) {
527
+ const revisedFootfall = mapping.revicedFootfall ?? 0;
528
+ const revisedPerc =
529
+ footfallValue > 0 ?
530
+ `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
531
+ '0';
532
+ const countObj = mapping.count ? [ ...mapping.count ] : [];
533
+ temp.push( {
534
+ actionType: type,
535
+ footfall: footfallValue,
536
+ revicedFootfall: revisedFootfall,
537
+ revicedPerc: revisedPerc,
538
+ count: countObj,
539
+ createdAt: mapping.createdAt ?? '',
540
+ createdByEmail: mapping.createdByEmail ?? '',
541
+ createdByUserName: mapping.createdByUserName ?? '',
542
+ createdByRole: mapping.createdByRole ?? '',
543
+ isUp: false,
544
+ } );
545
+ } else if ( type !== 'tagging' && mapping.status === 'closed' ) {
546
+ const revisedFootfall = mapping.revicedFootfall ?? 0;
547
+ const revisedPerc =
548
+ footfallValue > 0 ?
549
+ `${Math.round( ( revisedFootfall / footfallValue ) * 100 )}` :
550
+ '0';
551
+ const countObj = mapping.count ? [ ...mapping.count ] : [];
552
+ temp.push( {
553
+ actionType: type,
554
+ footfall: footfallValue,
555
+ revicedFootfall: revisedFootfall,
556
+ revicedPerc: revisedPerc,
557
+ count: countObj,
558
+ createdAt: mapping.createdAt ?? '',
559
+ createdByEmail: mapping.createdByEmail ?? '',
560
+ createdByUserName: mapping.createdByUserName ?? '',
561
+ createdByRole: mapping.createdByRole ?? '',
562
+ } );
563
+ }
508
564
  } );
509
565
  }
510
566
 
@@ -514,7 +570,7 @@ export async function footFallImages( req, res ) {
514
570
  if ( resultData ) {
515
571
  // temp.length? temp[0].status = 'open': null;
516
572
  if ( resultData.status_code == '200' ) {
517
- return res.sendSuccess( { ...resultData, ticketStatus: temp?.length > 0? temp : null, config: req?.store?.footfallDirectoryConfigs } );
573
+ return res.sendSuccess( { ...resultData, ticketStatus: temp?.length > 0 && ticketDetails? temp : null, config: req?.store?.footfallDirectoryConfigs } );
518
574
  } else {
519
575
  return res.sendError( 'No Content', 204 );
520
576
  }