tango-app-api-trax 1.0.0-alpha.13 → 1.0.0-alpha.15

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.
@@ -496,6 +496,550 @@ 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
+ console.log( 'rangeOneFromDate =>', rangeOneFromDate );
699
+ console.log( 'rangeOneToDate =>', rangeOneToDate );
700
+ console.log( 'rangeTwoFromDate =>', rangeTwoFromDate );
701
+ console.log( 'rangeTwoToDate =>', rangeTwoToDate );
702
+ let flagComparisonCards = {
703
+ 'questionComparisonFlag': {
704
+ 'comparisonData': 0,
705
+ 'ComparisonFlag': '',
706
+ },
707
+ 'delayInSubmissionComparisonFlag': {
708
+ 'comparisonData': 0,
709
+ 'ComparisonFlag': '',
710
+ },
711
+ 'detectionComparisonFlag': {
712
+ 'comparisonData': 0,
713
+ 'ComparisonFlag': '',
714
+ },
715
+ };
716
+
717
+ let rangeOneFindQuery = [];
718
+ let rangeOneFindAndQuery = [];
719
+ rangeOneFindAndQuery.push(
720
+ { client_id: requestData.clientId },
721
+ { store_id: { $in: requestData.storeId } },
722
+ { date_iso: { $gte: rangeOneFromDate } },
723
+ { date_iso: { $lte: rangeOneToDate } },
724
+ );
725
+ rangeOneFindQuery.push( { $match: { $and: rangeOneFindAndQuery } } );
726
+ rangeOneFindQuery.push( {
727
+ $project: {
728
+ timeFlag: 1,
729
+ questionFlag: 1,
730
+ mobileDetectionFlag: 1,
731
+ storeOpenCloseFlag: 1,
732
+ uniformDetectionFlag: 1,
733
+ customerunattendedFlag: 1,
734
+ staffleftinthemiddleFlag: 1,
735
+ },
736
+ } );
737
+ rangeOneFindQuery.push( {
738
+ $group: {
739
+ _id: '',
740
+ totalFlag: {
741
+ $sum: {
742
+ $cond: [ {
743
+ $or: [
744
+ { $gt: [ '$questionFlag', 0 ] },
745
+ { $gt: [ '$timeFlag', 0 ] },
746
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
747
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
748
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
749
+ { $gt: [ '$customerunattendedFlag', 0 ] },
750
+ { $gt: [ '$staffleftinthemiddle', 0 ] },
751
+ ],
752
+ }, 1, 0 ],
753
+ },
754
+ },
755
+ questionFlag: {
756
+ $sum: {
757
+ $cond: [
758
+ {
759
+ $and: [
760
+ { $gt: [ '$questionFlag', 0 ] },
761
+ ],
762
+ }, 1, 0 ],
763
+ },
764
+ },
765
+ delayInSubmission: {
766
+ $sum: {
767
+ $cond: [
768
+ {
769
+ $and: [
770
+ { $gt: [ '$timeFlag', 0 ] },
771
+ ],
772
+ }, 1, 0 ],
773
+ },
774
+ },
775
+ detectionFlag: {
776
+ $sum: {
777
+ $cond: [ {
778
+ $or: [
779
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
780
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
781
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
782
+ { $gt: [ '$customerunattendedFlag', 0 ] },
783
+ { $gt: [ '$staffleftinthemiddleFlag', 0 ] },
784
+ ],
785
+ }, 1, 0 ],
786
+ },
787
+ },
788
+ },
789
+ } );
790
+ let rangeOneData = await processedchecklistService.aggregate( rangeOneFindQuery );
791
+ // console.log( 'rangeOneData =>', rangeOneData );
792
+
793
+ let rangeTwoFindQuery = [];
794
+ let rangeTwoFindAndQuery = [];
795
+ rangeTwoFindAndQuery.push(
796
+ { client_id: requestData.clientId },
797
+ { store_id: { $in: requestData.storeId } },
798
+ { date_iso: { $gte: rangeTwoFromDate } },
799
+ { date_iso: { $lte: rangeTwoToDate } },
800
+ );
801
+ rangeTwoFindQuery.push( { $match: { $and: rangeTwoFindAndQuery } } );
802
+ rangeTwoFindQuery.push( {
803
+ $project: {
804
+ timeFlag: 1,
805
+ questionFlag: 1,
806
+ mobileDetectionFlag: 1,
807
+ storeOpenCloseFlag: 1,
808
+ uniformDetectionFlag: 1,
809
+ customerunattendedFlag: 1,
810
+ staffleftinthemiddleFlag: 1,
811
+ },
812
+ } );
813
+ rangeTwoFindQuery.push( {
814
+ $group: {
815
+ _id: '',
816
+ totalFlag: {
817
+ $sum: {
818
+ $cond: [ {
819
+ $or: [
820
+ { $gt: [ '$questionFlag', 0 ] },
821
+ { $gt: [ '$timeFlag', 0 ] },
822
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
823
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
824
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
825
+ { $gt: [ '$customerunattendedFlag', 0 ] },
826
+ { $gt: [ '$staffleftinthemiddle', 0 ] },
827
+ ],
828
+ }, 1, 0 ],
829
+ },
830
+ },
831
+ questionFlag: {
832
+ $sum: {
833
+ $cond: [
834
+ {
835
+ $and: [
836
+ { $gt: [ '$questionFlag', 0 ] },
837
+ ],
838
+ }, 1, 0 ],
839
+ },
840
+ },
841
+ delayInSubmission: {
842
+ $sum: {
843
+ $cond: [
844
+ {
845
+ $and: [
846
+ { $gt: [ '$timeFlag', 0 ] },
847
+ ],
848
+ }, 1, 0 ],
849
+ },
850
+ },
851
+ detectionFlag: {
852
+ $sum: {
853
+ $cond: [ {
854
+ $or: [
855
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
856
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
857
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
858
+ { $gt: [ '$customerunattendedFlag', 0 ] },
859
+ { $gt: [ '$staffleftinthemiddleFlag', 0 ] },
860
+ ],
861
+ }, 1, 0 ],
862
+ },
863
+ },
864
+ },
865
+ } );
866
+ let rangeTwoData = await processedchecklistService.aggregate( rangeTwoFindQuery );
867
+ // console.log( 'rangeTwoData =>', rangeTwoData );
868
+
869
+ if ( rangeOneData.length >0 && rangeTwoData.length >0 ) {
870
+ // console.log( 'rangeOneData[0].questionFlag =>', rangeOneData[0].questionFlag );
871
+ // console.log( 'rangeTwoData[0].questionFlag =>', rangeTwoData[0].questionFlag );
872
+
873
+ // console.log( 'rangeOneData[0].delayInSubmission =>', rangeOneData[0].delayInSubmission );
874
+ // console.log( 'rangeTwoData[0].delayInSubmission =>', rangeTwoData[0].delayInSubmission );
875
+
876
+ // console.log( 'rangeOneData[0].detectionFlag =>', rangeOneData[0].detectionFlag );
877
+ // console.log( 'rangeTwoData[0].detectionFlag =>', rangeTwoData[0].detectionFlag );
878
+
879
+ flagComparisonCards.questionComparisonFlag.comparisonData = ( ( ( rangeOneData[0].questionFlag - rangeTwoData[0].questionFlag )/rangeOneData[0].questionFlag )*100 ).toFixed( 2 );
880
+ if ( flagComparisonCards.questionComparisonFlag.comparisonData > 0 ) {
881
+ flagComparisonCards.questionComparisonFlag.ComparisonFlag = true;
882
+ } else {
883
+ flagComparisonCards.questionComparisonFlag.ComparisonFlag = false;
884
+ }
885
+ flagComparisonCards.delayInSubmissionComparisonFlag.comparisonData = ( ( ( rangeOneData[0].delayInSubmission - rangeTwoData[0].delayInSubmission )/rangeOneData[0].delayInSubmission )*100 ).toFixed( 2 );
886
+ if ( flagComparisonCards.delayInSubmissionComparisonFlag.comparisonData > 0 ) {
887
+ flagComparisonCards.delayInSubmissionComparisonFlag.ComparisonFlag = true;
888
+ } else {
889
+ flagComparisonCards.delayInSubmissionComparisonFlag.ComparisonFlag = false;
890
+ }
891
+ flagComparisonCards.detectionComparisonFlag.comparisonData = ( ( ( rangeOneData[0].detectionFlag - rangeTwoData[0].detectionFlag )/rangeOneData[0].detectionFlag )*100 ).toFixed( 2 );
892
+ if ( flagComparisonCards.detectionComparisonFlag.comparisonData > 0 ) {
893
+ flagComparisonCards.detectionComparisonFlag.ComparisonFlag = true;
894
+ } else {
895
+ flagComparisonCards.detectionComparisonFlag.ComparisonFlag = false;
896
+ }
897
+
898
+ flagComparisonCards.questionComparisonFlag.comparisonData = Math.abs( flagComparisonCards.questionComparisonFlag.comparisonData );
899
+ flagComparisonCards.delayInSubmissionComparisonFlag.comparisonData = Math.abs( flagComparisonCards.delayInSubmissionComparisonFlag.comparisonData );
900
+ flagComparisonCards.detectionComparisonFlag.comparisonData = Math.abs( flagComparisonCards.detectionComparisonFlag.comparisonData );
901
+ }
902
+
903
+ let result = {
904
+ 'flagComparisonCards': flagComparisonCards,
905
+ };
906
+ return res.sendSuccess( result );
907
+ } catch ( error ) {
908
+ console.log( 'error =>', error );
909
+ logger.error( { error: error, function: 'subscribedStoreList' } );
910
+ return res.sendError( error, 500 );
911
+ }
912
+ };
913
+
914
+ export const flagTablesV1 = async ( req, res ) => {
915
+ try {
916
+ let requestData = req.body;
917
+ let fromDate = new Date( requestData.fromDate );
918
+ let toDate = new Date( requestData.toDate );
919
+ let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
920
+ toDate = new Date( toDate.getTime() - userTimezoneOffset );
921
+ toDate.setUTCHours( 23, 59, 59, 59 );
922
+ let result = {};
923
+
924
+ let findQuery = [];
925
+ let findAndQuery = [];
926
+ findAndQuery.push(
927
+ { client_id: requestData.clientId },
928
+ { store_id: { $in: requestData.storeId } },
929
+ { date_iso: { $gte: fromDate } },
930
+ { date_iso: { $lte: toDate } },
931
+ );
932
+
933
+ findQuery.push( { $match: { $and: findAndQuery } } );
934
+
935
+ if ( requestData.searchValue && requestData.searchValue != '' ) {
936
+ findQuery.push( { $match: { $or: [ { checkListName: { $regex: requestData.searchValue, $options: 'i' } } ] } } );
937
+ }
938
+
939
+ findQuery.push( {
940
+ $project: {
941
+ sourceCheckList_id: 1,
942
+ checkListId: 1,
943
+ checkListName: 1,
944
+ storeCount: 1,
945
+ createdBy: 1,
946
+ createdByName: 1,
947
+ checklistStatus: 1,
948
+ timeFlag: 1,
949
+ questionFlag: 1,
950
+ questionCount: 1,
951
+ mobileDetectionFlag: 1,
952
+ storeOpenCloseFlag: 1,
953
+ uniformDetectionFlag: 1,
954
+ checkListType: 1,
955
+ scheduleRepeatedType: 1,
956
+ },
957
+ } );
958
+
959
+ findQuery.push( {
960
+ $group: {
961
+ _id: '$sourceCheckList_id',
962
+ checkListName: { $last: '$checkListName' },
963
+ checkListChar: { $last: { $substr: [ '$checkListName', 0, 2 ] } },
964
+ sourceCheckList_id: { $last: '$sourceCheckList_id' },
965
+ checkListType: { $last: '$checkListType' },
966
+ assignedStores: { $max: '$storeCount' },
967
+ flagCount: {
968
+ $sum: {
969
+ $cond: [ {
970
+ $or: [
971
+ { $gt: [ '$timeFlag', 0 ] },
972
+ { $gt: [ '$questionFlag', 0 ] },
973
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
974
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
975
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
976
+ ],
977
+ }, 1, 0 ],
978
+ },
979
+ },
980
+ submittedChecklist: {
981
+ $sum: {
982
+ $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, 1, 0 ],
983
+ },
984
+ },
985
+ questionFlag: {
986
+ $sum: {
987
+ $cond: [ { $gt: [ '$questionFlag', 0 ] }, 1, 0 ],
988
+ },
989
+ },
990
+ questionCount: {
991
+ $sum: {
992
+ $cond: [ { $gt: [ '$questionCount', 0 ] }, 1, 0 ],
993
+ },
994
+ },
995
+ },
996
+ } );
997
+
998
+ findQuery.push( {
999
+ $project: {
1000
+ checkListName: 1,
1001
+ checkListChar: 1,
1002
+ sourceCheckList_id: 1,
1003
+ checkListType: 1,
1004
+ flagType: 1,
1005
+ assignedStores: 1,
1006
+ flaggedStores: '$assignedStores',
1007
+ flagCount: 1,
1008
+ complianceRate: {
1009
+ $multiply: [
1010
+ { $divide: [ '$questionFlag', '$questionCount' ] },
1011
+ 100,
1012
+ ],
1013
+ },
1014
+ },
1015
+ } );
1016
+
1017
+ let getTotalCount = await processedchecklistService.aggregate( findQuery );
1018
+ if ( !getTotalCount.length ) {
1019
+ return res.sendError( { error: 'No Data Found' }, 204 );
1020
+ }
1021
+
1022
+ if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
1023
+ findQuery.push( { $sort: { [requestData.sortColumnName]: requestData.sortBy } } );
1024
+ } else {
1025
+ findQuery.push( { $sort: { ['submittedChecklist']: -1 } } );
1026
+ }
1027
+
1028
+ let limit = parseInt( requestData?.limit ) || 10;
1029
+ let skip = limit * ( requestData?.offset ) || 0;
1030
+ findQuery.push( { $skip: skip }, { $limit: limit } );
1031
+ let getChecklistPerformanceData = await processedchecklistService.aggregate( findQuery );
1032
+
1033
+ result.totalCount = getTotalCount.length;
1034
+ result.checklistPerformance = getChecklistPerformanceData;
1035
+ return res.sendSuccess( result );
1036
+ } catch ( error ) {
1037
+ console.log( 'error =>', error );
1038
+ logger.error( { error: error, message: req.query, function: 'checklistPerformance' } );
1039
+ return res.sendError( { error: error }, 500 );
1040
+ }
1041
+ };
1042
+
499
1043
  async function checklistCardData( checklistType ) {
500
1044
  try {
501
1045
  let resData = {};
@@ -1014,30 +1558,6 @@ async function tableData( checklistType ) {
1014
1558
  }
1015
1559
  }
1016
1560
 
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
1561
  async function flagCardData( checklistType ) {
1042
1562
  try {
1043
1563
  let resData = {};
@@ -1075,550 +1595,194 @@ async function falgComparisonData( checklistType ) {
1075
1595
  'detectionComparisonFlag': {
1076
1596
  'comparisonData': 20,
1077
1597
  '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 );
1598
+ },
1599
+ };
1600
+ return resData;
1186
1601
  } catch ( error ) {
1187
1602
  console.log( 'error =>', error );
1188
- logger.error( { error: error, function: 'subscribedStoreList' } );
1189
- return res.sendError( error, 500 );
1603
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1190
1604
  }
1191
- };
1605
+ }
1192
1606
 
1193
- async function checklistDropdownData( checklistType ) {
1607
+ async function flagTableData( checklistType ) {
1194
1608
  try {
1195
1609
  let resData = {};
1196
- resData.checklistDropdownData = [
1610
+ resData.totalCount = 300;
1611
+ resData.flagTableData = [
1197
1612
  {
1198
1613
  'checklistName': 'Field VM- Store Visit Checklist',
1199
1614
  'sourceCheckList_id': '668e3e1807d5312fa49b0046',
1200
1615
  'checkListType': 'custom',
1201
- 'createdByName': 'Yamini',
1202
- 'storeCount': 1853,
1203
- 'scheduleRepeatedType': 'weekly',
1204
- 'scheduleStartTime': '12:00 PM',
1205
- 'scheduleEndTime': '06:00 PM',
1206
- 'publish': true,
1616
+ 'flagType': 'Question',
1617
+ 'assignedStores': 400,
1618
+ 'flaggedStores': 50,
1619
+ 'flagCount': 30,
1620
+ 'complianceRate': 25,
1207
1621
  },
1208
1622
  {
1209
1623
  'checklistName': 'DC Prep Checklist',
1210
1624
  'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1211
1625
  'checkListType': 'custom',
1212
- 'createdByName': 'Yamini',
1213
- 'storeCount': 1853,
1214
- 'scheduleRepeatedType': 'weekly',
1215
- 'scheduleStartTime': '12:00 PM',
1216
- 'scheduleEndTime': '06:00 PM',
1217
- 'publish': true,
1626
+ 'flagType': 'Question',
1627
+ 'assignedStores': 500,
1628
+ 'flaggedStores': 66,
1629
+ 'flagCount': 66,
1630
+ 'complianceRate': 89,
1218
1631
  },
1219
1632
  {
1220
1633
  'checklistName': 'Store Open and Close',
1221
1634
  'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1222
1635
  'checkListType': 'storeopenandclose',
1223
- 'createdByName': 'Yamini',
1224
- 'storeCount': 1853,
1225
- 'scheduleRepeatedType': 'weekly',
1226
- 'scheduleStartTime': '12:00 PM',
1227
- 'scheduleEndTime': '06:00 PM',
1228
- 'publish': true,
1636
+ 'flagType': 'Question',
1637
+ 'assignedStores': 300,
1638
+ 'flaggedStores': 70,
1639
+ 'flagCount': 80,
1640
+ 'complianceRate': 25,
1229
1641
  },
1230
1642
  {
1231
1643
  'checklistName': 'Mobileusage Detection',
1232
1644
  'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1233
1645
  'checkListType': 'mobileusagedetection',
1234
- 'createdByName': 'Yamini',
1235
- 'storeCount': 1853,
1236
- 'scheduleRepeatedType': 'weekly',
1237
- 'scheduleStartTime': '12:00 PM',
1238
- 'scheduleEndTime': '06:00 PM',
1239
- 'publish': true,
1646
+ 'flagType': 'Detection',
1647
+ 'assignedStores': 250,
1648
+ 'flaggedStores': 30,
1649
+ 'flagCount': 80,
1650
+ 'complianceRate': 77,
1240
1651
  },
1241
1652
  {
1242
1653
  'checklistName': 'Uniform Detection',
1243
1654
  'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1244
1655
  'checkListType': 'uniformdetection',
1245
- 'createdByName': 'Yamini',
1246
- 'storeCount': 1853,
1247
- 'scheduleRepeatedType': 'weekly',
1248
- 'scheduleStartTime': '12:00 PM',
1249
- 'scheduleEndTime': '06:00 PM',
1250
- 'publish': true,
1656
+ 'flagType': 'Detection',
1657
+ 'assignedStores': 100,
1658
+ 'flaggedStores': 0,
1659
+ 'flagCount': 60,
1660
+ 'complianceRate': 45,
1251
1661
  },
1252
1662
  {
1253
1663
  'checklistName': 'Customer Unattended',
1254
1664
  'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1255
1665
  'checkListType': 'customerunattended',
1256
- 'createdByName': 'Yamini',
1257
- 'storeCount': 1853,
1258
- 'scheduleRepeatedType': 'weekly',
1259
- 'scheduleStartTime': '12:00 PM',
1260
- 'scheduleEndTime': '06:00 PM',
1261
- 'publish': true,
1666
+ 'flagType': 'Detection',
1667
+ 'assignedStores': 200,
1668
+ 'flaggedStores': 20,
1669
+ 'flagCount': 70,
1670
+ 'complianceRate': 55,
1262
1671
  },
1263
1672
  {
1264
1673
  'checklistName': 'Staff Left in The Middle',
1265
1674
  'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1266
1675
  'checkListType': 'staffleftinthemiddle',
1267
- 'createdByName': 'Yamini',
1268
- 'storeCount': 1853,
1269
- 'scheduleRepeatedType': 'weekly',
1270
- 'scheduleStartTime': '12:00 PM',
1271
- 'scheduleEndTime': '06:00 PM',
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,
1676
+ 'flagType': 'Detection',
1677
+ 'assignedStores': 150,
1678
+ 'flaggedStores': 50,
1679
+ 'flagCount': 50,
1680
+ 'complianceRate': 30,
1284
1681
  },
1285
1682
  ];
1286
1683
  return resData;
1287
1684
  } catch ( error ) {
1288
- console.log( 'error =>', error );
1289
- logger.error( { error: error, message: data, function: 'returnServerError' } );
1290
- }
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 );
1685
+ console.log( 'error =>', error );
1686
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1687
+ }
1688
+ }
1443
1689
 
1444
- let flagComparisonCards = {
1445
- 'questionComparisonFlag': {
1446
- 'comparisonData': 0,
1447
- 'ComparisonFlag': '',
1690
+ async function checklistDropdownData( checklistType ) {
1691
+ try {
1692
+ let resData = {};
1693
+ resData.checklistDropdownData = [
1694
+ {
1695
+ 'checklistName': 'Field VM- Store Visit Checklist',
1696
+ 'sourceCheckList_id': '668e3e1807d5312fa49b0046',
1697
+ 'checkListType': 'custom',
1698
+ 'createdByName': 'Yamini',
1699
+ 'storeCount': 1853,
1700
+ 'scheduleRepeatedType': 'weekly',
1701
+ 'scheduleStartTime': '12:00 PM',
1702
+ 'scheduleEndTime': '06:00 PM',
1703
+ 'publish': true,
1448
1704
  },
1449
- 'delayInSubmissionComparisonFlag': {
1450
- 'comparisonData': 0,
1451
- 'ComparisonFlag': '',
1705
+ {
1706
+ 'checklistName': 'DC Prep Checklist',
1707
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1708
+ 'checkListType': 'custom',
1709
+ 'createdByName': 'Yamini',
1710
+ 'storeCount': 1853,
1711
+ 'scheduleRepeatedType': 'weekly',
1712
+ 'scheduleStartTime': '12:00 PM',
1713
+ 'scheduleEndTime': '06:00 PM',
1714
+ 'publish': true,
1452
1715
  },
1453
- 'detectionComparisonFlag': {
1454
- 'comparisonData': 0,
1455
- 'ComparisonFlag': '',
1716
+ {
1717
+ 'checklistName': 'Store Open and Close',
1718
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167362',
1719
+ 'checkListType': 'storeopenandclose',
1720
+ 'createdByName': 'Yamini',
1721
+ 'storeCount': 1853,
1722
+ 'scheduleRepeatedType': 'weekly',
1723
+ 'scheduleStartTime': '12:00 PM',
1724
+ 'scheduleEndTime': '06:00 PM',
1725
+ 'publish': true,
1456
1726
  },
1457
- };
1458
-
1459
- let rangeOneFindQuery = [];
1460
- let rangeOneFindAndQuery = [];
1461
- rangeOneFindAndQuery.push(
1462
- { client_id: requestData.clientId },
1463
- { store_id: { $in: requestData.storeId } },
1464
- { date_iso: { $gte: fromDate } },
1465
- { date_iso: { $lte: toDate } },
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,
1727
+ {
1728
+ 'checklistName': 'Mobileusage Detection',
1729
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167363',
1730
+ 'checkListType': 'mobileusagedetection',
1731
+ 'createdByName': 'Yamini',
1732
+ 'storeCount': 1853,
1733
+ 'scheduleRepeatedType': 'weekly',
1734
+ 'scheduleStartTime': '12:00 PM',
1735
+ 'scheduleEndTime': '06:00 PM',
1736
+ 'publish': true,
1477
1737
  },
1478
- } );
1479
- rangeOneFindQuery.push( {
1480
- $group: {
1481
- _id: '',
1482
- totalFlag: {
1483
- $sum: {
1484
- $cond: [ {
1485
- $or: [
1486
- { $gt: [ '$questionFlag', 0 ] },
1487
- { $gt: [ '$timeFlag', 0 ] },
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
- },
1738
+ {
1739
+ 'checklistName': 'Uniform Detection',
1740
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167364',
1741
+ 'checkListType': 'uniformdetection',
1742
+ 'createdByName': 'Yamini',
1743
+ 'storeCount': 1853,
1744
+ 'scheduleRepeatedType': 'weekly',
1745
+ 'scheduleStartTime': '12:00 PM',
1746
+ 'scheduleEndTime': '06:00 PM',
1747
+ 'publish': true,
1530
1748
  },
1531
- } );
1532
- let rangeOneData = await processedchecklistService.aggregate( rangeOneFindQuery );
1533
- console.log( 'rangeOneData =>', rangeOneData );
1534
-
1535
- let rangeTwoFindQuery = [];
1536
- let rangeTwoFindAndQuery = [];
1537
- rangeTwoFindAndQuery.push(
1538
- { client_id: requestData.clientId },
1539
- { store_id: { $in: requestData.storeId } },
1540
- { date_iso: { $gte: fromDate } },
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,
1749
+ {
1750
+ 'checklistName': 'Customer Unattended',
1751
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167365',
1752
+ 'checkListType': 'customerunattended',
1753
+ 'createdByName': 'Yamini',
1754
+ 'storeCount': 1853,
1755
+ 'scheduleRepeatedType': 'weekly',
1756
+ 'scheduleStartTime': '12:00 PM',
1757
+ 'scheduleEndTime': '06:00 PM',
1758
+ 'publish': true,
1553
1759
  },
1554
- } );
1555
- rangeTwoFindQuery.push( {
1556
- $group: {
1557
- _id: '',
1558
- totalFlag: {
1559
- $sum: {
1560
- $cond: [ {
1561
- $or: [
1562
- { $gt: [ '$questionFlag', 0 ] },
1563
- { $gt: [ '$timeFlag', 0 ] },
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
- },
1760
+ {
1761
+ 'checklistName': 'Staff Left in The Middle',
1762
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167366',
1763
+ 'checkListType': 'staffleftinthemiddle',
1764
+ 'createdByName': 'Yamini',
1765
+ 'storeCount': 1853,
1766
+ 'scheduleRepeatedType': 'weekly',
1767
+ 'scheduleStartTime': '12:00 PM',
1768
+ 'scheduleEndTime': '06:00 PM',
1769
+ 'publish': true,
1606
1770
  },
1607
- } );
1608
- let rangeTwoData = await processedchecklistService.aggregate( rangeTwoFindQuery );
1609
- console.log( 'rangeTwoData =>', rangeTwoData );
1610
-
1611
- if ( rangeOneData.length >0 && rangeTwoData.length >0 ) {
1612
-
1613
- }
1614
-
1615
- let result = {
1616
- 'flagComparisonCards': flagComparisonCards,
1617
- };
1618
- return res.sendSuccess( result );
1771
+ {
1772
+ 'checklistName': 'Field VM- Store Visit Checklist Field VM- Store Visit Checklist',
1773
+ 'sourceCheckList_id': '668e3e1807d5312fa49b0046',
1774
+ 'checkListType': 'custom',
1775
+ 'createdByName': 'Yamini',
1776
+ 'storeCount': 1853,
1777
+ 'scheduleRepeatedType': 'weekly',
1778
+ 'scheduleStartTime': '12:00 PM',
1779
+ 'scheduleEndTime': '06:00 PM',
1780
+ 'publish': true,
1781
+ },
1782
+ ];
1783
+ return resData;
1619
1784
  } catch ( error ) {
1620
1785
  console.log( 'error =>', error );
1621
- logger.error( { error: error, function: 'subscribedStoreList' } );
1622
- return res.sendError( error, 500 );
1786
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1623
1787
  }
1624
- };
1788
+ }