tango-app-api-trax 1.0.0-alpha.0 → 1.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-trax",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.2",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,5 +1,6 @@
1
1
  import { logger } from 'tango-app-api-middleware';
2
2
  import * as processedchecklistService from '../services/processedchecklist.services.js';
3
+ import mongoose from 'mongoose';
3
4
 
4
5
  export const welcome = async ( req, res ) => {
5
6
  try {
@@ -22,12 +23,22 @@ export const overallCards = async ( req, res ) => {
22
23
  toDate = new Date( toDate.getTime() - userTimezoneOffset );
23
24
  toDate.setUTCHours( 23, 59, 59, 59 );
24
25
  let activeUnique = 0;
25
- let total = 0;
26
- let notSubmitted = 0;
27
- let open = 0;
28
- let inprogress = 0;
29
- let submitted = 0;
30
- let totalFlags = {
26
+ let notSubmittedInstances = {
27
+ 'count': '',
28
+ 'open': '',
29
+ 'inprogress': '',
30
+ };
31
+ let totalInstances = {
32
+ 'count': '',
33
+ 'comparisonData': '',
34
+ 'ComparisonFlag': '',
35
+ };
36
+ let completedInstances = {
37
+ 'count': '',
38
+ 'comparisonData': '',
39
+ 'ComparisonFlag': '',
40
+ };
41
+ let flags = {
31
42
  'count': '',
32
43
  'comparisonData': '',
33
44
  'ComparisonFlag': '',
@@ -37,124 +48,115 @@ export const overallCards = async ( req, res ) => {
37
48
  'comparisonData': '',
38
49
  'ComparisonFlag': '',
39
50
  };
40
- let complianceScore = {
51
+ let complianceRate = {
41
52
  'count': '',
42
53
  'comparisonData': '',
43
54
  'ComparisonFlag': '',
44
55
  };
45
56
  let result = {};
46
57
 
47
- let overallChecklistDataQuery = [
48
- {
49
- $match: {
50
- client_id: reqestData.clientId,
51
- $and: [
52
- { store_id: { $in: reqestData.storeId } },
53
- { date_iso: { $gte: fromDate } },
54
- { date_iso: { $lte: toDate } },
55
- ],
56
- },
57
- },
58
- {
59
- $project: {
60
- sourceCheckList_id: 1,
61
- checkListId: 1,
62
- checklistStatus: 1,
63
- timeFlag: 1,
64
- questionFlag: 1,
65
- mobileDetectionFlag: 1,
66
- storeOpenCloseFlag: 1,
67
- uniformDetectionFlag: 1,
68
- markasread: 1,
69
- checkListType: 1,
70
- },
58
+ let findQuery = [];
59
+ let findUniqueQuery = [];
60
+ let findAndQuery = [];
61
+ findAndQuery.push(
62
+ { client_id: reqestData.clientId },
63
+ { store_id: { $in: reqestData.storeId } },
64
+ { date_iso: { $gte: fromDate } },
65
+ { date_iso: { $lte: toDate } },
66
+ );
67
+
68
+ findQuery.push( { $match: { $and: findAndQuery } } );
69
+
70
+ findQuery.push( {
71
+ $project: {
72
+ sourceCheckList_id: 1,
73
+ checkListId: 1,
74
+ checklistStatus: 1,
75
+ timeFlag: 1,
76
+ questionFlag: 1,
77
+ mobileDetectionFlag: 1,
78
+ storeOpenCloseFlag: 1,
79
+ uniformDetectionFlag: 1,
80
+ markasread: 1,
81
+ checkListType: 1,
71
82
  },
72
- {
73
- $group: {
74
- _id: '',
75
- totalChecklist: { $sum: 1 },
76
- notSubmittedChecklist: {
77
- $sum: {
78
- $cond: [
79
- {
80
- $and: [
81
- { $ne: [ '$checklistStatus', 'submit' ] },
82
- ],
83
- }, 1, 0 ],
84
- },
85
- },
86
- openChecklist: {
87
- $sum: {
88
- $cond: [
89
- {
90
- $and: [
91
- { $eq: [ '$checklistStatus', 'open' ] },
92
- ],
93
- }, 1, 0 ],
94
- },
95
- },
96
- inprogressChecklist: {
97
- $sum: {
98
- $cond: [
99
- {
100
- $and: [
101
- { $eq: [ '$checklistStatus', 'inprogress' ] },
102
- ],
103
- }, 1, 0 ],
104
- },
83
+ } );
84
+
85
+ findQuery.push( {
86
+ $group: {
87
+ _id: '',
88
+ totalChecklist: { $sum: 1 },
89
+ notSubmittedChecklist: {
90
+ $sum: {
91
+ $cond: [
92
+ {
93
+ $and: [
94
+ { $ne: [ '$checklistStatus', 'submit' ] },
95
+ ],
96
+ }, 1, 0 ],
105
97
  },
106
- submittedChecklist: {
107
- $sum: {
108
- $cond: [
109
- {
110
- $and: [
111
- { $eq: [ '$checklistStatus', 'submit' ] },
112
- ],
113
- }, 1, 0 ],
114
- },
98
+ },
99
+ openChecklist: {
100
+ $sum: {
101
+ $cond: [
102
+ {
103
+ $and: [
104
+ { $eq: [ '$checklistStatus', 'open' ] },
105
+ ],
106
+ }, 1, 0 ],
115
107
  },
116
- flaggedChecklist: {
117
- $sum: {
118
- $cond: [ {
119
- $or: [
120
- { $gt: [ '$timeFlag', 0 ] },
121
- { $gt: [ '$mobileDetectionFlag', 0 ] },
122
- { $gt: [ '$storeOpenCloseFlag', 0 ] },
123
- { $gt: [ '$uniformDetectionFlag', 0 ] },
108
+ },
109
+ inprogressChecklist: {
110
+ $sum: {
111
+ $cond: [
112
+ {
113
+ $and: [
114
+ { $eq: [ '$checklistStatus', 'inprogress' ] },
124
115
  ],
125
116
  }, 1, 0 ],
126
- },
127
117
  },
128
118
  },
129
- },
130
- ];
131
- let getOverallChecklistData = await processedchecklistService.aggregate( overallChecklistDataQuery );
132
- let uniqueChecklistDataQuery = [
133
- {
134
- $match: {
135
- client_id: reqestData.clientId,
136
- $and: [
137
- { store_id: { $in: reqestData.storeId } },
138
- { date_iso: { $gte: fromDate } },
139
- { date_iso: { $lte: toDate } },
140
- ],
119
+ submittedChecklist: {
120
+ $sum: {
121
+ $cond: [
122
+ {
123
+ $and: [
124
+ { $eq: [ '$checklistStatus', 'submit' ] },
125
+ ],
126
+ }, 1, 0 ],
127
+ },
141
128
  },
142
- },
143
- {
144
- $project: {
145
- sourceCheckList_id: 1,
129
+ flaggedChecklist: {
130
+ $sum: {
131
+ $cond: [ {
132
+ $or: [
133
+ { $gt: [ '$timeFlag', 0 ] },
134
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
135
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
136
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
137
+ ],
138
+ }, 1, 0 ],
139
+ },
146
140
  },
147
141
  },
148
- {
149
- $group: {
150
- _id: '$sourceCheckList_id',
151
- },
142
+ } );
143
+ let getOverallChecklistData = await processedchecklistService.aggregate( findQuery );
144
+
145
+ findUniqueQuery.push( { $match: { $and: findAndQuery } } );
146
+ findUniqueQuery.push( {
147
+ $project: {
148
+ sourceCheckList_id: 1,
152
149
  },
153
- {
154
- $count: 'totalUniqueChecklist',
150
+ } );
151
+ findUniqueQuery.push( {
152
+ $group: {
153
+ _id: '$sourceCheckList_id',
155
154
  },
156
- ];
157
- let getUniqueChecklistData = await processedchecklistService.aggregate( uniqueChecklistDataQuery );
155
+ } );
156
+ findUniqueQuery.push( {
157
+ $count: 'totalUniqueChecklist',
158
+ } );
159
+ let getUniqueChecklistData = await processedchecklistService.aggregate( findUniqueQuery );
158
160
  if ( !getUniqueChecklistData.length && !getOverallChecklistData.length ) {
159
161
  return res.sendError( { error: 'No Data Found' }, 204 );
160
162
  }
@@ -167,35 +169,32 @@ export const overallCards = async ( req, res ) => {
167
169
 
168
170
  if ( getOverallChecklistData.length && getOverallChecklistData.length>0 ) {
169
171
  if ( getOverallChecklistData[0].totalChecklist ) {
170
- total = getOverallChecklistData[0]?.totalChecklist;
172
+ totalInstances.count = getOverallChecklistData[0]?.totalChecklist;
171
173
  }
172
174
  if ( getOverallChecklistData[0].notSubmittedChecklist ) {
173
- notSubmitted = getOverallChecklistData[0]?.notSubmittedChecklist;
175
+ notSubmittedInstances.count = getOverallChecklistData[0]?.notSubmittedChecklist;
174
176
  }
175
177
  if ( getOverallChecklistData[0].openChecklist ) {
176
- open = getOverallChecklistData[0]?.openChecklist;
178
+ notSubmittedInstances.open = getOverallChecklistData[0]?.openChecklist;
177
179
  }
178
180
  if ( getOverallChecklistData[0].inprogressChecklist ) {
179
- inprogress = getOverallChecklistData[0]?.inprogressChecklist;
181
+ notSubmittedInstances.inprogress = getOverallChecklistData[0]?.inprogressChecklist;
180
182
  }
181
183
  if ( getOverallChecklistData[0].submittedChecklist ) {
182
- submitted = getOverallChecklistData[0]?.submittedChecklist;
184
+ completedInstances.count = getOverallChecklistData[0]?.submittedChecklist;
183
185
  }
184
186
  if ( getOverallChecklistData[0].flaggedChecklist ) {
185
- totalFlags.count = getOverallChecklistData[0]?.flaggedChecklist;
187
+ flags.count = getOverallChecklistData[0]?.flaggedChecklist;
186
188
  }
187
189
  }
188
-
189
190
  result.overallCards = {
190
191
  'activeUnique': activeUnique,
191
- 'total': total,
192
- 'notSubmitted': notSubmitted,
193
- 'open': open,
194
- 'inprogress': inprogress,
195
- 'submitted': submitted,
196
- 'totalFlags': totalFlags,
192
+ 'totalInstances': totalInstances,
193
+ 'notSubmittedInstances': notSubmittedInstances,
194
+ 'completedInstances': completedInstances,
195
+ 'flags': flags,
197
196
  'completionScore': completionScore,
198
- 'complianceScore': complianceScore,
197
+ 'complianceRate': complianceRate,
199
198
  };
200
199
  return res.sendSuccess( result );
201
200
  } catch ( error ) {
@@ -314,89 +313,916 @@ export const storePerformance = async ( req, res ) => {
314
313
  toDate.setUTCHours( 23, 59, 59, 59 );
315
314
  let result = {};
316
315
 
317
- let checklistPerformanceQuery = [
318
- {
319
- $match: {
320
- client_id: reqestData.clientId,
321
- $and: [
322
- { store_id: { $in: reqestData.storeId } },
323
- { date_iso: { $gte: fromDate } },
324
- { date_iso: { $lte: toDate } },
325
- ],
326
- },
316
+ let findQuery = [];
317
+ let findAndQuery = [];
318
+ findAndQuery.push(
319
+ { client_id: reqestData.clientId },
320
+ { store_id: { $in: reqestData.storeId } },
321
+ { date_iso: { $gte: fromDate } },
322
+ { date_iso: { $lte: toDate } },
323
+ );
324
+
325
+ findQuery.push( { $match: { $and: findAndQuery } } );
326
+
327
+ if ( reqestData.searchValue && reqestData.searchValue != '' ) {
328
+ findQuery.push( { $match: { $or: [ { storeName: { $regex: reqestData.searchValue, $options: 'i' } } ] } } );
329
+ }
330
+
331
+ findQuery.push( {
332
+ $project: {
333
+ sourceCheckList_id: 1,
334
+ checkListId: 1,
335
+ checkListName: 1,
336
+ storeCount: 1,
337
+ createdBy: 1,
338
+ createdByName: 1,
339
+ checklistStatus: 1,
340
+ timeFlag: 1,
341
+ questionFlag: 1,
342
+ mobileDetectionFlag: 1,
343
+ storeOpenCloseFlag: 1,
344
+ uniformDetectionFlag: 1,
345
+ checkListType: 1,
346
+ scheduleRepeatedType: 1,
347
+ store_id: 1,
348
+ storeName: 1,
349
+ userEmail: 1,
327
350
  },
328
- {
329
- $project: {
330
- sourceCheckList_id: 1,
331
- checkListId: 1,
332
- checkListName: 1,
333
- storeCount: 1,
334
- createdBy: 1,
335
- createdByName: 1,
336
- checklistStatus: 1,
337
- timeFlag: 1,
338
- questionFlag: 1,
339
- mobileDetectionFlag: 1,
340
- storeOpenCloseFlag: 1,
341
- uniformDetectionFlag: 1,
342
- checkListType: 1,
343
- scheduleRepeatedType: 1,
344
- store_id: 1,
345
- storeName: 1,
346
- userEmail: 1,
351
+ } );
352
+
353
+ findQuery.push( {
354
+ $group: {
355
+ _id: '$store_id',
356
+ storeName: { $last: '$storeName' },
357
+ userEmail: { $last: '$userEmail' },
358
+ checkListCount: { $sum: '$store_id' },
359
+ flaggedCount: {
360
+ $sum: {
361
+ $cond: [ {
362
+ $or: [
363
+ { $gt: [ '$timeFlag', 0 ] },
364
+ { $gt: [ '$questionFlag', 0 ] },
365
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
366
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
367
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
368
+ ],
369
+ }, 1, 0 ],
370
+ },
371
+ },
372
+ submittedChecklist: {
373
+ $sum: {
374
+ $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, 1, 0 ],
375
+ },
347
376
  },
377
+ checkListType: { $last: '$checkListType' },
348
378
  },
349
- {
350
- $group: {
351
- _id: '$store_id',
352
- storeName: { $last: '$storeName' },
353
- userEmail: { $last: '$userEmail' },
354
- checkListCount: { $sum: '$store_id' },
355
- flaggedChecklist: {
356
- $sum: {
357
- $cond: [ {
358
- $or: [
359
- { $gt: [ '$timeFlag', 0 ] },
360
- { $gt: [ '$questionFlag', 0 ] },
361
- { $gt: [ '$mobileDetectionFlag', 0 ] },
362
- { $gt: [ '$storeOpenCloseFlag', 0 ] },
363
- { $gt: [ '$uniformDetectionFlag', 0 ] },
364
- ],
365
- }, 1, 0 ],
366
- },
379
+ } );
380
+
381
+ findQuery.push( {
382
+ $project: {
383
+ store_id: 1,
384
+ storeName: 1,
385
+ userEmail: 1,
386
+ checkListCount: 1,
387
+ flaggedCount: 1,
388
+ submittedChecklist: 1,
389
+ checkListType: 1,
390
+ completion: '20',
391
+ compliance: '40',
392
+ performance: '54',
393
+ },
394
+ } );
395
+
396
+ let getTotalCount = await processedchecklistService.aggregate( findQuery );
397
+ if ( !getTotalCount.length ) {
398
+ return res.sendError( { error: 'No Data Found' }, 204 );
399
+ }
400
+
401
+ if ( reqestData.sortColumnName && reqestData.sortColumnName != '' && reqestData.sortBy && reqestData.sortBy !='' ) {
402
+ findQuery.push( { $sort: { [reqestData.sortColumnName]: reqestData.sortBy } } );
403
+ } else {
404
+ findQuery.push( { $sort: { ['submittedChecklist']: -1 } } );
405
+ }
406
+
407
+ let limit = parseInt( reqestData?.limit ) || 10;
408
+ let skip = limit * ( reqestData?.offset ) || 0;
409
+ findQuery.push( { $skip: skip }, { $limit: limit } );
410
+ let getStorePerformanceData = await processedchecklistService.aggregate( findQuery );
411
+
412
+ result.totalCount = getTotalCount.length;
413
+ result.storePerformance = getStorePerformanceData;
414
+ return res.sendSuccess( result );
415
+ } catch ( error ) {
416
+ console.log( 'error =>', error );
417
+ logger.error( { error: error, message: req.query, function: 'storePerformance' } );
418
+ return res.sendError( { error: error }, 500 );
419
+ }
420
+ };
421
+
422
+ export const userPerformance = async ( req, res ) => {
423
+ try {
424
+ let reqestData = req.body;
425
+ let fromDate = new Date( reqestData.fromDate );
426
+ let toDate = new Date( reqestData.toDate );
427
+ let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
428
+ toDate = new Date( toDate.getTime() - userTimezoneOffset );
429
+ toDate.setUTCHours( 23, 59, 59, 59 );
430
+ let result = {};
431
+
432
+ let findQuery = [];
433
+ let findAndQuery = [];
434
+ findAndQuery.push(
435
+ { client_id: reqestData.clientId },
436
+ { store_id: { $in: reqestData.storeId } },
437
+ { date_iso: { $gte: fromDate } },
438
+ { date_iso: { $lte: toDate } },
439
+ );
440
+
441
+ findQuery.push( { $match: { $and: findAndQuery } } );
442
+
443
+ if ( reqestData.searchValue && reqestData.searchValue != '' ) {
444
+ findQuery.push( { $match: { $or: [ { userName: { $regex: reqestData.searchValue, $options: 'i' } } ] } } );
445
+ }
446
+
447
+ findQuery.push( {
448
+ $project: {
449
+ sourceCheckList_id: 1,
450
+ checkListId: 1,
451
+ checkListName: 1,
452
+ storeCount: 1,
453
+ createdBy: 1,
454
+ createdByName: 1,
455
+ checklistStatus: 1,
456
+ timeFlag: 1,
457
+ questionFlag: 1,
458
+ mobileDetectionFlag: 1,
459
+ storeOpenCloseFlag: 1,
460
+ uniformDetectionFlag: 1,
461
+ checkListType: 1,
462
+ scheduleRepeatedType: 1,
463
+ store_id: 1,
464
+ storeName: 1,
465
+ userEmail: 1,
466
+ userName: 1,
467
+ },
468
+ } );
469
+
470
+ findQuery.push( {
471
+ $group: {
472
+ _id: '$userName',
473
+ userEmail: { $last: '$userEmail' },
474
+ checkListCount: { $sum: '$store_id' },
475
+ flaggedCount: {
476
+ $sum: {
477
+ $cond: [ {
478
+ $or: [
479
+ { $gt: [ '$timeFlag', 0 ] },
480
+ { $gt: [ '$questionFlag', 0 ] },
481
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
482
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
483
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
484
+ ],
485
+ }, 1, 0 ],
367
486
  },
368
- submittedChecklist: {
369
- $sum: {
370
- $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, 1, 0 ],
371
- },
487
+ },
488
+ submittedChecklist: {
489
+ $sum: {
490
+ $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, 1, 0 ],
372
491
  },
373
- checkListType: { $last: '$checkListType' },
374
492
  },
493
+ checkListType: { $last: '$checkListType' },
494
+ },
495
+ } );
496
+
497
+ findQuery.push( {
498
+ $project: {
499
+ userName: '$_id',
500
+ userEmail: 1,
501
+ checkListCount: 1,
502
+ flaggedCount: 1,
503
+ submittedChecklist: 1,
504
+ checkListType: 1,
505
+ completion: '20',
506
+ compliance: '40',
507
+ performance: '54',
375
508
  },
376
- ];
509
+ } );
377
510
 
378
- let getTotalCount = await processedchecklistService.aggregate( checklistPerformanceQuery );
511
+ let getTotalCount = await processedchecklistService.aggregate( findQuery );
379
512
  if ( !getTotalCount.length ) {
380
513
  return res.sendError( { error: 'No Data Found' }, 204 );
381
514
  }
382
515
 
383
516
  if ( reqestData.sortColumnName && reqestData.sortColumnName != '' && reqestData.sortBy && reqestData.sortBy !='' ) {
384
- checklistPerformanceQuery.push( { $sort: { [reqestData.sortColumnName]: reqestData.sortBy } } );
517
+ findQuery.push( { $sort: { [reqestData.sortColumnName]: reqestData.sortBy } } );
385
518
  } else {
386
- checklistPerformanceQuery.push( { $sort: { ['submittedChecklist']: -1 } } );
519
+ findQuery.push( { $sort: { ['submittedChecklist']: -1 } } );
387
520
  }
388
521
 
389
522
  let limit = parseInt( reqestData?.limit ) || 10;
390
523
  let skip = limit * ( reqestData?.offset ) || 0;
391
- checklistPerformanceQuery.push( { $skip: skip }, { $limit: limit } );
392
- let getChecklistPerformanceData = await processedchecklistService.aggregate( checklistPerformanceQuery );
524
+ findQuery.push( { $skip: skip }, { $limit: limit } );
525
+ let getUserPerformanceData = await processedchecklistService.aggregate( findQuery );
393
526
 
394
527
  result.totalCount = getTotalCount.length;
395
- result.checklistPerformance = getChecklistPerformanceData;
528
+ result.userPerformance = getUserPerformanceData;
396
529
  return res.sendSuccess( result );
397
530
  } catch ( error ) {
398
531
  console.log( 'error =>', error );
399
- logger.error( { error: error, message: req.query, function: 'storePerformance' } );
532
+ logger.error( { error: error, message: req.query, function: 'userPerformance' } );
533
+ return res.sendError( { error: error }, 500 );
534
+ }
535
+ };
536
+
537
+ export const checklistDropdown = async ( req, res ) => {
538
+ try {
539
+ let reqestData = req.body;
540
+ let fromDate = new Date( reqestData.fromDate );
541
+ let toDate = new Date( reqestData.toDate );
542
+ let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
543
+ toDate = new Date( toDate.getTime() - userTimezoneOffset );
544
+ toDate.setUTCHours( 23, 59, 59, 59 );
545
+ let result = {};
546
+
547
+ let findQuery = [];
548
+ let findAndQuery = [];
549
+ findAndQuery.push(
550
+ { client_id: reqestData.clientId },
551
+ { store_id: { $in: reqestData.storeId } },
552
+ { date_iso: { $gte: fromDate } },
553
+ { date_iso: { $lte: toDate } },
554
+ );
555
+
556
+ findQuery.push( { $match: { $and: findAndQuery } } );
557
+
558
+ findQuery.push( {
559
+ $project: {
560
+ sourceCheckList_id: 1,
561
+ checkListName: 1,
562
+ checkListType: 1,
563
+ createdByName: 1,
564
+ storeCount: 1,
565
+ scheduleRepeatedType: 1,
566
+ scheduleStartTime: 1,
567
+ scheduleEndTime: 1,
568
+ },
569
+ } );
570
+
571
+ findQuery.push( {
572
+ $group: {
573
+ _id: '$sourceCheckList_id',
574
+ sourceCheckList_id: { $last: '$sourceCheckList_id' },
575
+ checkListName: { $last: '$checkListName' },
576
+ checkListType: { $last: '$checkListType' },
577
+ createdByName: { $last: '$createdByName' },
578
+ storeCount: { $max: '$storeCount' },
579
+ scheduleRepeatedType: { $last: '$scheduleRepeatedType' },
580
+ scheduleStartTime: { $last: '$scheduleStartTime' },
581
+ scheduleEndTime: { $last: '$scheduleEndTime' },
582
+ },
583
+ } );
584
+
585
+ findQuery.push( {
586
+ $lookup: {
587
+ from: 'checklistconfigs',
588
+ let: { sourceCheckList_id: '$sourceCheckList_id' },
589
+ pipeline: [
590
+ {
591
+ $match: {
592
+ $expr: {
593
+ $and: [
594
+ { $eq: [ '$_id', '$$sourceCheckList_id' ] },
595
+ ],
596
+ },
597
+ },
598
+ },
599
+ {
600
+ $project: {
601
+ checkListName: 1,
602
+ publish: 1,
603
+ },
604
+ },
605
+ ], as: 'checklistconfigs',
606
+ },
607
+ } );
608
+ findQuery.push( { $unwind: { path: '$checklistconfigs', preserveNullAndEmptyArrays: true } } );
609
+ findQuery.push( {
610
+ $project: {
611
+ sourceCheckList_id: 1,
612
+ checkListName: 1,
613
+ checkListType: 1,
614
+ createdByName: 1,
615
+ storeCount: 1,
616
+ scheduleRepeatedType: 1,
617
+ scheduleStartTime: 1,
618
+ scheduleEndTime: 1,
619
+ publish: '$checklistconfigs.publish',
620
+ },
621
+ } );
622
+
623
+ let getTotalCount = await processedchecklistService.aggregate( findQuery );
624
+ if ( !getTotalCount.length ) {
625
+ return res.sendError( { error: 'No Data Found' }, 204 );
626
+ }
627
+
628
+ if ( reqestData.sortColumnName && reqestData.sortColumnName != '' && reqestData.sortBy && reqestData.sortBy !='' ) {
629
+ findQuery.push( { $sort: { [reqestData.sortColumnName]: reqestData.sortBy } } );
630
+ } else {
631
+ findQuery.push( { $sort: { ['checkListName']: -1 } } );
632
+ }
633
+
634
+ let getChecklistData = await processedchecklistService.aggregate( findQuery );
635
+ result.checklistData = getChecklistData;
636
+ return res.sendSuccess( result );
637
+ } catch ( error ) {
638
+ logger.error( { error: error, message: req.query, function: 'checklistDropdown' } );
639
+ return res.sendError( { error: error }, 500 );
640
+ }
641
+ };
642
+
643
+ export const storeDropdown = async ( req, res ) => {
644
+ try {
645
+ let reqestData = req.body;
646
+ let fromDate = new Date( reqestData.fromDate );
647
+ let toDate = new Date( reqestData.toDate );
648
+ let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
649
+ toDate = new Date( toDate.getTime() - userTimezoneOffset );
650
+ toDate.setUTCHours( 23, 59, 59, 59 );
651
+ let result = {};
652
+
653
+ let findQuery = [];
654
+ let findAndQuery = [];
655
+ findAndQuery.push(
656
+ { client_id: reqestData.clientId },
657
+ { store_id: { $in: reqestData.storeId } },
658
+ { date_iso: { $gte: fromDate } },
659
+ { date_iso: { $lte: toDate } },
660
+ );
661
+
662
+ findQuery.push( { $match: { $and: findAndQuery } } );
663
+
664
+ findQuery.push( {
665
+ $project: {
666
+ store_id: 1,
667
+ storeName: 1,
668
+ },
669
+ } );
670
+
671
+ findQuery.push( {
672
+ $group: {
673
+ _id: '$store_id',
674
+ storeName: { $last: '$storeName' },
675
+ },
676
+ } );
677
+ findQuery.push( {
678
+ $project: {
679
+ _id: 0,
680
+ store_id: '$_id',
681
+ storeName: 1,
682
+ },
683
+ } );
684
+ findQuery.push( {
685
+ $lookup: {
686
+ from: 'stores',
687
+ let: { store_id: '$store_id' },
688
+ pipeline: [
689
+ {
690
+ $match: {
691
+ $expr: {
692
+ $and: [
693
+ { $eq: [ '$storeId', '$$store_id' ] },
694
+ ],
695
+ },
696
+ },
697
+ },
698
+ {
699
+ $project: {
700
+ appId: 1,
701
+ status: 1,
702
+ storeId: 1,
703
+ },
704
+ },
705
+ ], as: 'stores',
706
+ },
707
+ } );
708
+ findQuery.push( { $unwind: { path: '$stores', preserveNullAndEmptyArrays: true } } );
709
+ findQuery.push( {
710
+ $project: {
711
+ _id: 0,
712
+ store_id: 1,
713
+ storeName: 1,
714
+ appId: '$stores.appId',
715
+ },
716
+ } );
717
+
718
+ let getTotalCount = await processedchecklistService.aggregate( findQuery );
719
+ if ( !getTotalCount.length ) {
720
+ return res.sendError( { error: 'No Data Found' }, 204 );
721
+ }
722
+ if ( reqestData.sortColumnName && reqestData.sortColumnName != '' && reqestData.sortBy && reqestData.sortBy !='' ) {
723
+ findQuery.push( { $sort: { [reqestData.sortColumnName]: reqestData.sortBy } } );
724
+ } else {
725
+ findQuery.push( { $sort: { ['store_id']: -1 } } );
726
+ }
727
+
728
+ let getstoreData = await processedchecklistService.aggregate( findQuery );
729
+ result.storeData = getstoreData;
730
+ return res.sendSuccess( result );
731
+ } catch ( error ) {
732
+ logger.error( { error: error, message: req.query, function: 'storeDropdown' } );
733
+ return res.sendError( { error: error }, 500 );
734
+ }
735
+ };
736
+
737
+ export const userDropdown = async ( req, res ) => {
738
+ try {
739
+ let reqestData = req.body;
740
+ let fromDate = new Date( reqestData.fromDate );
741
+ let toDate = new Date( reqestData.toDate );
742
+ let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
743
+ toDate = new Date( toDate.getTime() - userTimezoneOffset );
744
+ toDate.setUTCHours( 23, 59, 59, 59 );
745
+ let result = {};
746
+
747
+ let findQuery = [];
748
+ let findAndQuery = [];
749
+ findAndQuery.push(
750
+ { client_id: reqestData.clientId },
751
+ { store_id: { $in: reqestData.storeId } },
752
+ { date_iso: { $gte: fromDate } },
753
+ { date_iso: { $lte: toDate } },
754
+ );
755
+
756
+ findQuery.push( { $match: { $and: findAndQuery } } );
757
+
758
+ findQuery.push( {
759
+ $project: {
760
+ userEmail: 1,
761
+ userName: 1,
762
+ },
763
+ } );
764
+
765
+ findQuery.push( {
766
+ $group: {
767
+ _id: '$userEmail',
768
+ userName: { $last: '$userName' },
769
+ userNameChar: { $last: { $substr: [ '$userName', 0, 2 ] } },
770
+ },
771
+ } );
772
+
773
+ findQuery.push( {
774
+ $project: {
775
+ _id: 0,
776
+ userEmail: '$_id',
777
+ userName: 1,
778
+ userNameChar: 1,
779
+ },
780
+ } );
781
+ findQuery.push( {
782
+ $lookup: {
783
+ from: 'users',
784
+ let: { userEmail: '$userEmail' },
785
+ pipeline: [
786
+ {
787
+ $match: {
788
+ $expr: {
789
+ $and: [
790
+ { $eq: [ '$email', '$$userEmail' ] },
791
+ ],
792
+ },
793
+ },
794
+ },
795
+ {
796
+ $project: {
797
+ email: 1,
798
+ userName: 1,
799
+ role: 1,
800
+ },
801
+ },
802
+ ], as: 'users',
803
+ },
804
+ } );
805
+ findQuery.push( { $unwind: { path: '$users', preserveNullAndEmptyArrays: true } } );
806
+ findQuery.push( {
807
+ $project: {
808
+ _id: 0,
809
+ userEmail: 1,
810
+ userName: 1,
811
+ userNameChar: 1,
812
+ role: '$users.role',
813
+ },
814
+ } );
815
+ let getTotalCount = await processedchecklistService.aggregate( findQuery );
816
+ if ( !getTotalCount.length ) {
817
+ return res.sendError( { error: 'No Data Found' }, 204 );
818
+ }
819
+ if ( reqestData.sortColumnName && reqestData.sortColumnName != '' && reqestData.sortBy && reqestData.sortBy !='' ) {
820
+ findQuery.push( { $sort: { [reqestData.sortColumnName]: reqestData.sortBy } } );
821
+ } else {
822
+ findQuery.push( { $sort: { ['userName']: -1 } } );
823
+ }
824
+ let getuserData = await processedchecklistService.aggregate( findQuery );
825
+ result.userData = getuserData;
826
+ return res.sendSuccess( result );
827
+ } catch ( error ) {
828
+ console.log( 'error =>', error );
829
+ logger.error( { error: error, message: req.query, function: 'userDropdown' } );
830
+ return res.sendError( { error: error }, 500 );
831
+ }
832
+ };
833
+
834
+ export const checklistInfo = async ( req, res ) => {
835
+ try {
836
+ let reqestData = req.body;
837
+ let fromDate = new Date( reqestData.fromDate );
838
+ let toDate = new Date( reqestData.toDate );
839
+ let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
840
+ toDate = new Date( toDate.getTime() - userTimezoneOffset );
841
+ toDate.setUTCHours( 23, 59, 59, 59 );
842
+ let result = {};
843
+
844
+ let findQuery = [];
845
+ let findAndQuery = [];
846
+ findAndQuery.push(
847
+ { client_id: reqestData.clientId },
848
+ { store_id: { $in: reqestData.storeId } },
849
+ { date_iso: { $gte: fromDate } },
850
+ { date_iso: { $lte: toDate } },
851
+ );
852
+
853
+ if ( reqestData.groupByType == 'checklist' ) {
854
+ findAndQuery.push( { sourceCheckList_id: new mongoose.Types.ObjectId( reqestData.groupByValue ) } );
855
+ }
856
+
857
+ if ( reqestData.groupByType == 'user' ) {
858
+ findAndQuery.push( { userEmail: reqestData.groupByValue } );
859
+ }
860
+
861
+ if ( reqestData.groupByType == 'store' ) {
862
+ findAndQuery.push( { store_id: reqestData.groupByValue } );
863
+ }
864
+
865
+ findQuery.push( { $match: { $and: findAndQuery } } );
866
+
867
+ if ( reqestData.searchValue && reqestData.searchValue != '' ) {
868
+ findQuery.push( { $match: { $or: [ { checkListName: { $regex: reqestData.searchValue, $options: 'i' } } ] } } );
869
+ }
870
+
871
+ findQuery.push( {
872
+ $project: {
873
+ checkListName: 1,
874
+ createdByName: 1,
875
+ userName: 1,
876
+ userEmail: 1,
877
+ checklistStatus: 1,
878
+ submitTime_string: 1,
879
+ date_string: 1,
880
+ storeName: 1,
881
+ checkListType: 1,
882
+ scheduleRepeatedType: 1,
883
+ flaggedChecklist: {
884
+ $sum: {
885
+ $cond: [ {
886
+ $or: [
887
+ { $gt: [ '$timeFlag', 0 ] },
888
+ { $gt: [ '$questionFlag', 0 ] },
889
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
890
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
891
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
892
+ ],
893
+ }, 1, 0 ],
894
+ },
895
+ },
896
+ date_iso: 1,
897
+ store_id: 1,
898
+ },
899
+ } );
900
+
901
+ let getTotalCount = await processedchecklistService.aggregate( findQuery );
902
+ if ( !getTotalCount.length ) {
903
+ return res.sendError( { error: 'No Data Found' }, 204 );
904
+ }
905
+
906
+ if ( reqestData.sortColumnName && reqestData.sortColumnName != '' && reqestData.sortBy && reqestData.sortBy !='' ) {
907
+ findQuery.push( { $sort: { [reqestData.sortColumnName]: reqestData.sortBy } } );
908
+ } else {
909
+ findQuery.push( { $sort: { ['date_iso']: -1 } } );
910
+ }
911
+
912
+ let limit = parseInt( reqestData?.limit ) || 10;
913
+ let skip = limit * ( reqestData?.offset ) || 0;
914
+ findQuery.push( { $skip: skip }, { $limit: limit } );
915
+ let getChecklistPerformanceData = await processedchecklistService.aggregate( findQuery );
916
+
917
+ result.totalCount = getTotalCount.length;
918
+ result.checklistInfo = getChecklistPerformanceData;
919
+ return res.sendSuccess( result );
920
+ } catch ( error ) {
921
+ console.log( 'error =>', error );
922
+ logger.error( { error: error, message: req.query, function: 'checklistInfo' } );
923
+ return res.sendError( { error: error }, 500 );
924
+ }
925
+ };
926
+
927
+ export const infoCards = async ( req, res ) => {
928
+ try {
929
+ let reqestData = req.body;
930
+ let fromDate = new Date( reqestData.fromDate );
931
+ let toDate = new Date( reqestData.toDate );
932
+ let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
933
+ toDate = new Date( toDate.getTime() - userTimezoneOffset );
934
+ toDate.setUTCHours( 23, 59, 59, 59 );
935
+ let activeUnique = 0;
936
+ let notSubmittedInstances = {
937
+ 'count': '',
938
+ 'open': '',
939
+ 'inprogress': '',
940
+ };
941
+ let totalInstances = {
942
+ 'count': '',
943
+ 'comparisonData': '',
944
+ 'ComparisonFlag': '',
945
+ };
946
+ let completedInstances = {
947
+ 'count': '',
948
+ 'comparisonData': '',
949
+ 'ComparisonFlag': '',
950
+ };
951
+ let flags = {
952
+ 'count': '',
953
+ 'comparisonData': '',
954
+ 'ComparisonFlag': '',
955
+ };
956
+ let completionScore = {
957
+ 'count': '',
958
+ 'comparisonData': '',
959
+ 'ComparisonFlag': '',
960
+ };
961
+ let complianceRate = {
962
+ 'count': '',
963
+ 'comparisonData': '',
964
+ 'ComparisonFlag': '',
965
+ };
966
+ let result = {};
967
+
968
+ let findQuery = [];
969
+ let findUniqueQuery = [];
970
+ let findAndQuery = [];
971
+ findAndQuery.push(
972
+ { client_id: reqestData.clientId },
973
+ { store_id: { $in: reqestData.storeId } },
974
+ { date_iso: { $gte: fromDate } },
975
+ { date_iso: { $lte: toDate } },
976
+ );
977
+
978
+ if ( reqestData.groupByType == 'checklist' ) {
979
+ findAndQuery.push( { sourceCheckList_id: new mongoose.Types.ObjectId( reqestData.groupByValue ) } );
980
+ }
981
+
982
+ if ( reqestData.groupByType == 'user' ) {
983
+ findAndQuery.push( { userEmail: reqestData.groupByValue } );
984
+ }
985
+
986
+ if ( reqestData.groupByType == 'store' ) {
987
+ findAndQuery.push( { store_id: reqestData.groupByValue } );
988
+ }
989
+
990
+ findQuery.push( { $match: { $and: findAndQuery } } );
991
+
992
+ findQuery.push( {
993
+ $project: {
994
+ sourceCheckList_id: 1,
995
+ checkListId: 1,
996
+ checklistStatus: 1,
997
+ timeFlag: 1,
998
+ questionFlag: 1,
999
+ mobileDetectionFlag: 1,
1000
+ storeOpenCloseFlag: 1,
1001
+ uniformDetectionFlag: 1,
1002
+ markasread: 1,
1003
+ checkListType: 1,
1004
+ },
1005
+ } );
1006
+
1007
+ findQuery.push( {
1008
+ $group: {
1009
+ _id: '',
1010
+ totalChecklist: { $sum: 1 },
1011
+ notSubmittedChecklist: {
1012
+ $sum: {
1013
+ $cond: [
1014
+ {
1015
+ $and: [
1016
+ { $ne: [ '$checklistStatus', 'submit' ] },
1017
+ ],
1018
+ }, 1, 0 ],
1019
+ },
1020
+ },
1021
+ openChecklist: {
1022
+ $sum: {
1023
+ $cond: [
1024
+ {
1025
+ $and: [
1026
+ { $eq: [ '$checklistStatus', 'open' ] },
1027
+ ],
1028
+ }, 1, 0 ],
1029
+ },
1030
+ },
1031
+ inprogressChecklist: {
1032
+ $sum: {
1033
+ $cond: [
1034
+ {
1035
+ $and: [
1036
+ { $eq: [ '$checklistStatus', 'inprogress' ] },
1037
+ ],
1038
+ }, 1, 0 ],
1039
+ },
1040
+ },
1041
+ submittedChecklist: {
1042
+ $sum: {
1043
+ $cond: [
1044
+ {
1045
+ $and: [
1046
+ { $eq: [ '$checklistStatus', 'submit' ] },
1047
+ ],
1048
+ }, 1, 0 ],
1049
+ },
1050
+ },
1051
+ flaggedChecklist: {
1052
+ $sum: {
1053
+ $cond: [ {
1054
+ $or: [
1055
+ { $gt: [ '$timeFlag', 0 ] },
1056
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
1057
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
1058
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
1059
+ ],
1060
+ }, 1, 0 ],
1061
+ },
1062
+ },
1063
+ },
1064
+ } );
1065
+ let getOverallChecklistData = await processedchecklistService.aggregate( findQuery );
1066
+
1067
+ findUniqueQuery.push( { $match: { $and: findAndQuery } } );
1068
+ findUniqueQuery.push( {
1069
+ $project: {
1070
+ sourceCheckList_id: 1,
1071
+ },
1072
+ } );
1073
+ findUniqueQuery.push( {
1074
+ $group: {
1075
+ _id: '$sourceCheckList_id',
1076
+ },
1077
+ } );
1078
+ findUniqueQuery.push( {
1079
+ $count: 'totalUniqueChecklist',
1080
+ } );
1081
+ let getUniqueChecklistData = await processedchecklistService.aggregate( findUniqueQuery );
1082
+ if ( !getUniqueChecklistData.length && !getOverallChecklistData.length ) {
1083
+ return res.sendError( { error: 'No Data Found' }, 204 );
1084
+ }
1085
+
1086
+ if ( getUniqueChecklistData.length && getUniqueChecklistData.length>0 ) {
1087
+ if ( getUniqueChecklistData[0].totalUniqueChecklist ) {
1088
+ activeUnique = getUniqueChecklistData[0]?.totalUniqueChecklist;
1089
+ }
1090
+ }
1091
+
1092
+ if ( getOverallChecklistData.length && getOverallChecklistData.length>0 ) {
1093
+ if ( getOverallChecklistData[0].totalChecklist ) {
1094
+ totalInstances.count = getOverallChecklistData[0]?.totalChecklist;
1095
+ }
1096
+ if ( getOverallChecklistData[0].notSubmittedChecklist ) {
1097
+ notSubmittedInstances.count = getOverallChecklistData[0]?.notSubmittedChecklist;
1098
+ }
1099
+ if ( getOverallChecklistData[0].openChecklist ) {
1100
+ notSubmittedInstances.open = getOverallChecklistData[0]?.openChecklist;
1101
+ }
1102
+ if ( getOverallChecklistData[0].inprogressChecklist ) {
1103
+ notSubmittedInstances.inprogress = getOverallChecklistData[0]?.inprogressChecklist;
1104
+ }
1105
+ if ( getOverallChecklistData[0].submittedChecklist ) {
1106
+ completedInstances.count = getOverallChecklistData[0]?.submittedChecklist;
1107
+ }
1108
+ if ( getOverallChecklistData[0].flaggedChecklist ) {
1109
+ flags.count = getOverallChecklistData[0]?.flaggedChecklist;
1110
+ }
1111
+ }
1112
+ result.infoCards = {
1113
+ 'activeUnique': activeUnique,
1114
+ 'totalInstances': totalInstances,
1115
+ 'notSubmittedInstances': notSubmittedInstances,
1116
+ 'completedInstances': completedInstances,
1117
+ 'flags': flags,
1118
+ 'completionScore': completionScore,
1119
+ 'complianceRate': complianceRate,
1120
+ };
1121
+ return res.sendSuccess( result );
1122
+ } catch ( error ) {
1123
+ logger.error( { error: error, message: req.query, function: 'infoCards' } );
1124
+ return res.sendError( { error: error }, 500 );
1125
+ }
1126
+ };
1127
+
1128
+ export const monthlyGraph = async ( req, res ) => {
1129
+ try {
1130
+ let reqestData = req.body;
1131
+ let fromDate = new Date( reqestData.fromDate );
1132
+ let toDate = new Date( reqestData.toDate );
1133
+ let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
1134
+ toDate = new Date( toDate.getTime() - userTimezoneOffset );
1135
+ toDate.setUTCHours( 23, 59, 59, 59 );
1136
+ let result = {};
1137
+
1138
+ let findQuery = [];
1139
+ let findAndQuery = [];
1140
+ findAndQuery.push(
1141
+ { client_id: reqestData.clientId },
1142
+ { store_id: { $in: reqestData.storeId } },
1143
+ { date_iso: { $gte: fromDate } },
1144
+ { date_iso: { $lte: toDate } },
1145
+ );
1146
+
1147
+ if ( reqestData.groupByType == 'checklist' ) {
1148
+ findAndQuery.push( { sourceCheckList_id: new mongoose.Types.ObjectId( reqestData.groupByValue ) } );
1149
+ }
1150
+
1151
+ if ( reqestData.groupByType == 'user' ) {
1152
+ findAndQuery.push( { userEmail: reqestData.groupByValue } );
1153
+ }
1154
+
1155
+ if ( reqestData.groupByType == 'store' ) {
1156
+ findAndQuery.push( { store_id: reqestData.groupByValue } );
1157
+ }
1158
+
1159
+ findQuery.push( { $match: { $and: findAndQuery } } );
1160
+
1161
+ findQuery.push( {
1162
+ $project: {
1163
+ sourceCheckList_id: 1,
1164
+ checkListId: 1,
1165
+ checkListName: 1,
1166
+ storeCount: 1,
1167
+ createdBy: 1,
1168
+ createdByName: 1,
1169
+ checklistStatus: 1,
1170
+ timeFlag: 1,
1171
+ questionFlag: 1,
1172
+ mobileDetectionFlag: 1,
1173
+ storeOpenCloseFlag: 1,
1174
+ uniformDetectionFlag: 1,
1175
+ checkListType: 1,
1176
+ scheduleRepeatedType: 1,
1177
+ date_string: 1,
1178
+ date_iso: 1,
1179
+ },
1180
+ } );
1181
+
1182
+ findQuery.push( {
1183
+ $group: {
1184
+ _id: '$date_string',
1185
+ date_iso: { $last: '$date_iso' },
1186
+ storeCount: { $max: '$storeCount' },
1187
+ submittedChecklist: {
1188
+ $sum: {
1189
+ $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, 1, 0 ],
1190
+ },
1191
+ },
1192
+ flaggedChecklist: {
1193
+ $sum: {
1194
+ $cond: [ {
1195
+ $or: [
1196
+ { $gt: [ '$timeFlag', 0 ] },
1197
+ { $gt: [ '$questionFlag', 0 ] },
1198
+ { $gt: [ '$mobileDetectionFlag', 0 ] },
1199
+ { $gt: [ '$storeOpenCloseFlag', 0 ] },
1200
+ { $gt: [ '$uniformDetectionFlag', 0 ] },
1201
+ ],
1202
+ }, 1, 0 ],
1203
+ },
1204
+ },
1205
+ checkListType: { $last: '$checkListType' },
1206
+ },
1207
+ } );
1208
+
1209
+ let getTotalCount = await processedchecklistService.aggregate( findQuery );
1210
+ if ( !getTotalCount.length ) {
1211
+ return res.sendError( { error: 'No Data Found' }, 204 );
1212
+ }
1213
+
1214
+ if ( reqestData.sortColumnName && reqestData.sortColumnName != '' && reqestData.sortBy && reqestData.sortBy !='' ) {
1215
+ findQuery.push( { $sort: { [reqestData.sortColumnName]: reqestData.sortBy } } );
1216
+ } else {
1217
+ findQuery.push( { $sort: { ['date_iso']: 1 } } );
1218
+ }
1219
+ let getmonthlyData = await processedchecklistService.aggregate( findQuery );
1220
+
1221
+ result.monthlyData = getmonthlyData;
1222
+ return res.sendSuccess( result );
1223
+ } catch ( error ) {
1224
+ console.log( 'error =>', error );
1225
+ logger.error( { error: error, message: req.query, function: 'checklistPerformance' } );
400
1226
  return res.sendError( { error: error }, 500 );
401
1227
  }
402
1228
  };
@@ -9,6 +9,13 @@ import {
9
9
  overallCards,
10
10
  checklistPerformance,
11
11
  storePerformance,
12
+ userPerformance,
13
+ checklistDropdown,
14
+ storeDropdown,
15
+ userDropdown,
16
+ checklistInfo,
17
+ infoCards,
18
+ monthlyGraph,
12
19
  } from '../controllers/traxDashboard.controllers.js';
13
20
 
14
21
  traxDashboardRouter
@@ -16,6 +23,12 @@ traxDashboardRouter
16
23
  .post( '/overallCards', overallCards )
17
24
  .post( '/checklistPerformance', checklistPerformance )
18
25
  .post( '/storePerformance', storePerformance )
19
- .post( '/userPerformance', overallCards );
26
+ .post( '/userPerformance', userPerformance )
27
+ .post( '/checklistInfo', checklistInfo )
28
+ .post( '/infoCards', infoCards )
29
+ .post( '/monthlyGraph', monthlyGraph )
30
+ .post( '/checklistDropdown', checklistDropdown )
31
+ .post( '/storelistDropdown', storeDropdown )
32
+ .post( '/userlistDropdown', userDropdown );
20
33
 
21
34
  export default traxDashboardRouter;