tango-app-api-trax 3.9.38 → 3.9.39

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.
Files changed (55) hide show
  1. package/index.js +1 -2
  2. package/package.json +2 -2
  3. package/src/controllers/internalTrax.controller.js +99 -221
  4. package/src/controllers/mobileTrax.controller.js +29 -69
  5. package/src/controllers/teaxFlag.controller.js +953 -15
  6. package/src/controllers/trax.controller.js +2 -3
  7. package/src/controllers/traxDashboard.controllers.js +55 -69
  8. package/src/hbs/flag.hbs +1 -1
  9. package/src/hbs/login-otp.hbs +943 -943
  10. package/src/hbs/template.hbs +0 -7
  11. package/src/hbs/visit-checklist.hbs +91 -71
  12. package/src/routes/internalTraxApi.router.js +0 -1
  13. package/src/routes/trax.routes.js +3 -0
  14. package/src/routes/traxFlag.router.js +24 -0
  15. package/src/services/app.service.js +9 -15
  16. package/src/services/approver.service.js +15 -23
  17. package/src/services/authentication.service.js +3 -9
  18. package/src/services/camera.service.js +13 -19
  19. package/src/services/checklist.service.js +27 -35
  20. package/src/services/checklistAssign.service.js +38 -43
  21. package/src/services/checklistQuestion.service.js +34 -39
  22. package/src/services/checklistlog.service.js +34 -39
  23. package/src/services/clientRequest.service.js +2 -9
  24. package/src/services/clients.services.js +18 -23
  25. package/src/services/cluster.service.js +23 -31
  26. package/src/services/domain.service.js +18 -23
  27. package/src/services/download.services.js +25 -35
  28. package/src/services/group.service.js +17 -23
  29. package/src/services/lenskartEmployeeMapping.service.js +10 -15
  30. package/src/services/locus.service.js +28 -35
  31. package/src/services/notification.service.js +26 -35
  32. package/src/services/otp.service.js +13 -20
  33. package/src/services/planogram.service.js +2 -9
  34. package/src/services/processedTaskConfig.service.js +27 -35
  35. package/src/services/processedTaskList.service.js +26 -32
  36. package/src/services/processedchecklist.services.js +47 -55
  37. package/src/services/processedchecklistconfig.services.js +34 -39
  38. package/src/services/recurringFlagTracker.service.js +32 -39
  39. package/src/services/runAIFeatures.services.js +27 -32
  40. package/src/services/runAIRequest.services.js +38 -43
  41. package/src/services/store.service.js +27 -32
  42. package/src/services/tagging.service.js +2 -9
  43. package/src/services/taskConfig.service.js +27 -35
  44. package/src/services/teams.service.js +24 -35
  45. package/src/services/ticket.service.js +10 -15
  46. package/src/services/user.service.js +20 -27
  47. package/src/services/userAssignedstores.service.js +5 -12
  48. package/src/utils/visitChecklistPdf.utils.js +21 -449
  49. package/src/logging/activityLogFlusher.js +0 -59
  50. package/src/logging/activityLogMiddleware.js +0 -45
  51. package/src/logging/activityLogStore.js +0 -91
  52. package/src/logging/compressBatches.js +0 -83
  53. package/src/logging/config.js +0 -24
  54. package/src/logging/createLoggableService.js +0 -46
  55. package/src/logging/logExternalCall.js +0 -37
@@ -14,6 +14,10 @@ import mongoose from 'mongoose';
14
14
  export const overallFlagMetrics = async ( req, res ) => {
15
15
  try {
16
16
  let requestData = req.body;
17
+ // Get User Based Checklist //
18
+ // let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
19
+ // let getUserEmails = await getChecklistUsers( loginUser );
20
+ // End: Get User Based Checklist////
17
21
  const pipeline = [
18
22
  {
19
23
  $facet: {
@@ -101,6 +105,7 @@ export const overallFlagMetrics = async ( req, res ) => {
101
105
  { client_id: req.body.clientId },
102
106
  { date_iso: { $gte: dayjs.utc( req.body.endDate ).subtract( 7, 'days' ).startOf( 'day' ).toDate() } },
103
107
  { date_iso: { $lte: dayjs.utc( req.body.startDate ).subtract( 1, 'day' ).startOf( 'day' ).toDate() } },
108
+ // { store_id: { $in: req.body.stores } },
104
109
  { $or: [ { store_id: { $in: req.body.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ] },
105
110
  ],
106
111
  },
@@ -153,6 +158,30 @@ export const overallFlagMetrics = async ( req, res ) => {
153
158
  },
154
159
  },
155
160
  },
161
+ // {
162
+ // $addFields: {
163
+ // questionFlag: {
164
+ // $round: [
165
+ // { $divide: [ '$questionFlag', 7 ] },
166
+ // 0,
167
+ // ],
168
+ // },
169
+ // timeFlag: {
170
+ // $round: [
171
+ // { $divide: [ '$timeFlag', 7 ] },
172
+ // 0,
173
+ // ],
174
+ // },
175
+ // detectionFlags: {
176
+ // $round: [
177
+ // {
178
+ // $divide: [ '$detectionFlags', 7 ],
179
+ // },
180
+ // 0,
181
+ // ],
182
+ // },
183
+ // },
184
+ // },
156
185
  ],
157
186
  },
158
187
  },
@@ -189,6 +218,9 @@ export const overallFlagMetrics = async ( req, res ) => {
189
218
  };
190
219
 
191
220
  function calculatePercentage( currentPeriod, last7Days ) {
221
+ // const current = currentPeriod[0];
222
+ // const last7 = last7Days[0];
223
+
192
224
  const calculateDiffPercentage = ( currentValue, last7Value ) => {
193
225
  if ( last7Value === 0 ) {
194
226
  return currentValue === 0 ? 0 : ( currentValue > 0 ? 100 : -100 );
@@ -224,6 +256,10 @@ export const overallFlagMetrics = async ( req, res ) => {
224
256
  export const checklistFlagsTable = async ( req, res ) => {
225
257
  try {
226
258
  let requestData = req.body;
259
+ // Get User Based Checklist //
260
+ // let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
261
+ // let getUserEmails = await getChecklistUsers( loginUser );
262
+ // End: Get User Based Checklist////
227
263
  const matchStage = {
228
264
  $match: {
229
265
  $and: [
@@ -237,6 +273,7 @@ export const checklistFlagsTable = async ( req, res ) => {
237
273
  { storeOpenCloseFlag: { $gt: 0 } },
238
274
  { uniformDetectionFlag: { $gt: 0 } },
239
275
  ] },
276
+ // { store_id: { $in: req.body.stores } },
240
277
  { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ] },
241
278
  ],
242
279
  },
@@ -402,6 +439,90 @@ export const checklistFlagsTable = async ( req, res ) => {
402
439
  }
403
440
  };
404
441
 
442
+ export const flagChecklistCards = async ( req, res ) => {
443
+ try {
444
+ let requestData = req.body;
445
+ let resultData = await checklistCardData( requestData.checklistType );
446
+ return res.sendSuccess( resultData );
447
+ } catch ( error ) {
448
+ console.log( 'error =>', error );
449
+ logger.error( { error: error, function: 'subscribedStoreList' } );
450
+ return res.sendError( error, 500 );
451
+ }
452
+ };
453
+
454
+ export const flagChecklistComparisonCards = async ( req, res ) => {
455
+ try {
456
+ let requestData = req.body;
457
+ let resultData = await checklistComparisonData( requestData.checklistType );
458
+ return res.sendSuccess( resultData );
459
+ } catch ( error ) {
460
+ console.log( 'error =>', error );
461
+ logger.error( { error: error, function: 'subscribedStoreList' } );
462
+ return res.sendError( error, 500 );
463
+ }
464
+ };
465
+
466
+ export const flagChecklistTable = async ( req, res ) => {
467
+ try {
468
+ let requestData = req.body;
469
+ let resultData = await tableData( requestData.checklistType );
470
+ return res.sendSuccess( resultData );
471
+ } catch ( error ) {
472
+ console.log( 'error =>', error );
473
+ logger.error( { error: error, function: 'subscribedStoreList' } );
474
+ return res.sendError( error, 500 );
475
+ }
476
+ };
477
+
478
+ export const flagCards = async ( req, res ) => {
479
+ try {
480
+ let requestData = req.body;
481
+ let resultData = await flagCardData( requestData.checklistType );
482
+ return res.sendSuccess( resultData );
483
+ } catch ( error ) {
484
+ console.log( 'error =>', error );
485
+ logger.error( { error: error, function: 'subscribedStoreList' } );
486
+ return res.sendError( error, 500 );
487
+ }
488
+ };
489
+
490
+ export const flagComparisonCards = async ( req, res ) => {
491
+ try {
492
+ let requestData = req.body;
493
+ let resultData = await falgComparisonData( requestData.checklistType );
494
+ return res.sendSuccess( resultData );
495
+ } catch ( error ) {
496
+ console.log( 'error =>', error );
497
+ logger.error( { error: error, function: 'subscribedStoreList' } );
498
+ return res.sendError( error, 500 );
499
+ }
500
+ };
501
+
502
+ export const flagTables = async ( req, res ) => {
503
+ try {
504
+ let requestData = req.body;
505
+ let resultData = await flagTableData( requestData.checklistType );
506
+ return res.sendSuccess( resultData );
507
+ } catch ( error ) {
508
+ console.log( 'error =>', error );
509
+ logger.error( { error: error, function: 'subscribedStoreList' } );
510
+ return res.sendError( error, 500 );
511
+ }
512
+ };
513
+
514
+ export const checklistDropdown = async ( req, res ) => {
515
+ try {
516
+ let requestData = req.body;
517
+ let resultData = await checklistDropdownData( requestData.checklistType );
518
+ return res.sendSuccess( resultData );
519
+ } catch ( error ) {
520
+ console.log( 'error =>', error );
521
+ logger.error( { error: error, function: 'subscribedStoreList' } );
522
+ return res.sendError( error, 500 );
523
+ }
524
+ };
525
+
405
526
  export const flagCardsV1 = async ( req, res ) => {
406
527
  try {
407
528
  const { clientId, storeId, fromDate, toDate } = req.body;
@@ -416,12 +537,18 @@ export const flagCardsV1 = async ( req, res ) => {
416
537
  };
417
538
 
418
539
  let requestData = req.body;
419
-
540
+ // Get User Based Checklist //
541
+ // let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
542
+ // let getUserEmails = await getChecklistUsers( loginUser );
543
+ // End: Get User Based Checklist////
420
544
  const findQuery = [
421
545
  {
422
546
  $match: {
423
547
  client_id: clientId,
548
+ // $or: [ { store_id: { $in: storeId } }, { aiStoreList: { $in: storeId } } ],
424
549
  date_iso: { $gte: adjustedFromDate, $lte: adjustedToDate },
550
+ // $or: [ { store_id: { $in: storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } }, { aiStoreList: { $in: storeId } } ],
551
+ // $or: [ { store_id: { $in: storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ],
425
552
  $or: clientId === '11' ?
426
553
  [
427
554
  { store_id: { $in: storeId } },
@@ -452,6 +579,7 @@ export const flagCardsV1 = async ( req, res ) => {
452
579
  ];
453
580
 
454
581
  const getOverallChecklistData = await processedchecklistService.aggregate( findQuery );
582
+ console.log( '🚀 ~ flagCardsV1 ~ getOverallChecklistData:', getOverallChecklistData );
455
583
 
456
584
  if ( !getOverallChecklistData.length ) {
457
585
  const resVal = {
@@ -480,11 +608,15 @@ export const flagCardsV1 = async ( req, res ) => {
480
608
  {
481
609
  client_id: clientId,
482
610
  publish: true,
483
- checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring', 'unattendeddetection', 'employeemonitoring', 'activitymonitoring' ] },
611
+ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring', 'unattendeddetection', 'employeemonitoring' ] },
484
612
  },
485
613
  { checkListType: 1 },
486
614
  );
487
615
 
616
+ // if ( !publishedAiChecklists?.length ) {
617
+ // return res.sendError( { error: 'No Data Found' }, 204 );
618
+ // }
619
+
488
620
  const detectionPayload = { fromDate, toDate, storeId, clientId };
489
621
  const lambdaURL = 'https://f65azvtljclaxp6l7rnx65cdmm0lcgvp.lambda-url.ap-south-1.on.aws/';
490
622
  const resultData = await LamdaServiceCall( lambdaURL, detectionPayload );
@@ -565,8 +697,13 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
565
697
  rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
566
698
  }
567
699
 
700
+ // Get User Based Checklist //
701
+ // let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
702
+ // let getUserEmails = await getChecklistUsers( loginUser );
703
+ // End: Get User Based Checklist////
568
704
  const createFindQuery = ( fromDate, toDate ) => [
569
705
  { $match: { client_id: requestData.clientId,
706
+ // $or: [ { store_id: { $in: requestData.storeId } }, { aiStoreList: { $in: requestData.storeId } } ],
570
707
  date_iso: { $gte: fromDate, $lte: toDate },
571
708
  $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } }, { aiStoreList: { $in: requestData.storeId } } ],
572
709
  } },
@@ -606,11 +743,16 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
606
743
  clientId: requestData.clientId,
607
744
  };
608
745
 
746
+ // console.log( dayjs( fromDate ).format( 'YYYY-MM-DD' ), 'from date' );
747
+ // console.log( dayjs( toDate ).subtract( 1, 'day' ).format( 'YYYY-MM-DD' ), 'current' );
748
+ // console.log( dayjs( toDate ).format( 'YYYY-MM-DD' ), 'previous' );
749
+ // console.log( dayjs( toDate ).startOf( 'day' ).subtract( 1, 'day' ).format( 'YYYY-MM-DD' ), 'new start of' );
750
+
609
751
  const publishedAiChecklists = await checklistconfigService.find(
610
752
  {
611
753
  client_id: requestData.clientId,
612
754
  publish: true,
613
- checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'employeeCount', 'employeemonitoring', 'activitymonitoring' ] },
755
+ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum' ] },
614
756
  },
615
757
  { checkListType: 1 },
616
758
  );
@@ -670,16 +812,24 @@ export const flagTablesV1 = async ( req, res ) => {
670
812
  toDate = new Date( toDate.getTime() - userTimezoneOffset );
671
813
  toDate.setUTCHours( 23, 59, 59, 59 );
672
814
  let result = {};
815
+
816
+ // Get User Based Checklist //
817
+ // let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
818
+ // let getUserEmails = await getChecklistUsers( loginUser );
819
+ // End: Get User Based Checklist////
820
+
673
821
  let findQuery = [];
674
822
  let findAndQuery = [];
675
823
  findAndQuery.push(
676
824
  { client_id: requestData.clientId },
825
+ // { $or: [ { store_id: { $in: requestData.storeId } }, { aiStoreList: { $in: requestData.storeId } } ] },
677
826
  { date_iso: { $gte: fromDate, $lte: toDate } },
678
827
  { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } }, { aiStoreList: { $in: requestData.storeId } } ] },
679
828
  );
680
829
 
681
830
  if ( requestData?.filter === 'all' ) {
682
- findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'employeeCount', 'employeemonitoring', 'activitymonitoring' ] } } ] } );
831
+ // findAndQuery.push( { $or: [ { questionFlag: { $gte: 1 } }, { timeFlag: { $gte: 1 } }, { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection' ] } } ] } );
832
+ findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum' ] } } ] } );
683
833
  } else if ( requestData?.filter === 'question' ) {
684
834
  findAndQuery.push( { checkListType: 'custom' } );
685
835
  findAndQuery.push( { questionFlag: { $gte: 1 } } );
@@ -687,7 +837,7 @@ export const flagTablesV1 = async ( req, res ) => {
687
837
  findAndQuery.push( { checkListType: 'custom' } );
688
838
  findAndQuery.push( { timeFlag: { $gte: 1 } } );
689
839
  } else if ( requestData?.filter === 'detection' ) {
690
- findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'employeeCount', 'employeemonitoring', 'activitymonitoring' ] } } );
840
+ findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum' ] } } );
691
841
  } else if ( requestData?.filter === 'runAI' ) {
692
842
  findAndQuery.push( { runAIQuestionCount: { $gte: 1 } } );
693
843
  }
@@ -731,6 +881,25 @@ export const flagTablesV1 = async ( req, res ) => {
731
881
  checkListType: { $last: '$checkListType' },
732
882
  storeCount: { $sum: 1 },
733
883
  storeCountAi: { $max: '$storeCount' },
884
+ // flaggedStores: {
885
+ // $addToSet: {
886
+ // $cond: [
887
+ // {
888
+ // $or: [
889
+ // { $gt: [ '$timeFlag', 0 ] },
890
+ // { $gt: [ '$questionFlag', 0 ] },
891
+ // { $gt: [ '$mobileDetectionFlag', 0 ] },
892
+ // { $gt: [ '$storeOpenCloseFlag', 0 ] },
893
+ // { $gt: [ '$uniformDetectionFlag', 0 ] },
894
+ // { $gt: [ '$customerUnattended', 0 ] },
895
+ // { $gt: [ '$staffLeftInTheMiddle', 0 ] },
896
+ // ],
897
+ // },
898
+ // '$store_id',
899
+ // '$$REMOVE',
900
+ // ],
901
+ // },
902
+ // },
734
903
  flaggedStores: { $sum: { $cond: [
735
904
  {
736
905
  $or: [
@@ -743,9 +912,6 @@ export const flagTablesV1 = async ( req, res ) => {
743
912
  { '$gt': [ '$staffLeftInTheMiddle', 0 ] },
744
913
  { '$gt': [ '$cleaning', 0 ] },
745
914
  { '$gt': [ '$scrum', 0 ] },
746
- { '$gt': [ '$employeeCount', 0 ] },
747
- { '$gt': [ '$employeemonitoring', 0 ] },
748
- { '$gt': [ '$activitymonitoring', 0 ] },
749
915
  ],
750
916
  },
751
917
  1,
@@ -755,6 +921,17 @@ export const flagTablesV1 = async ( req, res ) => {
755
921
  $sum: {
756
922
  $add: [ '$questionFlag', '$timeFlag' ],
757
923
  },
924
+ // $sum: {
925
+ // $cond: [ {
926
+ // $or: [
927
+ // { $gt: [ '$timeFlag', 0 ] },
928
+ // { $gt: [ '$questionFlag', 0 ] },
929
+ // { $gt: [ '$mobileDetectionFlag', 0 ] },
930
+ // { $gt: [ '$storeOpenCloseFlag', 0 ] },
931
+ // { $gt: [ '$uniformDetectionFlag', 0 ] },
932
+ // ],
933
+ // }, 1, 0 ],
934
+ // },
758
935
  },
759
936
  submittedChecklist: {
760
937
  $sum: {
@@ -763,12 +940,18 @@ export const flagTablesV1 = async ( req, res ) => {
763
940
  },
764
941
  questionFlag: {
765
942
  $sum: '$questionFlag',
943
+ // $sum: {
944
+ // $cond: [ { $gt: [ '$questionFlag', 0 ] }, 1, 0 ],
945
+ // },
766
946
  },
767
947
  timeFlag: {
768
948
  $sum: '$timeFlag',
769
949
  },
770
950
  questionCount: {
771
951
  $sum: '$questionCount',
952
+ // $sum: {
953
+ // $cond: [ { $gt: [ '$questionCount', 0 ] }, 1, 0 ],
954
+ // },
772
955
  },
773
956
  aiStoreList: { $max: '$aiStoreList' },
774
957
  aiStoreListNew: { $sum: { $size: '$aiStoreList' } },
@@ -795,12 +978,20 @@ export const flagTablesV1 = async ( req, res ) => {
795
978
  checkListType: 1,
796
979
  flagType: 1,
797
980
  uniqueFlaggedStores: 1,
981
+ // flaggedStores: { $size: '$flaggedStores' },
798
982
  flaggedStores: '$flaggedStores',
799
983
  flagCount: 1,
800
984
  questionCount: 1,
801
985
  correctAnswers: { $subtract: [ '$submittedQuestionCount', '$questionFlag' ] },
986
+ // customType: {
987
+ // $cond: { if: { $gte: [ '$questionFlag', 1 ] }, then: 'question', else: {
988
+ // $cond: { if: { $gte: [ '$timeFlag', 1 ] }, then: 'time', else: '' },
989
+ // },
990
+ // },
991
+ // },
802
992
  customQuestionFlagCount: '$questionFlag',
803
993
  customTimeFlagCount: '$timeFlag',
994
+ // correctAnswers: '$questionFlag',
804
995
  aiStoreList: 1,
805
996
  },
806
997
  } );
@@ -939,6 +1130,752 @@ export const flagTablesV1 = async ( req, res ) => {
939
1130
  }
940
1131
  };
941
1132
 
1133
+ async function checklistCardData( checklistType ) {
1134
+ try {
1135
+ let resData = {};
1136
+ switch ( checklistType ) {
1137
+ case 'storeopenandclose':
1138
+ resData.storeopenandcloseCards = {};
1139
+ resData.storeopenandcloseCards = {
1140
+ 'totalAssignedStores': { 'count': 300 },
1141
+ 'lateOpenStores': { 'count': 200 },
1142
+ 'earlyClosedStores': { 'count': 100 },
1143
+ 'complianceRate': { 'rate': 100 },
1144
+ };
1145
+ break;
1146
+ case 'mobileusagedetection':
1147
+ resData.mobileusagedetectionCards = {};
1148
+ resData.mobileusagedetectionCards = {
1149
+ 'totalAssignedStores': { 'count': 300 },
1150
+ 'flagIncidents': { 'count': 200 },
1151
+ 'complianceRate': { 'rate': 100 },
1152
+ };
1153
+ break;
1154
+ case 'uniformdetection':
1155
+ resData.uniformdetectionCards = {};
1156
+ resData.uniformdetectionCards = {
1157
+ 'totalAssignedStores': { 'count': 300 },
1158
+ 'flagIncidents': { 'count': 200 },
1159
+ 'complianceRate': { 'rate': 100 },
1160
+ };
1161
+ break;
1162
+ case 'customerunattended':
1163
+ resData.customerunattendedCards = {};
1164
+ resData.customerunattendedCards = {
1165
+ 'averageFootfall': {
1166
+ 'count': 300,
1167
+ },
1168
+ 'stafftoCustomerRatio': {
1169
+ 'ratio': '6:5',
1170
+ },
1171
+ 'attendedCustomers': {
1172
+ 'count': 100,
1173
+ },
1174
+ 'unattendedCustomers': {
1175
+ 'count': 100,
1176
+ },
1177
+ 'timeTakentoAssist': {
1178
+ 'mins': 100,
1179
+ },
1180
+ 'timeSpentwithCustomer': {
1181
+ 'mins': 100,
1182
+ },
1183
+ 'unattendedSummaryChart': {
1184
+ 'chart1': [
1185
+ {
1186
+ 'category': 'Un-Attended Peak Hours',
1187
+ 'value': 60,
1188
+ },
1189
+ {
1190
+ 'category': 'Un-Attended Non Peak Hours',
1191
+ 'value': 30,
1192
+ },
1193
+ {
1194
+ 'category': 'Un-Attended Customer Rate',
1195
+ 'value': 10,
1196
+ },
1197
+ ],
1198
+ 'chart2': [
1199
+ {
1200
+ 'category': 'Customer Attended Within Threshold',
1201
+ 'value': 60,
1202
+ },
1203
+ {
1204
+ 'category': 'Customer Attended After Threshold',
1205
+ 'value': 40,
1206
+ },
1207
+ ],
1208
+ },
1209
+ };
1210
+ break;
1211
+ case 'staffleftinthemiddle':
1212
+ resData.staffleftinthemiddleCards = {};
1213
+ resData.staffleftinthemiddleCards = {
1214
+ 'avgStaffPresent': {
1215
+ 'count': 300,
1216
+ },
1217
+ 'avgStaffleft': {
1218
+ 'count': 200,
1219
+ },
1220
+ 'avgStaffPresentInPeakHours': {
1221
+ 'rate': '6:5',
1222
+ },
1223
+ 'staffAvgPunctualityRate': {
1224
+ 'rate': 50,
1225
+ },
1226
+ 'staffAvgBreakHours': {
1227
+ 'mins': 100,
1228
+ },
1229
+ 'staffAvgProductiveHours': {
1230
+ 'mins': 100,
1231
+ },
1232
+ };
1233
+ break;
1234
+ case 'custom':
1235
+ resData.customCards = {};
1236
+ resData.customCards = {
1237
+ 'totalAssignedStores': {
1238
+ 'count': 300,
1239
+ },
1240
+ 'flagIncidents': {
1241
+ 'count': 200,
1242
+ },
1243
+ 'complianceRate': {
1244
+ 'count': 100,
1245
+ },
1246
+ };
1247
+ break;
1248
+ default:
1249
+ break;
1250
+ }
1251
+ return resData;
1252
+ } catch ( error ) {
1253
+ console.log( 'error =>', error );
1254
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1255
+ }
1256
+ }
1257
+
1258
+ async function checklistComparisonData( checklistType ) {
1259
+ try {
1260
+ let resData = {};
1261
+ switch ( checklistType ) {
1262
+ case 'storeopenandclose':
1263
+ resData.storeopenandcloseCards = {};
1264
+ resData.storeopenandcloseCards = {
1265
+ 'totalAssignedStores': {
1266
+ 'comparisonData': 40,
1267
+ 'ComparisonFlag': true,
1268
+ },
1269
+ 'lateOpenStores': {
1270
+ 'comparisonData': 50,
1271
+ 'ComparisonFlag': true,
1272
+ },
1273
+ 'earlyClosedStores': {
1274
+ 'comparisonData': 20,
1275
+ 'ComparisonFlag': false,
1276
+ },
1277
+ 'complianceRate': {
1278
+ 'comparisonData': 10,
1279
+ 'ComparisonFlag': false,
1280
+ },
1281
+ };
1282
+ break;
1283
+ case 'mobileusagedetection':
1284
+ resData.mobileusagedetectionCards = {};
1285
+ resData.mobileusagedetectionCards = {
1286
+ 'totalAssignedStores': {
1287
+ 'comparisonData': 40,
1288
+ 'ComparisonFlag': true,
1289
+ },
1290
+ 'flagIncidents': {
1291
+ 'comparisonData': 50,
1292
+ 'ComparisonFlag': false,
1293
+ },
1294
+ 'complianceRate': {
1295
+ 'comparisonData': 40,
1296
+ 'ComparisonFlag': true,
1297
+ },
1298
+ };
1299
+ break;
1300
+ case 'uniformdetection':
1301
+ resData.uniformdetectionCards = {};
1302
+ resData.uniformdetectionCards = {
1303
+ 'totalAssignedStores': {
1304
+ 'comparisonData': 40,
1305
+ 'ComparisonFlag': true,
1306
+ },
1307
+ 'flagIncidents': {
1308
+ 'comparisonData': 50,
1309
+ 'ComparisonFlag': false,
1310
+ },
1311
+ 'complianceRate': {
1312
+ 'comparisonData': 40,
1313
+ 'ComparisonFlag': true,
1314
+ },
1315
+ };
1316
+ break;
1317
+ case 'customerunattended':
1318
+ resData.customerunattendedCards = {};
1319
+ resData.customerunattendedCards = {
1320
+ 'averageFootfall': {
1321
+ 'comparisonData': 40,
1322
+ 'ComparisonFlag': true,
1323
+ },
1324
+ 'stafftoCustomerRatio': {
1325
+ 'comparisonData': 50,
1326
+ 'ComparisonFlag': true,
1327
+ },
1328
+ 'attendedCustomers': {
1329
+ 'comparisonData': 40,
1330
+ 'ComparisonFlag': false,
1331
+ },
1332
+ 'unattendedCustomers': {
1333
+ 'comparisonData': 10,
1334
+ 'ComparisonFlag': true,
1335
+ },
1336
+ 'timeTakentoAssist': {
1337
+ 'comparisonData': 30,
1338
+ 'ComparisonFlag': false,
1339
+ },
1340
+ 'timeSpentwithCustomer': {
1341
+ 'comparisonData': 40,
1342
+ 'ComparisonFlag': true,
1343
+ },
1344
+ };
1345
+ break;
1346
+ case 'staffleftinthemiddle':
1347
+ resData.staffleftinthemiddleCards = {};
1348
+ resData.staffleftinthemiddleCards = {
1349
+ 'avgStaffPresent': {
1350
+ 'comparisonData': 40,
1351
+ 'ComparisonFlag': false,
1352
+ },
1353
+ 'avgStaffleft': {
1354
+ 'comparisonData': 50,
1355
+ 'ComparisonFlag': true,
1356
+ },
1357
+ 'avgStaffPresentInPeakHours': {
1358
+ 'comparisonData': 30,
1359
+ 'ComparisonFlag': true,
1360
+ },
1361
+ 'staffAvgPunctualityRate': {
1362
+ 'comparisonData': 50,
1363
+ 'ComparisonFlag': true,
1364
+ },
1365
+ 'staffAvgBreakHours': {
1366
+ 'comparisonData': 40,
1367
+ 'ComparisonFlag': false,
1368
+ },
1369
+ 'staffAvgProductiveHours': {
1370
+ 'comparisonData': 60,
1371
+ 'ComparisonFlag': true,
1372
+ },
1373
+ };
1374
+ break;
1375
+ case 'custom':
1376
+ resData.customCards = {};
1377
+ resData.customCards = {
1378
+ 'totalAssignedStores': {
1379
+ 'comparisonData': 40,
1380
+ 'ComparisonFlag': true,
1381
+ },
1382
+ 'flagIncidents': {
1383
+ 'comparisonData': 20,
1384
+ 'ComparisonFlag': false,
1385
+ },
1386
+ 'complianceRate': {
1387
+ 'comparisonData': 10,
1388
+ 'ComparisonFlag': false,
1389
+ },
1390
+ };
1391
+ break;
1392
+ default:
1393
+ break;
1394
+ }
1395
+ return resData;
1396
+ } catch ( error ) {
1397
+ console.log( 'error =>', error );
1398
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1399
+ }
1400
+ }
1401
+
1402
+ async function tableData( checklistType ) {
1403
+ try {
1404
+ let resData = {};
1405
+ resData.totalCount = 300;
1406
+ switch ( checklistType ) {
1407
+ case 'storeopenandclose':
1408
+ resData.storeopenandcloseData = {};
1409
+ resData.storeopenandcloseData = [
1410
+ {
1411
+ 'date': '02 Aug, 2024',
1412
+ 'dateString': '2024-10-10',
1413
+ 'storeName': 'LKST400',
1414
+ 'storeId': '11-10',
1415
+ 'storeSpocEmail': 'olivia@yopmail.com',
1416
+ 'openTime': '09:00 AM',
1417
+ 'openTimeFlag': false,
1418
+ 'closeTime': '10:00 PM',
1419
+ 'closeTimeFlag': false,
1420
+ },
1421
+ {
1422
+ 'date': '02 Aug, 2024',
1423
+ 'dateString': '2024-10-10',
1424
+ 'storeName': 'LKST401',
1425
+ 'storeId': '11-11',
1426
+ 'storeSpocEmail': 'yamini@yopmail.com',
1427
+ 'openTime': '09:10 AM',
1428
+ 'openTimeFlag': true,
1429
+ 'closeTime': '10:00 PM',
1430
+ 'closeTimeFlag': false,
1431
+ },
1432
+ {
1433
+ 'date': '02 Aug, 2024',
1434
+ 'dateString': '2024-10-10',
1435
+ 'storeName': 'LKST402',
1436
+ 'storeId': '11-12',
1437
+ 'storeSpocEmail': 'balaji@yopmail.com',
1438
+ 'openTime': '09:00 AM',
1439
+ 'openTimeFlag': false,
1440
+ 'closeTime': '09:50 PM',
1441
+ 'closeTimeFlag': true,
1442
+ },
1443
+ {
1444
+ 'date': '02 Aug, 2024',
1445
+ 'dateString': '2024-10-10',
1446
+ 'storeName': 'LKST402',
1447
+ 'storeId': '11-12',
1448
+ 'storeSpocEmail': 'balaji@yopmail.com',
1449
+ 'openTime': '09:10 AM',
1450
+ 'openTimeFlag': true,
1451
+ 'closeTime': '09:50 PM',
1452
+ 'closeTimeFlag': true,
1453
+ },
1454
+ ];
1455
+ break;
1456
+ case 'mobileusagedetection':
1457
+ resData.mobileusagedetectionData = {};
1458
+ resData.mobileusagedetectionData = [
1459
+ {
1460
+ 'date': '02 Aug, 2024',
1461
+ 'dateString': '2024-10-10',
1462
+ 'storeName': 'LKST400',
1463
+ 'storeId': '11-10',
1464
+ 'storeSpocEmail': 'olivia@yopmail.com',
1465
+ 'detections': 50,
1466
+ },
1467
+ {
1468
+ 'date': '02 Aug, 2024',
1469
+ 'dateString': '2024-10-10',
1470
+ 'storeName': 'LKST401',
1471
+ 'storeId': '11-11',
1472
+ 'storeSpocEmail': 'yamini@yopmail.com',
1473
+ 'detections': 60,
1474
+ },
1475
+ {
1476
+ 'date': '02 Aug, 2024',
1477
+ 'dateString': '2024-10-10',
1478
+ 'storeName': 'LKST402',
1479
+ 'storeId': '11-12',
1480
+ 'storeSpocEmail': 'balaji@yopmail.com',
1481
+ 'detections': 70,
1482
+ },
1483
+ {
1484
+ 'date': '02 Aug, 2024',
1485
+ 'dateString': '2024-10-10',
1486
+ 'storeName': 'LKST402',
1487
+ 'storeId': '11-12',
1488
+ 'storeSpocEmail': 'balaji@yopmail.com',
1489
+ 'detections': 90,
1490
+ },
1491
+ ];
1492
+ break;
1493
+ case 'uniformdetection':
1494
+ resData.uniformdetectionData = {};
1495
+ resData.uniformdetectionData = [
1496
+ {
1497
+ 'date': '02 Aug, 2024',
1498
+ 'dateString': '2024-10-10',
1499
+ 'storeName': 'LKST400',
1500
+ 'storeId': '11-10',
1501
+ 'storeSpocEmail': 'olivia@yopmail.com',
1502
+ 'detections': 50,
1503
+ },
1504
+ {
1505
+ 'date': '02 Aug, 2024',
1506
+ 'dateString': '2024-10-10',
1507
+ 'storeName': 'LKST401',
1508
+ 'storeId': '11-11',
1509
+ 'storeSpocEmail': 'yamini@yopmail.com',
1510
+ 'detections': 60,
1511
+ },
1512
+ {
1513
+ 'date': '02 Aug, 2024',
1514
+ 'dateString': '2024-10-10',
1515
+ 'storeName': 'LKST402',
1516
+ 'storeId': '11-12',
1517
+ 'storeSpocEmail': 'balaji@yopmail.com',
1518
+ 'detections': 70,
1519
+ },
1520
+ {
1521
+ 'date': '02 Aug, 2024',
1522
+ 'dateString': '2024-10-10',
1523
+ 'storeName': 'LKST402',
1524
+ 'storeId': '11-12',
1525
+ 'storeSpocEmail': 'balaji@yopmail.com',
1526
+ 'detections': 90,
1527
+ },
1528
+ ];
1529
+ break;
1530
+ case 'customerunattended':
1531
+ resData.customerunattendedData = {};
1532
+ resData.customerunattendedData = [
1533
+ {
1534
+ 'date': '02 Aug, 2024',
1535
+ 'dateString': '2024-10-10',
1536
+ 'storeName': 'LKST400',
1537
+ 'storeId': '11-10',
1538
+ 'storeSpocEmail': 'olivia@yopmail.com',
1539
+ 'detections': 50,
1540
+ },
1541
+ {
1542
+ 'date': '02 Aug, 2024',
1543
+ 'dateString': '2024-10-10',
1544
+ 'storeName': 'LKST401',
1545
+ 'storeId': '11-11',
1546
+ 'storeSpocEmail': 'yamini@yopmail.com',
1547
+ 'detections': 60,
1548
+ },
1549
+ {
1550
+ 'date': '02 Aug, 2024',
1551
+ 'dateString': '2024-10-10',
1552
+ 'storeName': 'LKST402',
1553
+ 'storeId': '11-12',
1554
+ 'storeSpocEmail': 'balaji@yopmail.com',
1555
+ 'detections': 70,
1556
+ },
1557
+ {
1558
+ 'date': '02 Aug, 2024',
1559
+ 'dateString': '2024-10-10',
1560
+ 'storeName': 'LKST402',
1561
+ 'storeId': '11-12',
1562
+ 'storeSpocEmail': 'balaji@yopmail.com',
1563
+ 'detections': 90,
1564
+ },
1565
+ ];
1566
+ break;
1567
+ case 'staffleftinthemiddle':
1568
+ resData.staffleftinthemiddleData = {};
1569
+ resData.staffleftinthemiddleData = [
1570
+ {
1571
+ 'date': '02 Aug, 2024',
1572
+ 'dateString': '2024-10-10',
1573
+ 'storeName': 'LKST400',
1574
+ 'storeId': '11-10',
1575
+ 'storeSpocEmail': 'olivia@yopmail.com',
1576
+ 'detections': 50,
1577
+ },
1578
+ {
1579
+ 'date': '02 Aug, 2024',
1580
+ 'dateString': '2024-10-10',
1581
+ 'storeName': 'LKST401',
1582
+ 'storeId': '11-11',
1583
+ 'storeSpocEmail': 'yamini@yopmail.com',
1584
+ 'detections': 60,
1585
+ },
1586
+ {
1587
+ 'date': '02 Aug, 2024',
1588
+ 'dateString': '2024-10-10',
1589
+ 'storeName': 'LKST402',
1590
+ 'storeId': '11-12',
1591
+ 'storeSpocEmail': 'balaji@yopmail.com',
1592
+ 'detections': 70,
1593
+ },
1594
+ {
1595
+ 'date': '02 Aug, 2024',
1596
+ 'dateString': '2024-10-10',
1597
+ 'storeName': 'LKST402',
1598
+ 'storeId': '11-12',
1599
+ 'storeSpocEmail': 'balaji@yopmail.com',
1600
+ 'detections': 90,
1601
+ },
1602
+ ];
1603
+ break;
1604
+ case 'custom':
1605
+ resData.customData = {};
1606
+ resData.customData = [
1607
+ {
1608
+ 'date': '02 Aug, 2024',
1609
+ 'dateString': '2024-10-10',
1610
+ 'storeName': 'LKST400',
1611
+ 'storeId': '11-10',
1612
+ 'storeSpocEmail': 'olivia@yopmail.com',
1613
+ 'detections': 50,
1614
+ },
1615
+ {
1616
+ 'date': '02 Aug, 2024',
1617
+ 'dateString': '2024-10-10',
1618
+ 'storeName': 'LKST401',
1619
+ 'storeId': '11-11',
1620
+ 'storeSpocEmail': 'yamini@yopmail.com',
1621
+ 'detections': 60,
1622
+ },
1623
+ {
1624
+ 'date': '02 Aug, 2024',
1625
+ 'dateString': '2024-10-10',
1626
+ 'storeName': 'LKST402',
1627
+ 'storeId': '11-12',
1628
+ 'storeSpocEmail': 'balaji@yopmail.com',
1629
+ 'detections': 70,
1630
+ },
1631
+ {
1632
+ 'date': '02 Aug, 2024',
1633
+ 'dateString': '2024-10-10',
1634
+ 'storeName': 'LKST402',
1635
+ 'storeId': '11-12',
1636
+ 'storeSpocEmail': 'balaji@yopmail.com',
1637
+ 'detections': 90,
1638
+ },
1639
+ ];
1640
+ break;
1641
+ default:
1642
+ break;
1643
+ }
1644
+ return resData;
1645
+ } catch ( error ) {
1646
+ console.log( 'error =>', error );
1647
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1648
+ }
1649
+ }
1650
+
1651
+ async function flagCardData( checklistType ) {
1652
+ try {
1653
+ let resData = {};
1654
+ resData.flagCards = {
1655
+ 'totalFlag': 700,
1656
+ 'questionFlag': {
1657
+ 'count': 40,
1658
+ },
1659
+ 'delayInSubmission': {
1660
+ 'count': 50,
1661
+ },
1662
+ 'detectionFlag': {
1663
+ 'count': 20,
1664
+ },
1665
+ };
1666
+ return resData;
1667
+ } catch ( error ) {
1668
+ console.log( 'error =>', error );
1669
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1670
+ }
1671
+ }
1672
+
1673
+ async function falgComparisonData( checklistType ) {
1674
+ try {
1675
+ let resData = {};
1676
+ resData.flagComparisonCards = {
1677
+ 'questionComparisonFlag': {
1678
+ 'comparisonData': 40,
1679
+ 'ComparisonFlag': true,
1680
+ },
1681
+ 'delayInSubmissionComparisonFlag': {
1682
+ 'comparisonData': 50,
1683
+ 'ComparisonFlag': false,
1684
+ },
1685
+ 'detectionComparisonFlag': {
1686
+ 'comparisonData': 20,
1687
+ 'ComparisonFlag': true,
1688
+ },
1689
+ };
1690
+ return resData;
1691
+ } catch ( error ) {
1692
+ console.log( 'error =>', error );
1693
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1694
+ }
1695
+ }
1696
+
1697
+ async function flagTableData( checklistType ) {
1698
+ try {
1699
+ let resData = {};
1700
+ resData.totalCount = 300;
1701
+ resData.flagTableData = [
1702
+ {
1703
+ 'checklistName': 'Field VM- Store Visit Checklist',
1704
+ 'sourceCheckList_id': '668e3e1807d5312fa49b0046',
1705
+ 'checkListType': 'custom',
1706
+ 'flagType': 'Question',
1707
+ 'assignedStores': 400,
1708
+ 'flaggedStores': 50,
1709
+ 'flagCount': 30,
1710
+ 'complianceRate': 25,
1711
+ },
1712
+ {
1713
+ 'checklistName': 'DC Prep Checklist',
1714
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1715
+ 'checkListType': 'custom',
1716
+ 'flagType': 'Question',
1717
+ 'assignedStores': 500,
1718
+ 'flaggedStores': 66,
1719
+ 'flagCount': 66,
1720
+ 'complianceRate': 89,
1721
+ },
1722
+ {
1723
+ 'checklistName': 'Store Open and Close',
1724
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1725
+ 'checkListType': 'storeopenandclose',
1726
+ 'flagType': 'Question',
1727
+ 'assignedStores': 300,
1728
+ 'flaggedStores': 70,
1729
+ 'flagCount': 80,
1730
+ 'complianceRate': 25,
1731
+ },
1732
+ {
1733
+ 'checklistName': 'Mobileusage Detection',
1734
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1735
+ 'checkListType': 'mobileusagedetection',
1736
+ 'flagType': 'Detection',
1737
+ 'assignedStores': 250,
1738
+ 'flaggedStores': 30,
1739
+ 'flagCount': 80,
1740
+ 'complianceRate': 77,
1741
+ },
1742
+ {
1743
+ 'checklistName': 'Uniform Detection',
1744
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1745
+ 'checkListType': 'uniformdetection',
1746
+ 'flagType': 'Detection',
1747
+ 'assignedStores': 100,
1748
+ 'flaggedStores': 0,
1749
+ 'flagCount': 60,
1750
+ 'complianceRate': 45,
1751
+ },
1752
+ {
1753
+ 'checklistName': 'Customer Unattended',
1754
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1755
+ 'checkListType': 'customerunattended',
1756
+ 'flagType': 'Detection',
1757
+ 'assignedStores': 200,
1758
+ 'flaggedStores': 20,
1759
+ 'flagCount': 70,
1760
+ 'complianceRate': 55,
1761
+ },
1762
+ {
1763
+ 'checklistName': 'Staff Left in The Middle',
1764
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1765
+ 'checkListType': 'staffleftinthemiddle',
1766
+ 'flagType': 'Detection',
1767
+ 'assignedStores': 150,
1768
+ 'flaggedStores': 50,
1769
+ 'flagCount': 50,
1770
+ 'complianceRate': 30,
1771
+ },
1772
+ ];
1773
+ return resData;
1774
+ } catch ( error ) {
1775
+ console.log( 'error =>', error );
1776
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1777
+ }
1778
+ }
1779
+
1780
+ async function checklistDropdownData( checklistType ) {
1781
+ try {
1782
+ let resData = {};
1783
+ resData.checklistDropdownData = [
1784
+ {
1785
+ 'checklistName': 'Field VM- Store Visit Checklist',
1786
+ 'sourceCheckList_id': '668e3e1807d5312fa49b0046',
1787
+ 'checkListType': 'custom',
1788
+ 'createdByName': 'Yamini',
1789
+ 'storeCount': 1853,
1790
+ 'scheduleRepeatedType': 'weekly',
1791
+ 'scheduleStartTime': '12:00 PM',
1792
+ 'scheduleEndTime': '06:00 PM',
1793
+ 'publish': true,
1794
+ },
1795
+ {
1796
+ 'checklistName': 'DC Prep Checklist',
1797
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167361',
1798
+ 'checkListType': 'custom',
1799
+ 'createdByName': 'Yamini',
1800
+ 'storeCount': 1853,
1801
+ 'scheduleRepeatedType': 'weekly',
1802
+ 'scheduleStartTime': '12:00 PM',
1803
+ 'scheduleEndTime': '06:00 PM',
1804
+ 'publish': true,
1805
+ },
1806
+ {
1807
+ 'checklistName': 'Store Open and Close',
1808
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167362',
1809
+ 'checkListType': 'storeopenandclose',
1810
+ 'createdByName': 'Yamini',
1811
+ 'storeCount': 1853,
1812
+ 'scheduleRepeatedType': 'weekly',
1813
+ 'scheduleStartTime': '12:00 PM',
1814
+ 'scheduleEndTime': '06:00 PM',
1815
+ 'publish': true,
1816
+ },
1817
+ {
1818
+ 'checklistName': 'Mobileusage Detection',
1819
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167363',
1820
+ 'checkListType': 'mobileusagedetection',
1821
+ 'createdByName': 'Yamini',
1822
+ 'storeCount': 1853,
1823
+ 'scheduleRepeatedType': 'weekly',
1824
+ 'scheduleStartTime': '12:00 PM',
1825
+ 'scheduleEndTime': '06:00 PM',
1826
+ 'publish': true,
1827
+ },
1828
+ {
1829
+ 'checklistName': 'Uniform Detection',
1830
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167364',
1831
+ 'checkListType': 'uniformdetection',
1832
+ 'createdByName': 'Yamini',
1833
+ 'storeCount': 1853,
1834
+ 'scheduleRepeatedType': 'weekly',
1835
+ 'scheduleStartTime': '12:00 PM',
1836
+ 'scheduleEndTime': '06:00 PM',
1837
+ 'publish': true,
1838
+ },
1839
+ {
1840
+ 'checklistName': 'Customer Unattended',
1841
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167365',
1842
+ 'checkListType': 'customerunattended',
1843
+ 'createdByName': 'Yamini',
1844
+ 'storeCount': 1853,
1845
+ 'scheduleRepeatedType': 'weekly',
1846
+ 'scheduleStartTime': '12:00 PM',
1847
+ 'scheduleEndTime': '06:00 PM',
1848
+ 'publish': true,
1849
+ },
1850
+ {
1851
+ 'checklistName': 'Staff Left in The Middle',
1852
+ 'sourceCheckList_id': '6690d95b747d2cc1f1167366',
1853
+ 'checkListType': 'staffleftinthemiddle',
1854
+ 'createdByName': 'Yamini',
1855
+ 'storeCount': 1853,
1856
+ 'scheduleRepeatedType': 'weekly',
1857
+ 'scheduleStartTime': '12:00 PM',
1858
+ 'scheduleEndTime': '06:00 PM',
1859
+ 'publish': true,
1860
+ },
1861
+ {
1862
+ 'checklistName': 'Field VM- Store Visit Checklist Field VM- Store Visit Checklist',
1863
+ 'sourceCheckList_id': '668e3e1807d5312fa49b0046',
1864
+ 'checkListType': 'custom',
1865
+ 'createdByName': 'Yamini',
1866
+ 'storeCount': 1853,
1867
+ 'scheduleRepeatedType': 'weekly',
1868
+ 'scheduleStartTime': '12:00 PM',
1869
+ 'scheduleEndTime': '06:00 PM',
1870
+ 'publish': true,
1871
+ },
1872
+ ];
1873
+ return resData;
1874
+ } catch ( error ) {
1875
+ console.log( 'error =>', error );
1876
+ logger.error( { error: error, message: data, function: 'returnServerError' } );
1877
+ }
1878
+ }
942
1879
 
943
1880
  // Lamda Service Call //
944
1881
  async function LamdaServiceCall( url, data ) {
@@ -966,6 +1903,10 @@ async function LamdaServiceCall( url, data ) {
966
1903
  export const flagChecklistCardsV1 = async ( req, res ) => {
967
1904
  try {
968
1905
  let reqestData = req.body;
1906
+ // Get User Based Checklist //
1907
+ // let loginUser = { clientId: reqestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
1908
+ // let getUserEmails = await getChecklistUsers( loginUser );
1909
+ // End: Get User Based Checklist////
969
1910
 
970
1911
  if ( reqestData.ChecklistType == 'custom' ) {
971
1912
  const pipeline = [
@@ -1806,7 +2747,7 @@ export const checklistDropdownV1 = async ( req, res ) => {
1806
2747
  $or: [
1807
2748
  { questionFlag: { $gte: 1 } },
1808
2749
  { timeFlag: { $gte: 1 } },
1809
- { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring', 'unattendeddetection', 'vehicle_check_in', 'employeemonitoring', 'activitymonitoring' ] } },
2750
+ { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring', 'unattendeddetection', 'vehicle_check_in', 'employeemonitoring' ] } },
1810
2751
  {
1811
2752
  runAIQuestionCount: { $gte: 1 },
1812
2753
  },
@@ -2008,7 +2949,7 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
2008
2949
  {
2009
2950
  client_id: requestData.clientId,
2010
2951
  publish: true,
2011
- checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring', 'unattendeddetection', 'employeemonitoring', 'activitymonitoring' ] },
2952
+ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring', 'unattendeddetection', 'employeemonitoring' ] },
2012
2953
  },
2013
2954
  { checkListType: 1 },
2014
2955
  );
@@ -2110,7 +3051,7 @@ export const flagTablesV2 = async ( req, res ) => {
2110
3051
  }
2111
3052
 
2112
3053
  if ( requestData?.filter === 'all' ) {
2113
- findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring', 'unattendeddetection', 'vehicle_check_in', 'employeemonitoring', 'activitymonitoring' ] } } ] } );
3054
+ findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring', 'unattendeddetection', 'vehicle_check_in', 'employeemonitoring' ] } } ] } );
2114
3055
  } else if ( requestData?.filter === 'question' ) {
2115
3056
  findAndQuery.push( { checkListType: 'custom' } );
2116
3057
  findAndQuery.push( { questionFlag: { $gte: 1 } } );
@@ -2118,7 +3059,7 @@ export const flagTablesV2 = async ( req, res ) => {
2118
3059
  findAndQuery.push( { checkListType: 'custom' } );
2119
3060
  findAndQuery.push( { timeFlag: { $gte: 1 } } );
2120
3061
  } else if ( requestData?.filter === 'detection' ) {
2121
- findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring', 'unattendeddetection', 'vehicle_check_in', 'employeemonitoring', 'activitymonitoring' ] } } );
3062
+ findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring', 'unattendeddetection', 'vehicle_check_in', 'employeemonitoring' ] } } );
2122
3063
  } else if ( requestData?.filter === 'runAI' ) {
2123
3064
  if ( req.body.runAIChecklistName ) {
2124
3065
  findAndQuery.push( { checkListName: { $in: req.body.runAIChecklistName } } );
@@ -2177,9 +3118,6 @@ export const flagTablesV2 = async ( req, res ) => {
2177
3118
  { '$gt': [ '$staffLeftInTheMiddle', 0 ] },
2178
3119
  { '$gt': [ '$cleaning', 0 ] },
2179
3120
  { '$gt': [ '$scrum', 0 ] },
2180
- { '$gt': [ '$employeeCount', 0 ] },
2181
- { '$gt': [ '$employeemonitoring', 0 ] },
2182
- { '$gt': [ '$activitymonitoring', 0 ] },
2183
3121
  ],
2184
3122
  },
2185
3123
  1,