tango-app-api-trax 1.0.0-alpha.13 → 1.0.0-alpha.14
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
|
@@ -496,6 +496,387 @@ export const flagChecklistTable = async ( req, res ) => {
|
|
|
496
496
|
}
|
|
497
497
|
};
|
|
498
498
|
|
|
499
|
+
export const flagCards = async ( req, res ) => {
|
|
500
|
+
try {
|
|
501
|
+
let requestData = req.body;
|
|
502
|
+
let resultData = await flagCardData( requestData.checklistType );
|
|
503
|
+
return res.sendSuccess( resultData );
|
|
504
|
+
} catch ( error ) {
|
|
505
|
+
console.log( 'error =>', error );
|
|
506
|
+
logger.error( { error: error, function: 'subscribedStoreList' } );
|
|
507
|
+
return res.sendError( error, 500 );
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
export const flagComparisonCards = async ( req, res ) => {
|
|
512
|
+
try {
|
|
513
|
+
let requestData = req.body;
|
|
514
|
+
let resultData = await falgComparisonData( requestData.checklistType );
|
|
515
|
+
return res.sendSuccess( resultData );
|
|
516
|
+
} catch ( error ) {
|
|
517
|
+
console.log( 'error =>', error );
|
|
518
|
+
logger.error( { error: error, function: 'subscribedStoreList' } );
|
|
519
|
+
return res.sendError( error, 500 );
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
export const flagTables = async ( req, res ) => {
|
|
524
|
+
try {
|
|
525
|
+
let requestData = req.body;
|
|
526
|
+
let resultData = await flagTableData( requestData.checklistType );
|
|
527
|
+
return res.sendSuccess( resultData );
|
|
528
|
+
} catch ( error ) {
|
|
529
|
+
console.log( 'error =>', error );
|
|
530
|
+
logger.error( { error: error, function: 'subscribedStoreList' } );
|
|
531
|
+
return res.sendError( error, 500 );
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
export const checklistDropdown = async ( req, res ) => {
|
|
536
|
+
try {
|
|
537
|
+
let requestData = req.body;
|
|
538
|
+
let resultData = await checklistDropdownData( requestData.checklistType );
|
|
539
|
+
return res.sendSuccess( resultData );
|
|
540
|
+
} catch ( error ) {
|
|
541
|
+
console.log( 'error =>', error );
|
|
542
|
+
logger.error( { error: error, function: 'subscribedStoreList' } );
|
|
543
|
+
return res.sendError( error, 500 );
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
export const flagCardsV1 = async ( req, res ) => {
|
|
548
|
+
try {
|
|
549
|
+
let requestData = req.body;
|
|
550
|
+
let fromDate = new Date( requestData.fromDate );
|
|
551
|
+
let toDate = new Date( requestData.toDate );
|
|
552
|
+
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
553
|
+
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
554
|
+
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
555
|
+
|
|
556
|
+
let flagCards = {
|
|
557
|
+
'totalFlag': 0,
|
|
558
|
+
'questionFlag': {
|
|
559
|
+
'count': 0,
|
|
560
|
+
},
|
|
561
|
+
'delayInSubmission': {
|
|
562
|
+
'count': 0,
|
|
563
|
+
},
|
|
564
|
+
'detectionFlag': {
|
|
565
|
+
'count': 0,
|
|
566
|
+
},
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
let findQuery = [];
|
|
570
|
+
let findAndQuery = [];
|
|
571
|
+
findAndQuery.push(
|
|
572
|
+
{ client_id: requestData.clientId },
|
|
573
|
+
{ store_id: { $in: requestData.storeId } },
|
|
574
|
+
{ date_iso: { $gte: fromDate } },
|
|
575
|
+
{ date_iso: { $lte: toDate } },
|
|
576
|
+
);
|
|
577
|
+
|
|
578
|
+
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
579
|
+
|
|
580
|
+
findQuery.push( {
|
|
581
|
+
$project: {
|
|
582
|
+
timeFlag: 1,
|
|
583
|
+
questionFlag: 1,
|
|
584
|
+
mobileDetectionFlag: 1,
|
|
585
|
+
storeOpenCloseFlag: 1,
|
|
586
|
+
uniformDetectionFlag: 1,
|
|
587
|
+
customerunattendedFlag: 1,
|
|
588
|
+
staffleftinthemiddleFlag: 1,
|
|
589
|
+
},
|
|
590
|
+
} );
|
|
591
|
+
|
|
592
|
+
findQuery.push( {
|
|
593
|
+
$group: {
|
|
594
|
+
_id: '',
|
|
595
|
+
totalFlag: {
|
|
596
|
+
$sum: {
|
|
597
|
+
$cond: [ {
|
|
598
|
+
$or: [
|
|
599
|
+
{ $gt: [ '$questionFlag', 0 ] },
|
|
600
|
+
{ $gt: [ '$timeFlag', 0 ] },
|
|
601
|
+
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
602
|
+
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
603
|
+
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
604
|
+
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
605
|
+
{ $gt: [ '$staffleftinthemiddleFlag', 0 ] },
|
|
606
|
+
],
|
|
607
|
+
}, 1, 0 ],
|
|
608
|
+
},
|
|
609
|
+
},
|
|
610
|
+
questionFlag: {
|
|
611
|
+
$sum: {
|
|
612
|
+
$cond: [
|
|
613
|
+
{
|
|
614
|
+
$and: [
|
|
615
|
+
{ $gt: [ '$questionFlag', 0 ] },
|
|
616
|
+
],
|
|
617
|
+
}, 1, 0 ],
|
|
618
|
+
},
|
|
619
|
+
},
|
|
620
|
+
delayInSubmission: {
|
|
621
|
+
$sum: {
|
|
622
|
+
$cond: [
|
|
623
|
+
{
|
|
624
|
+
$and: [
|
|
625
|
+
{ $gt: [ '$timeFlag', 0 ] },
|
|
626
|
+
],
|
|
627
|
+
}, 1, 0 ],
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
detectionFlag: {
|
|
631
|
+
$sum: {
|
|
632
|
+
$cond: [ {
|
|
633
|
+
$or: [
|
|
634
|
+
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
635
|
+
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
636
|
+
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
637
|
+
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
638
|
+
{ $gt: [ '$staffleftinthemiddleFlag', 0 ] },
|
|
639
|
+
],
|
|
640
|
+
}, 1, 0 ],
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
},
|
|
644
|
+
} );
|
|
645
|
+
let getOverallChecklistData = await processedchecklistService.aggregate( findQuery );
|
|
646
|
+
if ( !getOverallChecklistData.length ) {
|
|
647
|
+
return res.sendError( { error: 'No Data Found' }, 204 );
|
|
648
|
+
}
|
|
649
|
+
console.log( 'getOverallChecklistData =>', getOverallChecklistData );
|
|
650
|
+
if ( getOverallChecklistData.length && getOverallChecklistData.length>0 ) {
|
|
651
|
+
if ( getOverallChecklistData[0].totalFlag ) {
|
|
652
|
+
flagCards.totalFlag = getOverallChecklistData[0]?.totalFlag;
|
|
653
|
+
}
|
|
654
|
+
if ( getOverallChecklistData[0].questionFlag ) {
|
|
655
|
+
flagCards.questionFlag.count = getOverallChecklistData[0]?.questionFlag;
|
|
656
|
+
}
|
|
657
|
+
if ( getOverallChecklistData[0].delayInSubmission ) {
|
|
658
|
+
flagCards.delayInSubmission.count = getOverallChecklistData[0]?.delayInSubmission;
|
|
659
|
+
}
|
|
660
|
+
if ( getOverallChecklistData[0].detectionFlag ) {
|
|
661
|
+
flagCards.detectionFlag.count = getOverallChecklistData[0]?.detectionFlag;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
let result = {
|
|
665
|
+
'flagCards': flagCards,
|
|
666
|
+
};
|
|
667
|
+
console.log( 'getOverallChecklistData =>', getOverallChecklistData );
|
|
668
|
+
// let resultData = await flagCardData( requestData.checklistType );
|
|
669
|
+
return res.sendSuccess( result );
|
|
670
|
+
} catch ( error ) {
|
|
671
|
+
console.log( 'error =>', error );
|
|
672
|
+
logger.error( { error: error, function: 'subscribedStoreList' } );
|
|
673
|
+
return res.sendError( error, 500 );
|
|
674
|
+
}
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
export const flagComparisonCardsV1 = async ( req, res ) => {
|
|
678
|
+
try {
|
|
679
|
+
let requestData = req.body;
|
|
680
|
+
let fromDate = new Date( requestData.fromDate );
|
|
681
|
+
let toDate = new Date( requestData.toDate );
|
|
682
|
+
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
683
|
+
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
684
|
+
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
685
|
+
|
|
686
|
+
let rangeOneFromDate = new Date( requestData.toDate );
|
|
687
|
+
rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 6 );
|
|
688
|
+
let rangeOneToDate = new Date( requestData.toDate );
|
|
689
|
+
rangeOneToDate = new Date( rangeOneToDate.getTime() - userTimezoneOffset );
|
|
690
|
+
rangeOneToDate.setUTCHours( 23, 59, 59, 59 );
|
|
691
|
+
let rangeTwoToDate = new Date( requestData.toDate );
|
|
692
|
+
rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 7 );
|
|
693
|
+
let rangeTwoFromDate = new Date( rangeTwoToDate );
|
|
694
|
+
rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 6 );
|
|
695
|
+
rangeTwoToDate = new Date( rangeTwoToDate.getTime() - userTimezoneOffset );
|
|
696
|
+
rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
|
|
697
|
+
|
|
698
|
+
let flagComparisonCards = {
|
|
699
|
+
'questionComparisonFlag': {
|
|
700
|
+
'comparisonData': 0,
|
|
701
|
+
'ComparisonFlag': '',
|
|
702
|
+
},
|
|
703
|
+
'delayInSubmissionComparisonFlag': {
|
|
704
|
+
'comparisonData': 0,
|
|
705
|
+
'ComparisonFlag': '',
|
|
706
|
+
},
|
|
707
|
+
'detectionComparisonFlag': {
|
|
708
|
+
'comparisonData': 0,
|
|
709
|
+
'ComparisonFlag': '',
|
|
710
|
+
},
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
let rangeOneFindQuery = [];
|
|
714
|
+
let rangeOneFindAndQuery = [];
|
|
715
|
+
rangeOneFindAndQuery.push(
|
|
716
|
+
{ client_id: requestData.clientId },
|
|
717
|
+
{ store_id: { $in: requestData.storeId } },
|
|
718
|
+
{ date_iso: { $gte: fromDate } },
|
|
719
|
+
{ date_iso: { $lte: toDate } },
|
|
720
|
+
);
|
|
721
|
+
rangeOneFindQuery.push( { $match: { $and: rangeOneFindAndQuery } } );
|
|
722
|
+
rangeOneFindQuery.push( {
|
|
723
|
+
$project: {
|
|
724
|
+
timeFlag: 1,
|
|
725
|
+
questionFlag: 1,
|
|
726
|
+
mobileDetectionFlag: 1,
|
|
727
|
+
storeOpenCloseFlag: 1,
|
|
728
|
+
uniformDetectionFlag: 1,
|
|
729
|
+
customerunattendedFlag: 1,
|
|
730
|
+
staffleftinthemiddleFlag: 1,
|
|
731
|
+
},
|
|
732
|
+
} );
|
|
733
|
+
rangeOneFindQuery.push( {
|
|
734
|
+
$group: {
|
|
735
|
+
_id: '',
|
|
736
|
+
totalFlag: {
|
|
737
|
+
$sum: {
|
|
738
|
+
$cond: [ {
|
|
739
|
+
$or: [
|
|
740
|
+
{ $gt: [ '$questionFlag', 0 ] },
|
|
741
|
+
{ $gt: [ '$timeFlag', 0 ] },
|
|
742
|
+
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
743
|
+
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
744
|
+
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
745
|
+
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
746
|
+
{ $gt: [ '$staffleftinthemiddle', 0 ] },
|
|
747
|
+
],
|
|
748
|
+
}, 1, 0 ],
|
|
749
|
+
},
|
|
750
|
+
},
|
|
751
|
+
questionFlag: {
|
|
752
|
+
$sum: {
|
|
753
|
+
$cond: [
|
|
754
|
+
{
|
|
755
|
+
$and: [
|
|
756
|
+
{ $gt: [ '$questionFlag', 0 ] },
|
|
757
|
+
],
|
|
758
|
+
}, 1, 0 ],
|
|
759
|
+
},
|
|
760
|
+
},
|
|
761
|
+
delayInSubmission: {
|
|
762
|
+
$sum: {
|
|
763
|
+
$cond: [
|
|
764
|
+
{
|
|
765
|
+
$and: [
|
|
766
|
+
{ $gt: [ '$timeFlag', 0 ] },
|
|
767
|
+
],
|
|
768
|
+
}, 1, 0 ],
|
|
769
|
+
},
|
|
770
|
+
},
|
|
771
|
+
detectionFlag: {
|
|
772
|
+
$sum: {
|
|
773
|
+
$cond: [ {
|
|
774
|
+
$or: [
|
|
775
|
+
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
776
|
+
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
777
|
+
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
778
|
+
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
779
|
+
{ $gt: [ '$staffleftinthemiddleFlag', 0 ] },
|
|
780
|
+
],
|
|
781
|
+
}, 1, 0 ],
|
|
782
|
+
},
|
|
783
|
+
},
|
|
784
|
+
},
|
|
785
|
+
} );
|
|
786
|
+
let rangeOneData = await processedchecklistService.aggregate( rangeOneFindQuery );
|
|
787
|
+
console.log( 'rangeOneData =>', rangeOneData );
|
|
788
|
+
|
|
789
|
+
let rangeTwoFindQuery = [];
|
|
790
|
+
let rangeTwoFindAndQuery = [];
|
|
791
|
+
rangeTwoFindAndQuery.push(
|
|
792
|
+
{ client_id: requestData.clientId },
|
|
793
|
+
{ store_id: { $in: requestData.storeId } },
|
|
794
|
+
{ date_iso: { $gte: fromDate } },
|
|
795
|
+
{ date_iso: { $lte: toDate } },
|
|
796
|
+
);
|
|
797
|
+
rangeTwoFindQuery.push( { $match: { $and: rangeOneFindAndQuery } } );
|
|
798
|
+
rangeTwoFindQuery.push( {
|
|
799
|
+
$project: {
|
|
800
|
+
timeFlag: 1,
|
|
801
|
+
questionFlag: 1,
|
|
802
|
+
mobileDetectionFlag: 1,
|
|
803
|
+
storeOpenCloseFlag: 1,
|
|
804
|
+
uniformDetectionFlag: 1,
|
|
805
|
+
customerunattendedFlag: 1,
|
|
806
|
+
staffleftinthemiddleFlag: 1,
|
|
807
|
+
},
|
|
808
|
+
} );
|
|
809
|
+
rangeTwoFindQuery.push( {
|
|
810
|
+
$group: {
|
|
811
|
+
_id: '',
|
|
812
|
+
totalFlag: {
|
|
813
|
+
$sum: {
|
|
814
|
+
$cond: [ {
|
|
815
|
+
$or: [
|
|
816
|
+
{ $gt: [ '$questionFlag', 0 ] },
|
|
817
|
+
{ $gt: [ '$timeFlag', 0 ] },
|
|
818
|
+
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
819
|
+
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
820
|
+
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
821
|
+
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
822
|
+
{ $gt: [ '$staffleftinthemiddle', 0 ] },
|
|
823
|
+
],
|
|
824
|
+
}, 1, 0 ],
|
|
825
|
+
},
|
|
826
|
+
},
|
|
827
|
+
questionFlag: {
|
|
828
|
+
$sum: {
|
|
829
|
+
$cond: [
|
|
830
|
+
{
|
|
831
|
+
$and: [
|
|
832
|
+
{ $gt: [ '$questionFlag', 0 ] },
|
|
833
|
+
],
|
|
834
|
+
}, 1, 0 ],
|
|
835
|
+
},
|
|
836
|
+
},
|
|
837
|
+
delayInSubmission: {
|
|
838
|
+
$sum: {
|
|
839
|
+
$cond: [
|
|
840
|
+
{
|
|
841
|
+
$and: [
|
|
842
|
+
{ $gt: [ '$timeFlag', 0 ] },
|
|
843
|
+
],
|
|
844
|
+
}, 1, 0 ],
|
|
845
|
+
},
|
|
846
|
+
},
|
|
847
|
+
detectionFlag: {
|
|
848
|
+
$sum: {
|
|
849
|
+
$cond: [ {
|
|
850
|
+
$or: [
|
|
851
|
+
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
852
|
+
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
853
|
+
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
854
|
+
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
855
|
+
{ $gt: [ '$staffleftinthemiddleFlag', 0 ] },
|
|
856
|
+
],
|
|
857
|
+
}, 1, 0 ],
|
|
858
|
+
},
|
|
859
|
+
},
|
|
860
|
+
},
|
|
861
|
+
} );
|
|
862
|
+
let rangeTwoData = await processedchecklistService.aggregate( rangeTwoFindQuery );
|
|
863
|
+
console.log( 'rangeTwoData =>', rangeTwoData );
|
|
864
|
+
|
|
865
|
+
if ( rangeOneData.length >0 && rangeTwoData.length >0 ) {
|
|
866
|
+
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
let result = {
|
|
870
|
+
'flagComparisonCards': flagComparisonCards,
|
|
871
|
+
};
|
|
872
|
+
return res.sendSuccess( result );
|
|
873
|
+
} catch ( error ) {
|
|
874
|
+
console.log( 'error =>', error );
|
|
875
|
+
logger.error( { error: error, function: 'subscribedStoreList' } );
|
|
876
|
+
return res.sendError( error, 500 );
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
|
|
499
880
|
async function checklistCardData( checklistType ) {
|
|
500
881
|
try {
|
|
501
882
|
let resData = {};
|
|
@@ -1014,30 +1395,6 @@ async function tableData( checklistType ) {
|
|
|
1014
1395
|
}
|
|
1015
1396
|
}
|
|
1016
1397
|
|
|
1017
|
-
export const flagCards = async ( req, res ) => {
|
|
1018
|
-
try {
|
|
1019
|
-
let requestData = req.body;
|
|
1020
|
-
let resultData = await flagCardData( requestData.checklistType );
|
|
1021
|
-
return res.sendSuccess( resultData );
|
|
1022
|
-
} catch ( error ) {
|
|
1023
|
-
console.log( 'error =>', error );
|
|
1024
|
-
logger.error( { error: error, function: 'subscribedStoreList' } );
|
|
1025
|
-
return res.sendError( error, 500 );
|
|
1026
|
-
}
|
|
1027
|
-
};
|
|
1028
|
-
|
|
1029
|
-
export const flagComparisonCards = async ( req, res ) => {
|
|
1030
|
-
try {
|
|
1031
|
-
let requestData = req.body;
|
|
1032
|
-
let resultData = await falgComparisonData( requestData.checklistType );
|
|
1033
|
-
return res.sendSuccess( resultData );
|
|
1034
|
-
} catch ( error ) {
|
|
1035
|
-
console.log( 'error =>', error );
|
|
1036
|
-
logger.error( { error: error, function: 'subscribedStoreList' } );
|
|
1037
|
-
return res.sendError( error, 500 );
|
|
1038
|
-
}
|
|
1039
|
-
};
|
|
1040
|
-
|
|
1041
1398
|
async function flagCardData( checklistType ) {
|
|
1042
1399
|
try {
|
|
1043
1400
|
let resData = {};
|
|
@@ -1072,215 +1429,92 @@ async function falgComparisonData( checklistType ) {
|
|
|
1072
1429
|
'comparisonData': 50,
|
|
1073
1430
|
'ComparisonFlag': false,
|
|
1074
1431
|
},
|
|
1075
|
-
'detectionComparisonFlag': {
|
|
1076
|
-
'comparisonData': 20,
|
|
1077
|
-
'ComparisonFlag': true,
|
|
1078
|
-
},
|
|
1079
|
-
};
|
|
1080
|
-
return resData;
|
|
1081
|
-
} catch ( error ) {
|
|
1082
|
-
console.log( 'error =>', error );
|
|
1083
|
-
logger.error( { error: error, message: data, function: 'returnServerError' } );
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
export const flagTables = async ( req, res ) => {
|
|
1088
|
-
try {
|
|
1089
|
-
let requestData = req.body;
|
|
1090
|
-
let resultData = await flagTableData( requestData.checklistType );
|
|
1091
|
-
return res.sendSuccess( resultData );
|
|
1092
|
-
} catch ( error ) {
|
|
1093
|
-
console.log( 'error =>', error );
|
|
1094
|
-
logger.error( { error: error, function: 'subscribedStoreList' } );
|
|
1095
|
-
return res.sendError( error, 500 );
|
|
1096
|
-
}
|
|
1097
|
-
};
|
|
1098
|
-
|
|
1099
|
-
async function flagTableData( checklistType ) {
|
|
1100
|
-
try {
|
|
1101
|
-
let resData = {};
|
|
1102
|
-
resData.flagTableData = [
|
|
1103
|
-
{
|
|
1104
|
-
'checklistName': 'Field VM- Store Visit Checklist',
|
|
1105
|
-
'sourceCheckList_id': '668e3e1807d5312fa49b0046',
|
|
1106
|
-
'checkListType': 'custom',
|
|
1107
|
-
'flagType': 'Question',
|
|
1108
|
-
'assignedStores': 400,
|
|
1109
|
-
'flaggedStores': 50,
|
|
1110
|
-
'flagCount': 30,
|
|
1111
|
-
'complianceRate': 25,
|
|
1112
|
-
},
|
|
1113
|
-
{
|
|
1114
|
-
'checklistName': 'DC Prep Checklist',
|
|
1115
|
-
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1116
|
-
'checkListType': 'custom',
|
|
1117
|
-
'flagType': 'Question',
|
|
1118
|
-
'assignedStores': 500,
|
|
1119
|
-
'flaggedStores': 66,
|
|
1120
|
-
'flagCount': 66,
|
|
1121
|
-
'complianceRate': 89,
|
|
1122
|
-
},
|
|
1123
|
-
{
|
|
1124
|
-
'checklistName': 'Store Open and Close',
|
|
1125
|
-
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1126
|
-
'checkListType': 'storeopenandclose',
|
|
1127
|
-
'flagType': 'Question',
|
|
1128
|
-
'assignedStores': 300,
|
|
1129
|
-
'flaggedStores': 70,
|
|
1130
|
-
'flagCount': 80,
|
|
1131
|
-
'complianceRate': 25,
|
|
1132
|
-
},
|
|
1133
|
-
{
|
|
1134
|
-
'checklistName': 'Mobileusage Detection',
|
|
1135
|
-
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1136
|
-
'checkListType': 'mobileusagedetection',
|
|
1137
|
-
'flagType': 'Detection',
|
|
1138
|
-
'assignedStores': 250,
|
|
1139
|
-
'flaggedStores': 30,
|
|
1140
|
-
'flagCount': 80,
|
|
1141
|
-
'complianceRate': 77,
|
|
1142
|
-
},
|
|
1143
|
-
{
|
|
1144
|
-
'checklistName': 'Uniform Detection',
|
|
1145
|
-
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1146
|
-
'checkListType': 'uniformdetection',
|
|
1147
|
-
'flagType': 'Detection',
|
|
1148
|
-
'assignedStores': 100,
|
|
1149
|
-
'flaggedStores': 0,
|
|
1150
|
-
'flagCount': 60,
|
|
1151
|
-
'complianceRate': 45,
|
|
1152
|
-
},
|
|
1153
|
-
{
|
|
1154
|
-
'checklistName': 'Customer Unattended',
|
|
1155
|
-
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1156
|
-
'checkListType': 'customerunattended',
|
|
1157
|
-
'flagType': 'Detection',
|
|
1158
|
-
'assignedStores': 200,
|
|
1159
|
-
'flaggedStores': 20,
|
|
1160
|
-
'flagCount': 70,
|
|
1161
|
-
'complianceRate': 55,
|
|
1162
|
-
},
|
|
1163
|
-
{
|
|
1164
|
-
'checklistName': 'Staff Left in The Middle',
|
|
1165
|
-
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1166
|
-
'checkListType': 'staffleftinthemiddle',
|
|
1167
|
-
'flagType': 'Detection',
|
|
1168
|
-
'assignedStores': 150,
|
|
1169
|
-
'flaggedStores': 50,
|
|
1170
|
-
'flagCount': 50,
|
|
1171
|
-
'complianceRate': 30,
|
|
1172
|
-
},
|
|
1173
|
-
];
|
|
1174
|
-
return resData;
|
|
1175
|
-
} catch ( error ) {
|
|
1176
|
-
console.log( 'error =>', error );
|
|
1177
|
-
logger.error( { error: error, message: data, function: 'returnServerError' } );
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
export const checklistDropdown = async ( req, res ) => {
|
|
1182
|
-
try {
|
|
1183
|
-
let requestData = req.body;
|
|
1184
|
-
let resultData = await checklistDropdownData( requestData.checklistType );
|
|
1185
|
-
return res.sendSuccess( resultData );
|
|
1432
|
+
'detectionComparisonFlag': {
|
|
1433
|
+
'comparisonData': 20,
|
|
1434
|
+
'ComparisonFlag': true,
|
|
1435
|
+
},
|
|
1436
|
+
};
|
|
1437
|
+
return resData;
|
|
1186
1438
|
} catch ( error ) {
|
|
1187
1439
|
console.log( 'error =>', error );
|
|
1188
|
-
logger.error( { error: error, function: '
|
|
1189
|
-
return res.sendError( error, 500 );
|
|
1440
|
+
logger.error( { error: error, message: data, function: 'returnServerError' } );
|
|
1190
1441
|
}
|
|
1191
|
-
}
|
|
1442
|
+
}
|
|
1192
1443
|
|
|
1193
|
-
async function
|
|
1444
|
+
async function flagTableData( checklistType ) {
|
|
1194
1445
|
try {
|
|
1195
1446
|
let resData = {};
|
|
1196
|
-
resData.
|
|
1447
|
+
resData.totalCount = 300;
|
|
1448
|
+
resData.flagTableData = [
|
|
1197
1449
|
{
|
|
1198
1450
|
'checklistName': 'Field VM- Store Visit Checklist',
|
|
1199
1451
|
'sourceCheckList_id': '668e3e1807d5312fa49b0046',
|
|
1200
1452
|
'checkListType': 'custom',
|
|
1201
|
-
'
|
|
1202
|
-
'
|
|
1203
|
-
'
|
|
1204
|
-
'
|
|
1205
|
-
'
|
|
1206
|
-
'publish': true,
|
|
1453
|
+
'flagType': 'Question',
|
|
1454
|
+
'assignedStores': 400,
|
|
1455
|
+
'flaggedStores': 50,
|
|
1456
|
+
'flagCount': 30,
|
|
1457
|
+
'complianceRate': 25,
|
|
1207
1458
|
},
|
|
1208
1459
|
{
|
|
1209
1460
|
'checklistName': 'DC Prep Checklist',
|
|
1210
1461
|
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1211
1462
|
'checkListType': 'custom',
|
|
1212
|
-
'
|
|
1213
|
-
'
|
|
1214
|
-
'
|
|
1215
|
-
'
|
|
1216
|
-
'
|
|
1217
|
-
'publish': true,
|
|
1463
|
+
'flagType': 'Question',
|
|
1464
|
+
'assignedStores': 500,
|
|
1465
|
+
'flaggedStores': 66,
|
|
1466
|
+
'flagCount': 66,
|
|
1467
|
+
'complianceRate': 89,
|
|
1218
1468
|
},
|
|
1219
1469
|
{
|
|
1220
1470
|
'checklistName': 'Store Open and Close',
|
|
1221
1471
|
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1222
1472
|
'checkListType': 'storeopenandclose',
|
|
1223
|
-
'
|
|
1224
|
-
'
|
|
1225
|
-
'
|
|
1226
|
-
'
|
|
1227
|
-
'
|
|
1228
|
-
'publish': true,
|
|
1473
|
+
'flagType': 'Question',
|
|
1474
|
+
'assignedStores': 300,
|
|
1475
|
+
'flaggedStores': 70,
|
|
1476
|
+
'flagCount': 80,
|
|
1477
|
+
'complianceRate': 25,
|
|
1229
1478
|
},
|
|
1230
1479
|
{
|
|
1231
1480
|
'checklistName': 'Mobileusage Detection',
|
|
1232
1481
|
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1233
1482
|
'checkListType': 'mobileusagedetection',
|
|
1234
|
-
'
|
|
1235
|
-
'
|
|
1236
|
-
'
|
|
1237
|
-
'
|
|
1238
|
-
'
|
|
1239
|
-
'publish': true,
|
|
1483
|
+
'flagType': 'Detection',
|
|
1484
|
+
'assignedStores': 250,
|
|
1485
|
+
'flaggedStores': 30,
|
|
1486
|
+
'flagCount': 80,
|
|
1487
|
+
'complianceRate': 77,
|
|
1240
1488
|
},
|
|
1241
1489
|
{
|
|
1242
1490
|
'checklistName': 'Uniform Detection',
|
|
1243
1491
|
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1244
1492
|
'checkListType': 'uniformdetection',
|
|
1245
|
-
'
|
|
1246
|
-
'
|
|
1247
|
-
'
|
|
1248
|
-
'
|
|
1249
|
-
'
|
|
1250
|
-
'publish': true,
|
|
1493
|
+
'flagType': 'Detection',
|
|
1494
|
+
'assignedStores': 100,
|
|
1495
|
+
'flaggedStores': 0,
|
|
1496
|
+
'flagCount': 60,
|
|
1497
|
+
'complianceRate': 45,
|
|
1251
1498
|
},
|
|
1252
1499
|
{
|
|
1253
1500
|
'checklistName': 'Customer Unattended',
|
|
1254
1501
|
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1255
1502
|
'checkListType': 'customerunattended',
|
|
1256
|
-
'
|
|
1257
|
-
'
|
|
1258
|
-
'
|
|
1259
|
-
'
|
|
1260
|
-
'
|
|
1261
|
-
'publish': true,
|
|
1503
|
+
'flagType': 'Detection',
|
|
1504
|
+
'assignedStores': 200,
|
|
1505
|
+
'flaggedStores': 20,
|
|
1506
|
+
'flagCount': 70,
|
|
1507
|
+
'complianceRate': 55,
|
|
1262
1508
|
},
|
|
1263
1509
|
{
|
|
1264
1510
|
'checklistName': 'Staff Left in The Middle',
|
|
1265
1511
|
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1266
1512
|
'checkListType': 'staffleftinthemiddle',
|
|
1267
|
-
'
|
|
1268
|
-
'
|
|
1269
|
-
'
|
|
1270
|
-
'
|
|
1271
|
-
'
|
|
1272
|
-
'publish': true,
|
|
1273
|
-
},
|
|
1274
|
-
{
|
|
1275
|
-
'checklistName': 'Field VM- Store Visit Checklist Field VM- Store Visit Checklist',
|
|
1276
|
-
'sourceCheckList_id': '668e3e1807d5312fa49b0046',
|
|
1277
|
-
'checkListType': 'custom',
|
|
1278
|
-
'createdByName': 'Yamini',
|
|
1279
|
-
'storeCount': 1853,
|
|
1280
|
-
'scheduleRepeatedType': 'weekly',
|
|
1281
|
-
'scheduleStartTime': '12:00 PM',
|
|
1282
|
-
'scheduleEndTime': '06:00 PM',
|
|
1283
|
-
'publish': true,
|
|
1513
|
+
'flagType': 'Detection',
|
|
1514
|
+
'assignedStores': 150,
|
|
1515
|
+
'flaggedStores': 50,
|
|
1516
|
+
'flagCount': 50,
|
|
1517
|
+
'complianceRate': 30,
|
|
1284
1518
|
},
|
|
1285
1519
|
];
|
|
1286
1520
|
return resData;
|
|
@@ -1288,337 +1522,104 @@ async function checklistDropdownData( checklistType ) {
|
|
|
1288
1522
|
console.log( 'error =>', error );
|
|
1289
1523
|
logger.error( { error: error, message: data, function: 'returnServerError' } );
|
|
1290
1524
|
}
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
export const flagCardsV1 = async ( req, res ) => {
|
|
1294
|
-
try {
|
|
1295
|
-
let requestData = req.body;
|
|
1296
|
-
let fromDate = new Date( requestData.fromDate );
|
|
1297
|
-
let toDate = new Date( requestData.toDate );
|
|
1298
|
-
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
1299
|
-
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
1300
|
-
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
1301
|
-
|
|
1302
|
-
let flagCards = {
|
|
1303
|
-
'totalFlag': 0,
|
|
1304
|
-
'questionFlag': {
|
|
1305
|
-
'count': 0,
|
|
1306
|
-
},
|
|
1307
|
-
'delayInSubmission': {
|
|
1308
|
-
'count': 0,
|
|
1309
|
-
},
|
|
1310
|
-
'detectionFlag': {
|
|
1311
|
-
'count': 0,
|
|
1312
|
-
},
|
|
1313
|
-
};
|
|
1314
|
-
|
|
1315
|
-
let findQuery = [];
|
|
1316
|
-
let findAndQuery = [];
|
|
1317
|
-
findAndQuery.push(
|
|
1318
|
-
{ client_id: requestData.clientId },
|
|
1319
|
-
{ store_id: { $in: requestData.storeId } },
|
|
1320
|
-
{ date_iso: { $gte: fromDate } },
|
|
1321
|
-
{ date_iso: { $lte: toDate } },
|
|
1322
|
-
);
|
|
1323
|
-
|
|
1324
|
-
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
1325
|
-
|
|
1326
|
-
findQuery.push( {
|
|
1327
|
-
$project: {
|
|
1328
|
-
timeFlag: 1,
|
|
1329
|
-
questionFlag: 1,
|
|
1330
|
-
mobileDetectionFlag: 1,
|
|
1331
|
-
storeOpenCloseFlag: 1,
|
|
1332
|
-
uniformDetectionFlag: 1,
|
|
1333
|
-
customerunattendedFlag: 1,
|
|
1334
|
-
staffleftinthemiddleFlag: 1,
|
|
1335
|
-
},
|
|
1336
|
-
} );
|
|
1337
|
-
|
|
1338
|
-
findQuery.push( {
|
|
1339
|
-
$group: {
|
|
1340
|
-
_id: '',
|
|
1341
|
-
totalFlag: {
|
|
1342
|
-
$sum: {
|
|
1343
|
-
$cond: [ {
|
|
1344
|
-
$or: [
|
|
1345
|
-
{ $gt: [ '$questionFlag', 0 ] },
|
|
1346
|
-
{ $gt: [ '$timeFlag', 0 ] },
|
|
1347
|
-
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
1348
|
-
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
1349
|
-
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
1350
|
-
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
1351
|
-
{ $gt: [ '$staffleftinthemiddleFlag', 0 ] },
|
|
1352
|
-
],
|
|
1353
|
-
}, 1, 0 ],
|
|
1354
|
-
},
|
|
1355
|
-
},
|
|
1356
|
-
questionFlag: {
|
|
1357
|
-
$sum: {
|
|
1358
|
-
$cond: [
|
|
1359
|
-
{
|
|
1360
|
-
$and: [
|
|
1361
|
-
{ $gt: [ '$questionFlag', 0 ] },
|
|
1362
|
-
],
|
|
1363
|
-
}, 1, 0 ],
|
|
1364
|
-
},
|
|
1365
|
-
},
|
|
1366
|
-
delayInSubmission: {
|
|
1367
|
-
$sum: {
|
|
1368
|
-
$cond: [
|
|
1369
|
-
{
|
|
1370
|
-
$and: [
|
|
1371
|
-
{ $gt: [ '$timeFlag', 0 ] },
|
|
1372
|
-
],
|
|
1373
|
-
}, 1, 0 ],
|
|
1374
|
-
},
|
|
1375
|
-
},
|
|
1376
|
-
detectionFlag: {
|
|
1377
|
-
$sum: {
|
|
1378
|
-
$cond: [ {
|
|
1379
|
-
$or: [
|
|
1380
|
-
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
1381
|
-
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
1382
|
-
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
1383
|
-
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
1384
|
-
{ $gt: [ '$staffleftinthemiddleFlag', 0 ] },
|
|
1385
|
-
],
|
|
1386
|
-
}, 1, 0 ],
|
|
1387
|
-
},
|
|
1388
|
-
},
|
|
1389
|
-
},
|
|
1390
|
-
} );
|
|
1391
|
-
let getOverallChecklistData = await processedchecklistService.aggregate( findQuery );
|
|
1392
|
-
if ( !getOverallChecklistData.length ) {
|
|
1393
|
-
return res.sendError( { error: 'No Data Found' }, 204 );
|
|
1394
|
-
}
|
|
1395
|
-
console.log( 'getOverallChecklistData =>', getOverallChecklistData );
|
|
1396
|
-
if ( getOverallChecklistData.length && getOverallChecklistData.length>0 ) {
|
|
1397
|
-
if ( getOverallChecklistData[0].totalFlag ) {
|
|
1398
|
-
flagCards.totalFlag = getOverallChecklistData[0]?.totalFlag;
|
|
1399
|
-
}
|
|
1400
|
-
if ( getOverallChecklistData[0].questionFlag ) {
|
|
1401
|
-
flagCards.questionFlag.count = getOverallChecklistData[0]?.questionFlag;
|
|
1402
|
-
}
|
|
1403
|
-
if ( getOverallChecklistData[0].delayInSubmission ) {
|
|
1404
|
-
flagCards.delayInSubmission.count = getOverallChecklistData[0]?.delayInSubmission;
|
|
1405
|
-
}
|
|
1406
|
-
if ( getOverallChecklistData[0].detectionFlag ) {
|
|
1407
|
-
flagCards.detectionFlag.count = getOverallChecklistData[0]?.detectionFlag;
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
let result = {
|
|
1411
|
-
'flagCards': flagCards,
|
|
1412
|
-
};
|
|
1413
|
-
console.log( 'getOverallChecklistData =>', getOverallChecklistData );
|
|
1414
|
-
// let resultData = await flagCardData( requestData.checklistType );
|
|
1415
|
-
return res.sendSuccess( result );
|
|
1416
|
-
} catch ( error ) {
|
|
1417
|
-
console.log( 'error =>', error );
|
|
1418
|
-
logger.error( { error: error, function: 'subscribedStoreList' } );
|
|
1419
|
-
return res.sendError( error, 500 );
|
|
1420
|
-
}
|
|
1421
|
-
};
|
|
1422
|
-
|
|
1423
|
-
export const flagComparisonCardsV1 = async ( req, res ) => {
|
|
1424
|
-
try {
|
|
1425
|
-
let requestData = req.body;
|
|
1426
|
-
let fromDate = new Date( requestData.fromDate );
|
|
1427
|
-
let toDate = new Date( requestData.toDate );
|
|
1428
|
-
let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
|
|
1429
|
-
toDate = new Date( toDate.getTime() - userTimezoneOffset );
|
|
1430
|
-
toDate.setUTCHours( 23, 59, 59, 59 );
|
|
1431
|
-
|
|
1432
|
-
let rangeOneFromDate = new Date( requestData.toDate );
|
|
1433
|
-
rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 6 );
|
|
1434
|
-
let rangeOneToDate = new Date( requestData.toDate );
|
|
1435
|
-
rangeOneToDate = new Date( rangeOneToDate.getTime() - userTimezoneOffset );
|
|
1436
|
-
rangeOneToDate.setUTCHours( 23, 59, 59, 59 );
|
|
1437
|
-
let rangeTwoToDate = new Date( requestData.toDate );
|
|
1438
|
-
rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 7 );
|
|
1439
|
-
let rangeTwoFromDate = new Date( rangeTwoToDate );
|
|
1440
|
-
rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 6 );
|
|
1441
|
-
rangeTwoToDate = new Date( rangeTwoToDate.getTime() - userTimezoneOffset );
|
|
1442
|
-
rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
|
|
1525
|
+
}
|
|
1443
1526
|
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1527
|
+
async function checklistDropdownData( checklistType ) {
|
|
1528
|
+
try {
|
|
1529
|
+
let resData = {};
|
|
1530
|
+
resData.checklistDropdownData = [
|
|
1531
|
+
{
|
|
1532
|
+
'checklistName': 'Field VM- Store Visit Checklist',
|
|
1533
|
+
'sourceCheckList_id': '668e3e1807d5312fa49b0046',
|
|
1534
|
+
'checkListType': 'custom',
|
|
1535
|
+
'createdByName': 'Yamini',
|
|
1536
|
+
'storeCount': 1853,
|
|
1537
|
+
'scheduleRepeatedType': 'weekly',
|
|
1538
|
+
'scheduleStartTime': '12:00 PM',
|
|
1539
|
+
'scheduleEndTime': '06:00 PM',
|
|
1540
|
+
'publish': true,
|
|
1448
1541
|
},
|
|
1449
|
-
|
|
1450
|
-
'
|
|
1451
|
-
'
|
|
1542
|
+
{
|
|
1543
|
+
'checklistName': 'DC Prep Checklist',
|
|
1544
|
+
'sourceCheckList_id': '6690d95b747d2cc1f1167361',
|
|
1545
|
+
'checkListType': 'custom',
|
|
1546
|
+
'createdByName': 'Yamini',
|
|
1547
|
+
'storeCount': 1853,
|
|
1548
|
+
'scheduleRepeatedType': 'weekly',
|
|
1549
|
+
'scheduleStartTime': '12:00 PM',
|
|
1550
|
+
'scheduleEndTime': '06:00 PM',
|
|
1551
|
+
'publish': true,
|
|
1452
1552
|
},
|
|
1453
|
-
|
|
1454
|
-
'
|
|
1455
|
-
'
|
|
1553
|
+
{
|
|
1554
|
+
'checklistName': 'Store Open and Close',
|
|
1555
|
+
'sourceCheckList_id': '6690d95b747d2cc1f1167362',
|
|
1556
|
+
'checkListType': 'storeopenandclose',
|
|
1557
|
+
'createdByName': 'Yamini',
|
|
1558
|
+
'storeCount': 1853,
|
|
1559
|
+
'scheduleRepeatedType': 'weekly',
|
|
1560
|
+
'scheduleStartTime': '12:00 PM',
|
|
1561
|
+
'scheduleEndTime': '06:00 PM',
|
|
1562
|
+
'publish': true,
|
|
1456
1563
|
},
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
rangeOneFindQuery.push( { $match: { $and: rangeOneFindAndQuery } } );
|
|
1468
|
-
rangeOneFindQuery.push( {
|
|
1469
|
-
$project: {
|
|
1470
|
-
timeFlag: 1,
|
|
1471
|
-
questionFlag: 1,
|
|
1472
|
-
mobileDetectionFlag: 1,
|
|
1473
|
-
storeOpenCloseFlag: 1,
|
|
1474
|
-
uniformDetectionFlag: 1,
|
|
1475
|
-
customerunattendedFlag: 1,
|
|
1476
|
-
staffleftinthemiddleFlag: 1,
|
|
1564
|
+
{
|
|
1565
|
+
'checklistName': 'Mobileusage Detection',
|
|
1566
|
+
'sourceCheckList_id': '6690d95b747d2cc1f1167363',
|
|
1567
|
+
'checkListType': 'mobileusagedetection',
|
|
1568
|
+
'createdByName': 'Yamini',
|
|
1569
|
+
'storeCount': 1853,
|
|
1570
|
+
'scheduleRepeatedType': 'weekly',
|
|
1571
|
+
'scheduleStartTime': '12:00 PM',
|
|
1572
|
+
'scheduleEndTime': '06:00 PM',
|
|
1573
|
+
'publish': true,
|
|
1477
1574
|
},
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
1489
|
-
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
1490
|
-
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
1491
|
-
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
1492
|
-
{ $gt: [ '$staffleftinthemiddle', 0 ] },
|
|
1493
|
-
],
|
|
1494
|
-
}, 1, 0 ],
|
|
1495
|
-
},
|
|
1496
|
-
},
|
|
1497
|
-
questionFlag: {
|
|
1498
|
-
$sum: {
|
|
1499
|
-
$cond: [
|
|
1500
|
-
{
|
|
1501
|
-
$and: [
|
|
1502
|
-
{ $gt: [ '$questionFlag', 0 ] },
|
|
1503
|
-
],
|
|
1504
|
-
}, 1, 0 ],
|
|
1505
|
-
},
|
|
1506
|
-
},
|
|
1507
|
-
delayInSubmission: {
|
|
1508
|
-
$sum: {
|
|
1509
|
-
$cond: [
|
|
1510
|
-
{
|
|
1511
|
-
$and: [
|
|
1512
|
-
{ $gt: [ '$timeFlag', 0 ] },
|
|
1513
|
-
],
|
|
1514
|
-
}, 1, 0 ],
|
|
1515
|
-
},
|
|
1516
|
-
},
|
|
1517
|
-
detectionFlag: {
|
|
1518
|
-
$sum: {
|
|
1519
|
-
$cond: [ {
|
|
1520
|
-
$or: [
|
|
1521
|
-
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
1522
|
-
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
1523
|
-
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
1524
|
-
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
1525
|
-
{ $gt: [ '$staffleftinthemiddleFlag', 0 ] },
|
|
1526
|
-
],
|
|
1527
|
-
}, 1, 0 ],
|
|
1528
|
-
},
|
|
1529
|
-
},
|
|
1575
|
+
{
|
|
1576
|
+
'checklistName': 'Uniform Detection',
|
|
1577
|
+
'sourceCheckList_id': '6690d95b747d2cc1f1167364',
|
|
1578
|
+
'checkListType': 'uniformdetection',
|
|
1579
|
+
'createdByName': 'Yamini',
|
|
1580
|
+
'storeCount': 1853,
|
|
1581
|
+
'scheduleRepeatedType': 'weekly',
|
|
1582
|
+
'scheduleStartTime': '12:00 PM',
|
|
1583
|
+
'scheduleEndTime': '06:00 PM',
|
|
1584
|
+
'publish': true,
|
|
1530
1585
|
},
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
{ date_iso: { $lte: toDate } },
|
|
1542
|
-
);
|
|
1543
|
-
rangeTwoFindQuery.push( { $match: { $and: rangeOneFindAndQuery } } );
|
|
1544
|
-
rangeTwoFindQuery.push( {
|
|
1545
|
-
$project: {
|
|
1546
|
-
timeFlag: 1,
|
|
1547
|
-
questionFlag: 1,
|
|
1548
|
-
mobileDetectionFlag: 1,
|
|
1549
|
-
storeOpenCloseFlag: 1,
|
|
1550
|
-
uniformDetectionFlag: 1,
|
|
1551
|
-
customerunattendedFlag: 1,
|
|
1552
|
-
staffleftinthemiddleFlag: 1,
|
|
1586
|
+
{
|
|
1587
|
+
'checklistName': 'Customer Unattended',
|
|
1588
|
+
'sourceCheckList_id': '6690d95b747d2cc1f1167365',
|
|
1589
|
+
'checkListType': 'customerunattended',
|
|
1590
|
+
'createdByName': 'Yamini',
|
|
1591
|
+
'storeCount': 1853,
|
|
1592
|
+
'scheduleRepeatedType': 'weekly',
|
|
1593
|
+
'scheduleStartTime': '12:00 PM',
|
|
1594
|
+
'scheduleEndTime': '06:00 PM',
|
|
1595
|
+
'publish': true,
|
|
1553
1596
|
},
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
1565
|
-
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
1566
|
-
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
1567
|
-
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
1568
|
-
{ $gt: [ '$staffleftinthemiddle', 0 ] },
|
|
1569
|
-
],
|
|
1570
|
-
}, 1, 0 ],
|
|
1571
|
-
},
|
|
1572
|
-
},
|
|
1573
|
-
questionFlag: {
|
|
1574
|
-
$sum: {
|
|
1575
|
-
$cond: [
|
|
1576
|
-
{
|
|
1577
|
-
$and: [
|
|
1578
|
-
{ $gt: [ '$questionFlag', 0 ] },
|
|
1579
|
-
],
|
|
1580
|
-
}, 1, 0 ],
|
|
1581
|
-
},
|
|
1582
|
-
},
|
|
1583
|
-
delayInSubmission: {
|
|
1584
|
-
$sum: {
|
|
1585
|
-
$cond: [
|
|
1586
|
-
{
|
|
1587
|
-
$and: [
|
|
1588
|
-
{ $gt: [ '$timeFlag', 0 ] },
|
|
1589
|
-
],
|
|
1590
|
-
}, 1, 0 ],
|
|
1591
|
-
},
|
|
1592
|
-
},
|
|
1593
|
-
detectionFlag: {
|
|
1594
|
-
$sum: {
|
|
1595
|
-
$cond: [ {
|
|
1596
|
-
$or: [
|
|
1597
|
-
{ $gt: [ '$storeOpenCloseFlag', 0 ] },
|
|
1598
|
-
{ $gt: [ '$mobileDetectionFlag', 0 ] },
|
|
1599
|
-
{ $gt: [ '$uniformDetectionFlag', 0 ] },
|
|
1600
|
-
{ $gt: [ '$customerunattendedFlag', 0 ] },
|
|
1601
|
-
{ $gt: [ '$staffleftinthemiddleFlag', 0 ] },
|
|
1602
|
-
],
|
|
1603
|
-
}, 1, 0 ],
|
|
1604
|
-
},
|
|
1605
|
-
},
|
|
1597
|
+
{
|
|
1598
|
+
'checklistName': 'Staff Left in The Middle',
|
|
1599
|
+
'sourceCheckList_id': '6690d95b747d2cc1f1167366',
|
|
1600
|
+
'checkListType': 'staffleftinthemiddle',
|
|
1601
|
+
'createdByName': 'Yamini',
|
|
1602
|
+
'storeCount': 1853,
|
|
1603
|
+
'scheduleRepeatedType': 'weekly',
|
|
1604
|
+
'scheduleStartTime': '12:00 PM',
|
|
1605
|
+
'scheduleEndTime': '06:00 PM',
|
|
1606
|
+
'publish': true,
|
|
1606
1607
|
},
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1608
|
+
{
|
|
1609
|
+
'checklistName': 'Field VM- Store Visit Checklist Field VM- Store Visit Checklist',
|
|
1610
|
+
'sourceCheckList_id': '668e3e1807d5312fa49b0046',
|
|
1611
|
+
'checkListType': 'custom',
|
|
1612
|
+
'createdByName': 'Yamini',
|
|
1613
|
+
'storeCount': 1853,
|
|
1614
|
+
'scheduleRepeatedType': 'weekly',
|
|
1615
|
+
'scheduleStartTime': '12:00 PM',
|
|
1616
|
+
'scheduleEndTime': '06:00 PM',
|
|
1617
|
+
'publish': true,
|
|
1618
|
+
},
|
|
1619
|
+
];
|
|
1620
|
+
return resData;
|
|
1619
1621
|
} catch ( error ) {
|
|
1620
1622
|
console.log( 'error =>', error );
|
|
1621
|
-
logger.error( { error: error, function: '
|
|
1622
|
-
return res.sendError( error, 500 );
|
|
1623
|
+
logger.error( { error: error, message: data, function: 'returnServerError' } );
|
|
1623
1624
|
}
|
|
1624
|
-
}
|
|
1625
|
+
}
|
|
@@ -15,7 +15,7 @@ export const welcome = async ( req, res ) => {
|
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export const
|
|
18
|
+
export const overallCardsOld = async ( req, res ) => {
|
|
19
19
|
try {
|
|
20
20
|
let requestData = req.body;
|
|
21
21
|
let fromDate = new Date( requestData.fromDate );
|
|
@@ -984,7 +984,7 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
984
984
|
}
|
|
985
985
|
};
|
|
986
986
|
|
|
987
|
-
export const
|
|
987
|
+
export const infoCardsOld = async ( req, res ) => {
|
|
988
988
|
try {
|
|
989
989
|
let requestData = req.body;
|
|
990
990
|
let fromDate = new Date( requestData.fromDate );
|
|
@@ -1540,3 +1540,203 @@ export const flagDetectionTables = async ( req, res ) => {
|
|
|
1540
1540
|
return res.sendError( { error: error }, 500 );
|
|
1541
1541
|
}
|
|
1542
1542
|
};
|
|
1543
|
+
|
|
1544
|
+
export const overallCards = async ( req, res ) => {
|
|
1545
|
+
try {
|
|
1546
|
+
let requestData = req.body;
|
|
1547
|
+
let resultData = await overallCardsData( requestData.checklistType );
|
|
1548
|
+
return res.sendSuccess( resultData );
|
|
1549
|
+
} catch ( error ) {
|
|
1550
|
+
console.log( 'error =>', error );
|
|
1551
|
+
logger.error( { error: error, function: 'overallCards' } );
|
|
1552
|
+
return res.sendError( error, 500 );
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1556
|
+
export const overallComparisonCards = async ( req, res ) => {
|
|
1557
|
+
try {
|
|
1558
|
+
let requestData = req.body;
|
|
1559
|
+
let resultData = await checklistComparisonData( requestData.checklistType );
|
|
1560
|
+
return res.sendSuccess( resultData );
|
|
1561
|
+
} catch ( error ) {
|
|
1562
|
+
console.log( 'error =>', error );
|
|
1563
|
+
logger.error( { error: error, function: 'overallComparisonCards' } );
|
|
1564
|
+
return res.sendError( error, 500 );
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
|
|
1568
|
+
async function overallCardsData( checklistType ) {
|
|
1569
|
+
try {
|
|
1570
|
+
let resData = {};
|
|
1571
|
+
let activeUnique = 50;
|
|
1572
|
+
let notSubmittedInstances = {
|
|
1573
|
+
'count': 300,
|
|
1574
|
+
'open': 100,
|
|
1575
|
+
'inprogress': 200,
|
|
1576
|
+
};
|
|
1577
|
+
let totalInstances = {
|
|
1578
|
+
'count': 500,
|
|
1579
|
+
};
|
|
1580
|
+
let completedInstances = {
|
|
1581
|
+
'count': 200,
|
|
1582
|
+
};
|
|
1583
|
+
let flags = {
|
|
1584
|
+
'count': 50,
|
|
1585
|
+
};
|
|
1586
|
+
let completionScore = {
|
|
1587
|
+
'count': 49,
|
|
1588
|
+
};
|
|
1589
|
+
let complianceRate = {
|
|
1590
|
+
'count': 66,
|
|
1591
|
+
};
|
|
1592
|
+
|
|
1593
|
+
resData.overallCards = {
|
|
1594
|
+
'activeUnique': activeUnique,
|
|
1595
|
+
'totalInstances': totalInstances,
|
|
1596
|
+
'notSubmittedInstances': notSubmittedInstances,
|
|
1597
|
+
'completedInstances': completedInstances,
|
|
1598
|
+
'flags': flags,
|
|
1599
|
+
'completionScore': completionScore,
|
|
1600
|
+
'complianceRate': complianceRate,
|
|
1601
|
+
};
|
|
1602
|
+
|
|
1603
|
+
return resData;
|
|
1604
|
+
} catch ( error ) {
|
|
1605
|
+
console.log( 'error =>', error );
|
|
1606
|
+
logger.error( { error: error, message: data, function: 'returnServerError' } );
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
async function checklistComparisonData( checklistType ) {
|
|
1611
|
+
try {
|
|
1612
|
+
let resData = {};
|
|
1613
|
+
let flags = {
|
|
1614
|
+
'comparisonData': 40,
|
|
1615
|
+
'ComparisonFlag': true,
|
|
1616
|
+
};
|
|
1617
|
+
let completionScore = {
|
|
1618
|
+
'comparisonData': 20,
|
|
1619
|
+
'ComparisonFlag': false,
|
|
1620
|
+
};
|
|
1621
|
+
let complianceRate = {
|
|
1622
|
+
'comparisonData': 60,
|
|
1623
|
+
'ComparisonFlag': true,
|
|
1624
|
+
};
|
|
1625
|
+
|
|
1626
|
+
resData.overallComparisonCards = {
|
|
1627
|
+
'flags': flags,
|
|
1628
|
+
'completionScore': completionScore,
|
|
1629
|
+
'complianceRate': complianceRate,
|
|
1630
|
+
};
|
|
1631
|
+
|
|
1632
|
+
return resData;
|
|
1633
|
+
} catch ( error ) {
|
|
1634
|
+
console.log( 'error =>', error );
|
|
1635
|
+
logger.error( { error: error, message: data, function: 'returnServerError' } );
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
export const infoCards = async ( req, res ) => {
|
|
1640
|
+
try {
|
|
1641
|
+
let requestData = req.body;
|
|
1642
|
+
let resultData = await infoCardsData( requestData.checklistType );
|
|
1643
|
+
return res.sendSuccess( resultData );
|
|
1644
|
+
} catch ( error ) {
|
|
1645
|
+
console.log( 'error =>', error );
|
|
1646
|
+
logger.error( { error: error, function: 'infoCards' } );
|
|
1647
|
+
return res.sendError( error, 500 );
|
|
1648
|
+
}
|
|
1649
|
+
};
|
|
1650
|
+
|
|
1651
|
+
export const infoComparisonCards = async ( req, res ) => {
|
|
1652
|
+
try {
|
|
1653
|
+
let requestData = req.body;
|
|
1654
|
+
let resultData = await infoCardsComparisonData( requestData.checklistType );
|
|
1655
|
+
return res.sendSuccess( resultData );
|
|
1656
|
+
} catch ( error ) {
|
|
1657
|
+
console.log( 'error =>', error );
|
|
1658
|
+
logger.error( { error: error, function: 'infoComparisonCards' } );
|
|
1659
|
+
return res.sendError( error, 500 );
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
async function infoCardsData( checklistType ) {
|
|
1664
|
+
try {
|
|
1665
|
+
let resData = {};
|
|
1666
|
+
let activeUnique = 800;
|
|
1667
|
+
let notSubmittedInstances = {
|
|
1668
|
+
'count': 500,
|
|
1669
|
+
'open': 300,
|
|
1670
|
+
'inprogress': 200,
|
|
1671
|
+
};
|
|
1672
|
+
let totalInstances = {
|
|
1673
|
+
'count': 300,
|
|
1674
|
+
};
|
|
1675
|
+
let completedInstances = {
|
|
1676
|
+
'count': '',
|
|
1677
|
+
};
|
|
1678
|
+
let flags = {
|
|
1679
|
+
'count': '',
|
|
1680
|
+
};
|
|
1681
|
+
let completionScore = {
|
|
1682
|
+
'count': '',
|
|
1683
|
+
};
|
|
1684
|
+
let complianceRate = {
|
|
1685
|
+
'count': '',
|
|
1686
|
+
};
|
|
1687
|
+
|
|
1688
|
+
resData.overallCards = {
|
|
1689
|
+
'activeUnique': activeUnique,
|
|
1690
|
+
'totalInstances': totalInstances,
|
|
1691
|
+
'notSubmittedInstances': notSubmittedInstances,
|
|
1692
|
+
'completedInstances': completedInstances,
|
|
1693
|
+
'flags': flags,
|
|
1694
|
+
'completionScore': completionScore,
|
|
1695
|
+
'complianceRate': complianceRate,
|
|
1696
|
+
};
|
|
1697
|
+
|
|
1698
|
+
return resData;
|
|
1699
|
+
} catch ( error ) {
|
|
1700
|
+
console.log( 'error =>', error );
|
|
1701
|
+
logger.error( { error: error, message: data, function: 'returnServerError' } );
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
async function infoCardsComparisonData( checklistType ) {
|
|
1706
|
+
try {
|
|
1707
|
+
let resData = {};
|
|
1708
|
+
let totalInstances = {
|
|
1709
|
+
'comparisonData': 30,
|
|
1710
|
+
'ComparisonFlag': false,
|
|
1711
|
+
};
|
|
1712
|
+
let completedInstances = {
|
|
1713
|
+
'comparisonData': 50,
|
|
1714
|
+
'ComparisonFlag': true,
|
|
1715
|
+
};
|
|
1716
|
+
let flags = {
|
|
1717
|
+
'comparisonData': 40,
|
|
1718
|
+
'ComparisonFlag': true,
|
|
1719
|
+
};
|
|
1720
|
+
let completionScore = {
|
|
1721
|
+
'comparisonData': 20,
|
|
1722
|
+
'ComparisonFlag': false,
|
|
1723
|
+
};
|
|
1724
|
+
let complianceRate = {
|
|
1725
|
+
'comparisonData': 60,
|
|
1726
|
+
'ComparisonFlag': true,
|
|
1727
|
+
};
|
|
1728
|
+
|
|
1729
|
+
resData.overallComparisonCards = {
|
|
1730
|
+
'totalInstances': totalInstances,
|
|
1731
|
+
'completedInstances': completedInstances,
|
|
1732
|
+
'flags': flags,
|
|
1733
|
+
'completionScore': completionScore,
|
|
1734
|
+
'complianceRate': complianceRate,
|
|
1735
|
+
};
|
|
1736
|
+
|
|
1737
|
+
return resData;
|
|
1738
|
+
} catch ( error ) {
|
|
1739
|
+
console.log( 'error =>', error );
|
|
1740
|
+
logger.error( { error: error, message: data, function: 'returnServerError' } );
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
@@ -7,6 +7,7 @@ export const traxDashboardRouter = express.Router();
|
|
|
7
7
|
import {
|
|
8
8
|
welcome,
|
|
9
9
|
overallCards,
|
|
10
|
+
overallComparisonCards,
|
|
10
11
|
checklistPerformance,
|
|
11
12
|
storePerformance,
|
|
12
13
|
userPerformance,
|
|
@@ -15,6 +16,7 @@ import {
|
|
|
15
16
|
userDropdown,
|
|
16
17
|
checklistInfo,
|
|
17
18
|
infoCards,
|
|
19
|
+
infoComparisonCards,
|
|
18
20
|
monthlyGraph,
|
|
19
21
|
flagDetectionCards,
|
|
20
22
|
flagDetectionTables,
|
|
@@ -23,11 +25,13 @@ import {
|
|
|
23
25
|
traxDashboardRouter
|
|
24
26
|
.get( '/welcome', welcome )
|
|
25
27
|
.post( '/overallCards', overallCards )
|
|
28
|
+
.post( '/overallComparisonCards', overallComparisonCards )
|
|
26
29
|
.post( '/checklistPerformance', checklistPerformance )
|
|
27
30
|
.post( '/storePerformance', storePerformance )
|
|
28
31
|
.post( '/userPerformance', userPerformance )
|
|
29
32
|
.post( '/checklistInfo', checklistInfo )
|
|
30
33
|
.post( '/infoCards', infoCards )
|
|
34
|
+
.post( '/infoComparisonCards', infoComparisonCards )
|
|
31
35
|
.post( '/monthlyGraph', monthlyGraph )
|
|
32
36
|
.post( '/checklistDropdown', checklistDropdown )
|
|
33
37
|
.post( '/storelistDropdown', storeDropdown )
|