tango-app-api-infra 3.9.5-vms.71 → 3.9.5-vms.72
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
|
@@ -302,7 +302,7 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
302
302
|
} else if ( revised < tangoReview ) {
|
|
303
303
|
// If ticket is closed, do not proceed with revision mapping
|
|
304
304
|
|
|
305
|
-
record.status = '
|
|
305
|
+
record.status = 'Open - Accuracy Issue';
|
|
306
306
|
// Only keep or modify mappingInfo items with type "review"
|
|
307
307
|
if ( Array.isArray( record.mappingInfo ) ) {
|
|
308
308
|
const temp = record.mappingInfo
|
|
@@ -322,14 +322,14 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
322
322
|
|
|
323
323
|
record.mappingInfo = [ ...ticketData?.[0]?._source?.mappingInfo.slice( 0, -1 ),
|
|
324
324
|
...temp ];
|
|
325
|
-
if ( Array.isArray( record.mappingInfo ) ) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
325
|
+
// if ( Array.isArray( record.mappingInfo ) ) {
|
|
326
|
+
// record.mappingInfo = record.mappingInfo.map( ( item ) => {
|
|
327
|
+
// return {
|
|
328
|
+
// ...item,
|
|
329
|
+
// status: 'Closed',
|
|
330
|
+
// };
|
|
331
|
+
// } );
|
|
332
|
+
// }
|
|
333
333
|
// If no review mapping existed, push a new one
|
|
334
334
|
// if ( record.mappingInfo.length === 0 ) {
|
|
335
335
|
// record.mappingInfo.push( {
|
|
@@ -445,7 +445,7 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
445
445
|
}
|
|
446
446
|
} catch ( error ) {
|
|
447
447
|
const err = error.message || 'Internal Server Error';
|
|
448
|
-
logger.error( { error:
|
|
448
|
+
logger.error( { error: error, funtion: 'tangoReviewTicket' } );
|
|
449
449
|
return res.sendError( err, 500 );
|
|
450
450
|
}
|
|
451
451
|
}
|
|
@@ -453,44 +453,8 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
453
453
|
export async function tangoReviewAccuracyClosedTicket( req, res ) {
|
|
454
454
|
try {
|
|
455
455
|
const inputData = req.body;
|
|
456
|
-
|
|
457
|
-
// get store info by the storeId into mongo db
|
|
458
|
-
const getstoreName = await findOneStore( { storeId: inputData.storeId, status: 'active' }, { storeId: 1, storeName: 1, clientId: 1 } );
|
|
459
|
-
|
|
460
|
-
if ( !getstoreName || getstoreName == null ) {
|
|
461
|
-
return res.sendError( 'The store ID is either inActive or not found', 400 );
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// get the footfall count from opensearch
|
|
465
456
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
466
|
-
const dateString = `${inputData.storeId}_${inputData.dateString}`;
|
|
467
|
-
const getQuery = {
|
|
468
|
-
query: {
|
|
469
|
-
terms: {
|
|
470
|
-
_id: [ dateString ],
|
|
471
|
-
},
|
|
472
|
-
},
|
|
473
|
-
_source: [ 'footfall', 'date_string', 'store_id', 'down_time', 'footfall_count' ],
|
|
474
|
-
sort: [
|
|
475
|
-
{
|
|
476
|
-
date_iso: {
|
|
477
|
-
order: 'desc',
|
|
478
|
-
},
|
|
479
|
-
},
|
|
480
|
-
],
|
|
481
|
-
};
|
|
482
457
|
|
|
483
|
-
const getFootfallCount = await getOpenSearchData( openSearch.footfall, getQuery );
|
|
484
|
-
const hits = getFootfallCount?.body?.hits?.hits || [];
|
|
485
|
-
if ( hits?.[0]?._source?.footfall_count <= 0 ) {
|
|
486
|
-
return res.sendError( 'You can’t create a ticket because this store has 0 footfall data' );
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// get category details from the client level configuration
|
|
490
|
-
const getConfig = await findOneClient( { clientId: getstoreName.clientId }, { footfallDirectoryConfigs: 1 } );
|
|
491
|
-
if ( !getConfig || getConfig == null ) {
|
|
492
|
-
return res.sendError( 'The Client ID is either not configured or not found', 400 );
|
|
493
|
-
}
|
|
494
458
|
let findQuery = {
|
|
495
459
|
size: 10000,
|
|
496
460
|
query: {
|
|
@@ -566,192 +530,61 @@ export async function tangoReviewAccuracyClosedTicket( req, res ) {
|
|
|
566
530
|
|
|
567
531
|
const record = {
|
|
568
532
|
|
|
569
|
-
status:
|
|
570
|
-
revicedFootfall: inputData.mappingInfo?.[0]?.revicedFootfall,
|
|
571
|
-
revicedPerc: inputData.mappingInfo?.[0]?.revicedPerc,
|
|
572
|
-
mappingInfo: ticketData?.[0]?._source?.mappingInfo,
|
|
533
|
+
status: 'Closed - Accuracy Issue',
|
|
573
534
|
createdByEmail: req?.user?.email,
|
|
574
535
|
createdByUserName: req?.user?.userName,
|
|
575
536
|
createdByRole: req?.user?.role,
|
|
576
|
-
|
|
537
|
+
mappingInfo: ticketData?.[0]?._source?.mappingInfo,
|
|
577
538
|
};
|
|
578
539
|
|
|
579
|
-
|
|
580
|
-
// Retrieve client footfallDirectoryConfigs revision
|
|
581
|
-
let isAutoCloseEnable = getConfig.footfallDirectoryConfigs.isAutoCloseEnable;
|
|
582
|
-
let autoCloseAccuracy = getConfig?.footfallDirectoryConfigs?.autoCloseAccuracy;
|
|
583
|
-
|
|
584
|
-
const getNumber = autoCloseAccuracy.split( '%' )[0];
|
|
585
|
-
|
|
586
|
-
let autoCloseAccuracyValue = parseFloat( ( autoCloseAccuracy || getNumber ).replace( '%', '' ) );
|
|
587
|
-
let revisedPercentage = inputData.mappingInfo?.revicedPerc;
|
|
588
|
-
const revised = Number( revisedPercentage?.split( '%' )[0] );
|
|
589
|
-
const tangoReview = Number( getConfig?.footfallDirectoryConfigs?.tangoReview?.split( '%' )[0] );
|
|
590
540
|
// If autoclose enabled and revisedPercentage meets/exceeds threshold, close ticket and skip revision
|
|
591
|
-
if (
|
|
592
|
-
isAutoCloseEnable === true &&
|
|
593
|
-
revisedPercentage >= autoCloseAccuracyValue
|
|
594
|
-
) {
|
|
595
|
-
record.status = 'Closed';
|
|
596
|
-
// Only keep or modify mappingInfo items with type "review"
|
|
597
|
-
if ( Array.isArray( record.mappingInfo ) ) {
|
|
598
|
-
const temp = record.mappingInfo
|
|
599
|
-
.filter( ( item ) => item.type === 'tangoreview' )
|
|
600
|
-
.map( ( item ) => ( {
|
|
601
|
-
...item,
|
|
602
541
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
status: 'Closed',
|
|
609
|
-
createdByEmail: req?.user?.email,
|
|
610
|
-
createdByUserName: req?.user?.userName,
|
|
611
|
-
createdByRole: req?.user?.role,
|
|
612
|
-
} ) );
|
|
613
|
-
|
|
614
|
-
record.mappingInfo = [ ...ticketData?.[0]?._source?.mappingInfo.slice( 0, -1 ),
|
|
615
|
-
...temp ];
|
|
616
|
-
// If updating the mapping config to mark [i].status as 'Closed'
|
|
617
|
-
// Make sure all relevant mappingInfo items of type 'approve' are set to status 'Closed'
|
|
618
|
-
if ( Array.isArray( record.mappingInfo ) ) {
|
|
619
|
-
record.mappingInfo = record.mappingInfo.map( ( item ) => {
|
|
620
|
-
return {
|
|
621
|
-
...item,
|
|
622
|
-
status: 'Closed',
|
|
623
|
-
};
|
|
624
|
-
} );
|
|
625
|
-
}
|
|
626
|
-
// If no review mapping existed, push a new one
|
|
627
|
-
// if ( record.mappingInfo.length === 0 ) {
|
|
628
|
-
// record.mappingInfo.push( {
|
|
629
|
-
// type: 'tangoreview',
|
|
630
|
-
// mode: inputData.mappingInfo?.mode,
|
|
631
|
-
// revicedFootfall: inputData.mappingInfo?.revicedFootfall,
|
|
632
|
-
// revicedPerc: inputData.mappingInfo?.revicedPerc,
|
|
633
|
-
// count: inputData.mappingInfo?.count,
|
|
634
|
-
// revisedDetail: inputData.mappingInfo?.revisedDetail,
|
|
635
|
-
// status: 'Closed',
|
|
636
|
-
// createdByEmail: req?.user?.email,
|
|
637
|
-
// createdByUserName: req?.user?.userName,
|
|
638
|
-
// createdByRole: req?.user?.role,
|
|
639
|
-
// } );
|
|
640
|
-
// }
|
|
641
|
-
}
|
|
642
|
-
record.mappingInfo.push(
|
|
643
|
-
{
|
|
644
|
-
type: 'finalRevision',
|
|
645
|
-
mode: inputData.mappingInfo?.mode,
|
|
646
|
-
revicedFootfall: revisedFootfall,
|
|
647
|
-
revicedPerc: inputData.mappingInfo?.revicedPerc,
|
|
648
|
-
count: inputData.mappingInfo?.count,
|
|
649
|
-
revisedDetail: inputData.mappingInfo?.revisedDetail,
|
|
542
|
+
if ( Array.isArray( record.mappingInfo ) ) {
|
|
543
|
+
const temp = record.mappingInfo
|
|
544
|
+
.filter( ( item ) => item.type === 'tangoreview' )
|
|
545
|
+
.map( ( item ) => ( {
|
|
546
|
+
...item,
|
|
650
547
|
status: 'Closed',
|
|
651
548
|
createdByEmail: req?.user?.email,
|
|
652
549
|
createdByUserName: req?.user?.userName,
|
|
653
550
|
createdByRole: req?.user?.role,
|
|
654
|
-
|
|
655
|
-
},
|
|
656
|
-
);
|
|
657
|
-
} else if ( revised < tangoReview ) {
|
|
658
|
-
// If ticket is closed, do not proceed with revision mapping
|
|
551
|
+
} ) );
|
|
659
552
|
|
|
660
|
-
record.
|
|
661
|
-
|
|
553
|
+
record.mappingInfo = [ ...ticketData?.[0]?._source?.mappingInfo.slice( 0, -1 ),
|
|
554
|
+
...temp ];
|
|
662
555
|
if ( Array.isArray( record.mappingInfo ) ) {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
revicedPerc: inputData.mappingInfo?.revicedPerc,
|
|
670
|
-
count: inputData.mappingInfo?.count,
|
|
671
|
-
revisedDetail: inputData.mappingInfo?.revisedDetail,
|
|
672
|
-
status: 'Closed',
|
|
673
|
-
createdByEmail: req?.user?.email,
|
|
674
|
-
createdByUserName: req?.user?.userName,
|
|
675
|
-
createdByRole: req?.user?.role,
|
|
676
|
-
} ) );
|
|
677
|
-
|
|
678
|
-
record.mappingInfo = [ ...ticketData?.[0]?._source?.mappingInfo.slice( 0, -1 ),
|
|
679
|
-
...temp ];
|
|
680
|
-
if ( Array.isArray( record.mappingInfo ) ) {
|
|
681
|
-
record.mappingInfo = record.mappingInfo.map( ( item ) => {
|
|
682
|
-
return {
|
|
683
|
-
...item,
|
|
684
|
-
status: 'Closed',
|
|
685
|
-
};
|
|
686
|
-
} );
|
|
687
|
-
}
|
|
688
|
-
// If no review mapping existed, push a new one
|
|
689
|
-
// if ( record.mappingInfo.length === 0 ) {
|
|
690
|
-
// record.mappingInfo.push( {
|
|
691
|
-
// type: 'tangoreview',
|
|
692
|
-
// mode: inputData.mappingInfo?.mode,
|
|
693
|
-
// revicedFootfall: inputData.mappingInfo?.revicedFootfall,
|
|
694
|
-
// revicedPerc: inputData.mappingInfo?.revicedPerc,
|
|
695
|
-
// count: inputData.mappingInfo?.count,
|
|
696
|
-
// revisedDetail: inputData.mappingInfo?.revisedDetail,
|
|
697
|
-
// status: 'Closed',
|
|
698
|
-
// createdByEmail: req?.user?.email,
|
|
699
|
-
// createdByUserName: req?.user?.userName,
|
|
700
|
-
// createdByRole: req?.user?.role,
|
|
701
|
-
// } );
|
|
702
|
-
// }
|
|
556
|
+
record.mappingInfo = record.mappingInfo.map( ( item ) => {
|
|
557
|
+
return {
|
|
558
|
+
...item,
|
|
559
|
+
status: 'Closed',
|
|
560
|
+
};
|
|
561
|
+
} );
|
|
703
562
|
}
|
|
704
|
-
} else {
|
|
705
|
-
if ( Array.isArray( record.mappingInfo ) ) {
|
|
706
|
-
const temp = record.mappingInfo
|
|
707
|
-
.filter( ( item ) => item.type === 'tangoreview' )
|
|
708
|
-
.map( ( item ) => ( {
|
|
709
|
-
...item,
|
|
710
|
-
mode: inputData.mappingInfo?.mode,
|
|
711
|
-
revicedFootfall: inputData.mappingInfo?.revicedFootfall,
|
|
712
|
-
revicedPerc: inputData.mappingInfo?.revicedPerc,
|
|
713
|
-
count: inputData.mappingInfo?.count,
|
|
714
|
-
revisedDetail: inputData.mappingInfo?.revisedDetail,
|
|
715
|
-
status: 'Closed',
|
|
716
|
-
createdByEmail: req?.user?.email,
|
|
717
|
-
createdByUserName: req?.user?.userName,
|
|
718
|
-
createdByRole: req?.user?.role,
|
|
719
|
-
} ) );
|
|
720
563
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
// revicedPerc: inputData.mappingInfo?.revicedPerc,
|
|
738
|
-
// count: inputData.mappingInfo?.count,
|
|
739
|
-
// revisedDetail: inputData.mappingInfo?.revisedDetail,
|
|
740
|
-
// status: 'Closed',
|
|
741
|
-
// createdByEmail: req?.user?.email,
|
|
742
|
-
// createdByUserName: req?.user?.userName,
|
|
743
|
-
// createdByRole: req?.user?.role,
|
|
744
|
-
// } );
|
|
745
|
-
// }
|
|
746
|
-
}
|
|
564
|
+
|
|
565
|
+
// If no review mapping existed, push a new one
|
|
566
|
+
// if ( record.mappingInfo.length === 0 ) {
|
|
567
|
+
// record.mappingInfo.push( {
|
|
568
|
+
// type: 'tangoreview',
|
|
569
|
+
// mode: inputData.mappingInfo?.mode,
|
|
570
|
+
// revicedFootfall: temp?.mappingInfo?.revicedFootfall,
|
|
571
|
+
// revicedPerc: temp?.mappingInfo?.revicedPerc,
|
|
572
|
+
// count: temp?.mappingInfo?.count,
|
|
573
|
+
// revisedDetail: temp?.mappingInfo?.revisedDetail,
|
|
574
|
+
// status: 'Closed',
|
|
575
|
+
// createdByEmail: req?.user?.email,
|
|
576
|
+
// createdByUserName: req?.user?.userName,
|
|
577
|
+
// createdByRole: req?.user?.role,
|
|
578
|
+
// } );
|
|
579
|
+
// }
|
|
747
580
|
record.mappingInfo.push(
|
|
748
581
|
{
|
|
749
582
|
type: 'finalRevision',
|
|
750
|
-
mode:
|
|
751
|
-
revicedFootfall:
|
|
752
|
-
revicedPerc:
|
|
753
|
-
count:
|
|
754
|
-
revisedDetail:
|
|
583
|
+
mode: 'web',
|
|
584
|
+
revicedFootfall: temp?.[0]?.revicedFootfall,
|
|
585
|
+
revicedPerc: temp?.[0].revicedPerc,
|
|
586
|
+
count: temp?.[0].count,
|
|
587
|
+
revisedDetail: temp?.[0]?.revisedDetail,
|
|
755
588
|
status: 'Closed',
|
|
756
589
|
createdByEmail: req?.user?.email,
|
|
757
590
|
createdByUserName: req?.user?.userName,
|
|
@@ -761,35 +594,10 @@ export async function tangoReviewAccuracyClosedTicket( req, res ) {
|
|
|
761
594
|
);
|
|
762
595
|
}
|
|
763
596
|
|
|
764
|
-
if ( Ticket[0]?._source?.type==='store' ) {
|
|
765
|
-
let findTagging = Ticket[0]?._source?.mappingInfo.filter( ( data ) => data.type==='tagging' );
|
|
766
|
-
if ( findTagging?.length>0&&findTagging[0].createdByEmail!='' ) {
|
|
767
|
-
let userData = await findOneUser( { email: findTagging[0]?.createdByEmail } );
|
|
768
|
-
let title = `Received response for the Footfall ticket raised.`;
|
|
769
|
-
let createdOn = dayjs( Ticket[0]?._source?.dateString ).format( 'DD MMM YYYY' );
|
|
770
|
-
let description = `Raised on ${createdOn}`;
|
|
771
597
|
|
|
772
|
-
let Data = {
|
|
773
|
-
'title': title,
|
|
774
|
-
'body': description,
|
|
775
|
-
'type': 'closed',
|
|
776
|
-
'date': Ticket[0]?._source?.dateString,
|
|
777
|
-
'storeId': Ticket[0]?._source?.storeId,
|
|
778
|
-
'clientId': Ticket[0]?._source?.clientId,
|
|
779
|
-
'ticketId': Ticket[0]?._source?.ticketId,
|
|
780
|
-
};
|
|
781
|
-
if ( userData && userData.fcmToken ) {
|
|
782
|
-
const fcmToken = userData.fcmToken;
|
|
783
|
-
await sendPushNotification( title, description, fcmToken, Data );
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
598
|
// return;
|
|
788
599
|
|
|
789
600
|
let id = `${inputData.storeId}_${inputData.dateString}_footfall-directory-tagging`;
|
|
790
|
-
if ( inputData.ticketType === 'internal' ) {
|
|
791
|
-
id = `${inputData.storeId}_${inputData.dateString}_internal_footfall-directory-tagging`;
|
|
792
|
-
}
|
|
793
601
|
|
|
794
602
|
const insertResult = await updateOpenSearchData( openSearch.footfallDirectory, id, { doc: record } );
|
|
795
603
|
|
|
@@ -800,7 +608,7 @@ export async function tangoReviewAccuracyClosedTicket( req, res ) {
|
|
|
800
608
|
}
|
|
801
609
|
} catch ( error ) {
|
|
802
610
|
const err = error.message || 'Internal Server Error';
|
|
803
|
-
logger.error( { error:
|
|
611
|
+
logger.error( { error: error, funtion: 'tangoReviewAccuracyClosedTicket' } );
|
|
804
612
|
return res.sendError( err, 500 );
|
|
805
613
|
}
|
|
806
614
|
}
|
|
@@ -11,7 +11,7 @@ footfallDirectoryRouter.post( '/create-internalticket', isAllowedSessionHandler,
|
|
|
11
11
|
footfallDirectoryRouter.post( '/checkTicketExists', isAllowedSessionHandler, checkTicketExists );
|
|
12
12
|
|
|
13
13
|
footfallDirectoryRouter.post( '/tango-review-ticket', isAllowedSessionHandler, validate( tangoReviewTicketValid ), tangoReviewTicket );
|
|
14
|
-
footfallDirectoryRouter.post( '/tango-review-ticket', isAllowedSessionHandler, validate( tangoReviewAccuracyClosedTicketValid ), tangoReviewAccuracyClosedTicket );
|
|
14
|
+
footfallDirectoryRouter.post( '/tango-review-accuracy-ticket', isAllowedSessionHandler, validate( tangoReviewAccuracyClosedTicketValid ), tangoReviewAccuracyClosedTicket );
|
|
15
15
|
|
|
16
16
|
footfallDirectoryRouter.get( '/ticket-summary', isAllowedSessionHandler, bulkValidate( ticketSummaryValid ), ticketSummary );
|
|
17
17
|
|