tango-app-api-trax 3.5.1-alpha-2 → 3.5.2-alpha-1

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": "3.5.1-alpha-2",
3
+ "version": "3.5.2-alpha-1",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "mongodb": "^6.8.0",
27
27
  "nodemon": "^3.1.4",
28
28
  "path": "^0.12.7",
29
- "tango-api-schema": "^2.2.101",
30
- "tango-app-api-middleware": "^3.1.72",
29
+ "tango-api-schema": "^2.2.120",
30
+ "tango-app-api-middleware": "^3.1.77",
31
31
  "url": "^0.11.4",
32
32
  "winston": "^3.13.1",
33
33
  "winston-daily-rotate-file": "^5.0.0"
@@ -1068,6 +1068,13 @@ export async function userList( req, res ) {
1068
1068
  },
1069
1069
  }, clientId: req.body.clientId } );
1070
1070
  req.body.teams = findTeams.map( ( data ) => data.teamName );
1071
+ if ( req.body.teams.length===0 ) {
1072
+ query.push( {
1073
+ $match: {
1074
+ userEmail: { $in: [ req.user.email ] },
1075
+ },
1076
+ } );
1077
+ }
1071
1078
  }
1072
1079
 
1073
1080
  if ( req.body.teams && req.body.teams.length > 0 ) {
@@ -286,6 +286,7 @@ export async function PCLconfigCreation( req, res ) {
286
286
  insertdata.scheduleRepeatedType = getCLconfig.scheduleRepeatedType;
287
287
  insertdata.allowedMultiSubmit = getCLconfig.allowedMultiSubmit;
288
288
  insertdata.rawImageUpload = getCLconfig.rawImageUpload || false;
289
+ insertdata.rawVideoUpload = getCLconfig.rawVideoUpload || false;
289
290
  let collectSections = [];
290
291
  let sectionQuery = [];
291
292
  sectionQuery.push( {
@@ -295,7 +296,7 @@ export async function PCLconfigCreation( req, res ) {
295
296
  },
296
297
  } );
297
298
  let getSections = await CLquestions.aggregate( sectionQuery );
298
- if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection' ].includes( getCLconfig.checkListType ) ) {
299
+ if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo' ].includes( getCLconfig.checkListType ) ) {
299
300
  if ( getSections.length ) {
300
301
  for ( let element3 of getSections ) {
301
302
  let collectQuestions = {};
@@ -562,6 +563,7 @@ export async function PCLconfigCreation( req, res ) {
562
563
  // element4.isPlano = getCLconfig?.isPlano;
563
564
  // }
564
565
  element4.rawImageUpload = getCLconfig?.rawImageUpload || false;
566
+ element4.rawVideoUpload = getCLconfig?.rawVideoUpload || false;
565
567
  }
566
568
  if ( userIdList.length ) {
567
569
  allQuestion = allQuestion.filter( ( item ) => typeof item._id == 'undefined' );
@@ -589,11 +591,11 @@ export async function PCLconfigCreation( req, res ) {
589
591
  // }
590
592
  }
591
593
  } else {
592
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection' ].includes( getCLconfig.checkListType ) ) {
594
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo' ].includes( getCLconfig.checkListType ) ) {
593
595
  let storeNameList = allQuestion.map( ( item ) => item.store_id );
594
- let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'cleaning', 'scrum' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
596
+ let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
595
597
  let storeList = storeDetails.map( ( store ) => store.storeId );
596
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'cleaning', 'scrum' ].includes( getCLconfig.checkListType ) ) {
598
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning' ].includes( getCLconfig.checkListType ) ) {
597
599
  allQuestion = allQuestion.filter( ( ele ) => storeList.includes( ele?.store_id ) );
598
600
  } else {
599
601
  allQuestion = storeDetails.map( ( item ) => {
@@ -627,7 +629,7 @@ export async function PCLconfigCreation( req, res ) {
627
629
  client_id: getCLconfig.client_id,
628
630
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => store.store_id ) : [],
629
631
  };
630
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'cleaning', 'scrum' ].includes( getCLconfig.checkListType ) ) {
632
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning' ].includes( getCLconfig.checkListType ) ) {
631
633
  let processData = {
632
634
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => {
633
635
  return { storeName: store.storeName, storeId: store.store_id, events: store.events };
@@ -852,6 +854,7 @@ async function insertData( requestData ) {
852
854
  insertdata.scheduleRepeatedType = getCLconfig.scheduleRepeatedType;
853
855
  insertdata.allowedMultiSubmit = getCLconfig.allowedMultiSubmit;
854
856
  insertdata.rawImageUpload = getCLconfig.rawImageUpload || false;
857
+ insertdata.rawVideoUpload = getCLconfig.rawVideoUpload || false;
855
858
  let collectSections = [];
856
859
  let sectionQuery = [];
857
860
  sectionQuery.push( {
@@ -861,7 +864,7 @@ async function insertData( requestData ) {
861
864
  },
862
865
  } );
863
866
  let getSections = await CLquestions.aggregate( sectionQuery );
864
- if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection' ].includes( getCLconfig.checkListType ) ) {
867
+ if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo' ].includes( getCLconfig.checkListType ) ) {
865
868
  if ( getSections.length ) {
866
869
  for ( let element3 of getSections ) {
867
870
  let collectQuestions = {};
@@ -1128,6 +1131,7 @@ async function insertData( requestData ) {
1128
1131
  // element4.isPlano = getCLconfig?.isPlano;
1129
1132
  // }
1130
1133
  element4.rawImageUpload = getCLconfig?.rawImageUpload || false;
1134
+ element4.rawVideoUpload = getCLconfig?.rawVideoUpload || false;
1131
1135
  }
1132
1136
  if ( userIdList.length ) {
1133
1137
  allQuestion = allQuestion.filter( ( item ) => typeof item._id == 'undefined' );
@@ -1154,11 +1158,11 @@ async function insertData( requestData ) {
1154
1158
  // }
1155
1159
  }
1156
1160
  } else {
1157
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection' ].includes( getCLconfig.checkListType ) ) {
1161
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo' ].includes( getCLconfig.checkListType ) ) {
1158
1162
  let storeNameList = allQuestion.map( ( item ) => item.store_id );
1159
- let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'cleaning', 'scrum' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
1163
+ let storeDetails = await storeService.find( { clientId: getCLconfig.client_id, status: 'active', ...( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning' ].includes( getCLconfig.checkListType ) ) ? { storeId: { $in: storeNameList } } : {} }, { storeId: 1 } );
1160
1164
  let storeList = storeDetails.map( ( store ) => store.storeId );
1161
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'cleaning', 'scrum' ].includes( getCLconfig.checkListType ) ) {
1165
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning' ].includes( getCLconfig.checkListType ) ) {
1162
1166
  allQuestion = allQuestion.filter( ( ele ) => storeList.includes( ele?.store_id ) );
1163
1167
  } else {
1164
1168
  allQuestion = storeDetails.map( ( item ) => {
@@ -1192,7 +1196,7 @@ async function insertData( requestData ) {
1192
1196
  client_id: getCLconfig.client_id,
1193
1197
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => store.store_id ) : [],
1194
1198
  };
1195
- if ( [ 'storeopenandclose', 'mobileusagedetection', 'cleaning', 'scrum' ].includes( getCLconfig.checkListType ) ) {
1199
+ if ( [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'scrum', 'cleaning' ].includes( getCLconfig.checkListType ) ) {
1196
1200
  let processData = {
1197
1201
  aiStoreList: allQuestion.length ? allQuestion.map( ( store ) => {
1198
1202
  return { storeName: store.storeName, storeId: store.store_id, events: store.events };
@@ -2309,3 +2313,35 @@ export async function internalAISendPushNotification( req, res ) {
2309
2313
  else res.sendError( e, 500 );
2310
2314
  }
2311
2315
  };
2316
+
2317
+ export async function getLiveChecklistClients( req, res ) {
2318
+ try {
2319
+ let inputData = req.body;
2320
+ let query = [
2321
+ {
2322
+ $match: {
2323
+ isdeleted: false,
2324
+ publish: true,
2325
+ client_id: {
2326
+ $nin: inputData.ignoreClientId,
2327
+ $exists: true,
2328
+ $ne: null,
2329
+ },
2330
+ },
2331
+ },
2332
+ { $group: { _id: '$client_id' } },
2333
+ { $sort: { _id: 1 } },
2334
+ { $group: { _id: null, client_ids: { $push: '$_id' } } },
2335
+ ];
2336
+
2337
+ let getchecklistsData = await CLconfig.aggregate( query );
2338
+ if ( getchecklistsData && getchecklistsData.length >0 ) {
2339
+ return res.sendSuccess( { liveChecklistClients: getchecklistsData[0].client_ids } );
2340
+ } else {
2341
+ return res.sendError( 'Checklist Not Available', 204 );
2342
+ }
2343
+ } catch ( error ) {
2344
+ if ( error.name === 'ValidationError' ) res.sendBadRequest( error );
2345
+ else res.sendError( error, 500 );
2346
+ }
2347
+ }
@@ -591,47 +591,47 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
591
591
  return res.sendError( 'Please Fill all Required Fields', 400 );
592
592
  }
593
593
 
594
- // if ( requestData.submittype == 'submit' ) {
595
- let reqAnswers = requestData.questionAnswers;
596
- logger.error( { functionName: 'payload', message: reqAnswers } );
597
- let CLQAnswers = getChecklistQA.questionAnswers;
598
- logger.error( { functionName: 'CLQAnswers', message: CLQAnswers } );
599
- let validationCount= 0;
600
- let errorCount = 0;
601
- CLQAnswers.forEach( ( section ) => {
602
- let requestSection = reqAnswers.filter( ( reqSection ) => reqSection.sectionName == section?.sectionOldName || reqSection.sectionName == section?.sectionName );
603
- if ( requestSection.length ) {
604
- requestSection.forEach( ( item ) => item.section_id = section.section_id );
605
- section.questions.forEach( ( question ) => {
606
- // question.answers.forEach( ( answer ) => {
607
- let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
608
- if ( sectionQuestion.length ) {
609
- if ( question.answerType == 'multiplechoicemultiple' && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
610
- validationCount++;
611
- } else {
612
- if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
594
+ if ( requestData.submittype == 'submit' ) {
595
+ let reqAnswers = requestData.questionAnswers;
596
+ logger.error( { functionName: 'payload', message: reqAnswers } );
597
+ let CLQAnswers = getChecklistQA.questionAnswers;
598
+ logger.error( { functionName: 'CLQAnswers', message: CLQAnswers } );
599
+ let validationCount= 0;
600
+ let errorCount = 0;
601
+ CLQAnswers.forEach( ( section ) => {
602
+ let requestSection = reqAnswers.filter( ( reqSection ) => reqSection.sectionName == section?.sectionOldName || reqSection.sectionName == section?.sectionName );
603
+ if ( requestSection.length ) {
604
+ requestSection.forEach( ( item ) => item.section_id = section.section_id );
605
+ section.questions.forEach( ( question ) => {
606
+ // question.answers.forEach( ( answer ) => {
607
+ let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
608
+ if ( sectionQuestion.length ) {
609
+ if ( question.answerType == 'multiplechoicemultiple' && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
613
610
  validationCount++;
611
+ } else {
612
+ if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
613
+ validationCount++;
614
+ }
614
615
  }
616
+ } else {
617
+ errorCount++;
615
618
  }
616
- } else {
617
- errorCount++;
618
- }
619
- // } );
620
- } );
619
+ // } );
620
+ } );
621
+ } else {
622
+ errorCount++;
623
+ }
624
+ } );
625
+ if ( validationCount ) {
626
+ return res.sendError( 'Please Fill all Required Fields', 400 );
627
+ } else if ( errorCount ) {
628
+ return res.sendError( 'Checklist got edited.please contact admin', 400 );
621
629
  } else {
622
- errorCount++;
630
+ next();
623
631
  }
624
- } );
625
- if ( validationCount && requestData.submittype == 'submit' ) {
626
- return res.sendError( 'Please Fill all Required Fields', 400 );
627
- } else if ( errorCount ) {
628
- return res.sendError( 'Checklist got edited.please contact admin', 400 );
629
632
  } else {
630
633
  next();
631
634
  }
632
- // } else {
633
- // next();
634
- // }
635
635
  } catch ( e ) {
636
636
  logger.error( { function: 'sopMobilechecklistQuestionValidator', error: e, body: req.body } );
637
637
  return res.sendError( e, 500 );
@@ -2132,7 +2132,7 @@ export async function submiteyeTestTask( req, res ) {
2132
2132
  return res.sendError( 'Qr code already Exists', 400 );
2133
2133
  }
2134
2134
 
2135
- await cameraService.updateOne( { streamName: streamId }, { qrCode: qrCode } );
2135
+ await cameraService.updateOne( { streamName: streamId }, { qrCode: qrCode, isEyeTestStream: true } );
2136
2136
  return res.sendSuccess( 'Qr code added successfully' );
2137
2137
 
2138
2138
  const findQuery = [
@@ -2753,8 +2753,8 @@ export async function checklistv1( req, res ) {
2753
2753
  };
2754
2754
 
2755
2755
  const [ checklistResult, taskResult ] = await Promise.allSettled( [
2756
- processedchecklist.aggregate( buildPipeline( [ { checkListType: 'custom' } ], { isPlano: 1, planoId: 1, planoType: 1 } ) ),
2757
- processedTask.aggregate( buildPipeline( [], { isPlano: 1, planoId: 1, planoType: 1 } ) ),
2756
+ processedchecklist.aggregate( buildPipeline( [ { checkListType: 'custom' } ], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1 } ) ),
2757
+ processedTask.aggregate( buildPipeline( [], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1 } ) ),
2758
2758
  ] );
2759
2759
 
2760
2760
  const checklistData = checklistResult.status === 'fulfilled' ? checklistResult.value : [];
@@ -3682,8 +3682,7 @@ export async function clientConfig( req, res ) {
3682
3682
  try {
3683
3683
  let requestData = req.body;
3684
3684
  if ( requestData.clientId && requestData.clientId !='' ) {
3685
- let getClientData = await clientService.findOne( { clientId: requestData.clientId }, { traxRAWImageUpload: 1, clientId: 1, clientName: 1, traxBlockMobileTimeUpdate: 1, traxSectionSave: 1 } );
3686
- // console.log( ' getClientData=>', getClientData );
3685
+ let getClientData = await clientService.findOne( { clientId: requestData.clientId }, { traxRAWImageUpload: 1, clientId: 1, clientName: 1, traxBlockMobileTimeUpdate: 1, traxSectionSave: 1, isCrestPlanogram: 1, isTangoPlanogram: 1 } );
3687
3686
  if ( getClientData ) {
3688
3687
  return res.sendSuccess( getClientData );
3689
3688
  } else {
@@ -1,9 +1,10 @@
1
- import { download, logger } from 'tango-app-api-middleware'; // getChecklistUsers
1
+ import { download, logger, convertSecondstoTimeFormat } from 'tango-app-api-middleware'; // getChecklistUsers
2
2
  import { aggregate } from '../services/processedchecklist.services.js';
3
3
  import dayjs from 'dayjs';
4
4
  import * as processedchecklistService from '../services/processedchecklist.services.js';
5
5
  import * as processedchecklistconfigService from '../services/processedchecklistconfig.services.js';
6
6
  import * as checklistconfigService from '../services/checklist.service.js';
7
+ import * as clientService from '../services/clients.services.js';
7
8
 
8
9
 
9
10
  import utc from 'dayjs/plugin/utc.js';
@@ -653,14 +654,14 @@ export const flagComparisonCardsV1 = async ( req, res ) => {
653
654
  rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
654
655
  } else if ( requestData.dateType == 'monthly' ) {
655
656
  rangeOneFromDate = new Date( requestData.toDate );
656
- rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 30 );
657
+ rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 29 );
657
658
  rangeOneToDate = new Date( requestData.toDate );
658
659
  rangeOneToDate = new Date( rangeOneToDate.getTime() - userTimezoneOffset );
659
660
  rangeOneToDate.setUTCHours( 23, 59, 59, 59 );
660
661
  rangeTwoToDate = new Date( requestData.toDate );
661
- rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 31 );
662
+ rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 30 );
662
663
  rangeTwoFromDate = new Date( rangeTwoToDate );
663
- rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 30 );
664
+ rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 29 );
664
665
  rangeTwoToDate = new Date( rangeTwoToDate.getTime() - userTimezoneOffset );
665
666
  rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
666
667
  } else {
@@ -2011,6 +2012,10 @@ export const flagChecklistCardsV1 = async ( req, res ) => {
2011
2012
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
2012
2013
  if ( resultData ) {
2013
2014
  if ( resultData.status_code == '200' ) {
2015
+ if ( resultData.customerunattendedCards && resultData.customerunattendedCards.timeTakentoAssistsec && resultData.customerunattendedCards.timeTakentoAssistsec.secs ) {
2016
+ resultData.customerunattendedCards.timeTakentoAssist_string = await convertSecondstoTimeFormat( resultData.customerunattendedCards.timeTakentoAssistsec.secs );
2017
+ resultData.customerunattendedCards.timeSpentwithCustomer_string = await convertSecondstoTimeFormat( resultData.customerunattendedCards.timeSpentwithCustomersec.secs );
2018
+ }
2014
2019
  return res.sendSuccess( resultData );
2015
2020
  } else {
2016
2021
  return res.sendError( 'No Content', 204 );
@@ -2053,14 +2058,14 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
2053
2058
  rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
2054
2059
  } else if ( requestData.dateType == 'monthly' ) {
2055
2060
  rangeOneFromDate = new Date( requestData.toDate );
2056
- rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 30 );
2061
+ rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 29 );
2057
2062
  rangeOneToDate = new Date( requestData.toDate );
2058
2063
  rangeOneToDate = new Date( rangeOneToDate.getTime() - userTimezoneOffset );
2059
2064
  rangeOneToDate.setUTCHours( 23, 59, 59, 59 );
2060
2065
  rangeTwoToDate = new Date( requestData.toDate );
2061
- rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 31 );
2066
+ rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 30 );
2062
2067
  rangeTwoFromDate = new Date( rangeTwoToDate );
2063
- rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 30 );
2068
+ rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 29 );
2064
2069
  rangeTwoToDate = new Date( rangeTwoToDate.getTime() - userTimezoneOffset );
2065
2070
  rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
2066
2071
  } else {
@@ -2092,6 +2097,12 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
2092
2097
  },
2093
2098
  };
2094
2099
 
2100
+ let traxMonthlyComparison = false;
2101
+ let traxMonthlyComparisonData = await clientService.findOne( { clientId: requestData.clientId }, { traxMonthlyComparison: 1 } );
2102
+ if ( traxMonthlyComparisonData && traxMonthlyComparisonData.traxMonthlyComparison ) {
2103
+ traxMonthlyComparison = traxMonthlyComparisonData.traxMonthlyComparison;
2104
+ }
2105
+
2095
2106
  // Get User Based Checklist //
2096
2107
  // let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
2097
2108
  // let getUserEmails = await getChecklistUsers( loginUser );
@@ -2291,6 +2302,7 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
2291
2302
 
2292
2303
  let result = {
2293
2304
  'customCards': flagComparisonCards,
2305
+ 'traxMonthlyComparison': traxMonthlyComparison,
2294
2306
  };
2295
2307
 
2296
2308
  return res.sendSuccess( result );
@@ -2320,7 +2332,6 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
2320
2332
  ];
2321
2333
  const from = await aggregate( fromPipeline );
2322
2334
  requestData.range1StoreCount = from[0]?.storeCount | 0;
2323
-
2324
2335
  const toPipeline = [
2325
2336
  {
2326
2337
  $match:
@@ -2353,6 +2364,7 @@ export const flagChecklistComparisonCardsV1 = async ( req, res ) => {
2353
2364
  // console.log( 'resultData =>', resultData );
2354
2365
  if ( resultData ) {
2355
2366
  if ( resultData.status_code == '200' ) {
2367
+ resultData.traxMonthlyComparison = traxMonthlyComparison;
2356
2368
  return res.sendSuccess( resultData );
2357
2369
  } else {
2358
2370
  return res.sendError( 'No Content', 204 );
@@ -2785,14 +2797,14 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
2785
2797
  rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
2786
2798
  } else if ( requestData.dateType == 'monthly' ) {
2787
2799
  rangeOneFromDate = new Date( requestData.toDate );
2788
- rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 30 );
2800
+ rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 29 );
2789
2801
  rangeOneToDate = new Date( requestData.toDate );
2790
2802
  rangeOneToDate = new Date( rangeOneToDate.getTime() - userTimezoneOffset );
2791
2803
  rangeOneToDate.setUTCHours( 23, 59, 59, 59 );
2792
2804
  rangeTwoToDate = new Date( requestData.toDate );
2793
- rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 31 );
2805
+ rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 30 );
2794
2806
  rangeTwoFromDate = new Date( rangeTwoToDate );
2795
- rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 30 );
2807
+ rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 29 );
2796
2808
  rangeTwoToDate = new Date( rangeTwoToDate.getTime() - userTimezoneOffset );
2797
2809
  rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
2798
2810
  } else {
@@ -2885,6 +2897,14 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
2885
2897
  getDetectionCount( rangeTwoFromDate, rangeTwoToDate ),
2886
2898
  ] );
2887
2899
 
2900
+ // console.log( 'rangeOneFromDate =>', rangeOneFromDate );
2901
+ // console.log( 'rangeOneToDate =>', rangeOneToDate );
2902
+ // console.log( 'rangeOneData =>', rangeOneData );
2903
+
2904
+ // console.log( 'rangeTwoFromDate =>', rangeTwoFromDate );
2905
+ // console.log( 'rangeTwoToDate =>', rangeTwoToDate );
2906
+ // console.log( 'rangeTwoData =>', rangeTwoData );
2907
+
2888
2908
  const flagComparisonCards = {
2889
2909
  totalComparisonFlag: { comparisonData: 0, ComparisonFlag: false },
2890
2910
  questionComparisonFlag: { comparisonData: 0, ComparisonFlag: false },
@@ -2900,7 +2920,11 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
2900
2920
  flagComparisonCards.delayInSubmissionComparisonFlag = calculateComparison( rangeOneData[0].delayInSubmission, rangeTwoData[0].delayInSubmission );
2901
2921
  flagComparisonCards.detectionComparisonFlag = calculateComparison( rangeOneDetectionCount, rangeTwoDetectionCount );
2902
2922
  }
2903
-
2923
+ flagComparisonCards.traxMonthlyComparison = false;
2924
+ let traxMonthlyComparisonData = await clientService.findOne( { clientId: requestData.clientId }, { traxMonthlyComparison: 1 } );
2925
+ if ( traxMonthlyComparisonData && traxMonthlyComparisonData.traxMonthlyComparison ) {
2926
+ flagComparisonCards.traxMonthlyComparison = traxMonthlyComparisonData.traxMonthlyComparison;
2927
+ }
2904
2928
  return res.sendSuccess( { flagComparisonCards } );
2905
2929
  } catch ( error ) {
2906
2930
  console.log( 'error =>', error );
@@ -3706,7 +3706,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3706
3706
  await processedchecklist.deleteMany( { date_string: insertdata.date_string,
3707
3707
  date_iso: insertdata.date_iso,
3708
3708
  client_id: insertdata.client_id,
3709
- checkListId: updatedchecklist._id, checklistStatus: 'open', redoStatus: false } );
3709
+ checkListId: updatedchecklist._id, checklistStatus: 'open' } );
3710
3710
 
3711
3711
 
3712
3712
  let actionType = 'deleteOpenUsers';
@@ -3720,18 +3720,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3720
3720
  date_iso: insertdata.date_iso,
3721
3721
  client_id: insertdata.client_id,
3722
3722
  checkListId: updatedchecklist._id,
3723
- // checklistStatus: 'inprogress',
3724
- $or: [
3725
- {
3726
- $and: [
3727
- { checklistStatus: 'open' },
3728
- { redoStatus: true },
3729
- ],
3730
- },
3731
- {
3732
- checklistStatus: 'inprogress',
3733
- },
3734
- ],
3723
+ checklistStatus: 'inprogress',
3735
3724
  }, { userId: 1, store_id: 1 } );
3736
3725
 
3737
3726
  if ( inprogressData.length ) {
@@ -3750,7 +3739,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3750
3739
  }
3751
3740
 
3752
3741
  if ( deletedList.length ) {
3753
- await processedchecklist.deleteMany( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, _id: { $in: deletedList }, redoStatus: false } );
3742
+ await processedchecklist.deleteMany( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, _id: { $in: deletedList } } );
3754
3743
  }
3755
3744
  await processedchecklist.insertMany( assignUserList );
3756
3745
  actionType = 'insertAssignUsers';
@@ -3832,7 +3821,7 @@ async function updateOpenSearch( user, data ) {
3832
3821
  export const aiChecklist = async ( req, res ) => {
3833
3822
  try {
3834
3823
  let storeDetails = await storeService.count( { clientId: req.query.clientId, status: 'active' } );
3835
- let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection' ];
3824
+ let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo' ];
3836
3825
  let checklistDetails = [];
3837
3826
  let publishList = [];
3838
3827
  let unpublishList = [];
@@ -9,7 +9,7 @@ import utc from 'dayjs/plugin/utc.js';
9
9
  dayjs.extend( utc );
10
10
  // import admin from 'firebase-admin';
11
11
  import { sendPushNotification } from 'tango-app-api-middleware';
12
-
12
+ import * as clientService from '../services/clients.services.js';
13
13
 
14
14
  export const welcome = async ( req, res ) => {
15
15
  try {
@@ -1165,7 +1165,7 @@ export const userDropdown = async ( req, res ) => {
1165
1165
  }
1166
1166
  };
1167
1167
 
1168
- export const checklistInfo = async ( req, res ) => {
1168
+ export const checklistInfoOld = async ( req, res ) => {
1169
1169
  try {
1170
1170
  let requestData = req.body;
1171
1171
  let fromDate = new Date( requestData.fromDate );
@@ -1445,6 +1445,297 @@ export const checklistInfo = async ( req, res ) => {
1445
1445
  }
1446
1446
  };
1447
1447
 
1448
+ export const checklistInfo = async ( req, res ) => {
1449
+ try {
1450
+ let requestData = req.body;
1451
+ let fromDate = new Date( requestData.fromDate );
1452
+ let toDate = new Date( requestData.toDate );
1453
+ let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
1454
+ toDate = new Date( toDate.getTime() - userTimezoneOffset );
1455
+ toDate.setUTCHours( 23, 59, 59, 59 );
1456
+ let result = {};
1457
+
1458
+ // Get User Based Checklist //
1459
+ // let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
1460
+ // let getUserEmails = await getChecklistUsers( loginUser );
1461
+ // End: Get User Based Checklist////
1462
+
1463
+ let findQuery = [];
1464
+ let findAndQuery = [];
1465
+ findAndQuery.push(
1466
+ { client_id: requestData.clientId },
1467
+ { date_iso: { $gte: fromDate } },
1468
+ { date_iso: { $lte: toDate } },
1469
+ { checkListType: { $eq: 'custom' } },
1470
+ // { store_id: { $in: requestData.storeId } },
1471
+ { $or: [ { store_id: { $in: requestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: requestData.userEmailes } } ] },
1472
+ );
1473
+
1474
+ if ( requestData.checklistStatus && requestData.checklistStatus != 'All' ) {
1475
+ if ( requestData.checklistStatus == 'redo' ) {
1476
+ findAndQuery.push( { redoStatus: true } );
1477
+ } else {
1478
+ findAndQuery.push( { checklistStatus: requestData.checklistStatus } );
1479
+ }
1480
+ }
1481
+
1482
+ if ( requestData.groupByType == 'Checklist' ) {
1483
+ findAndQuery.push( { sourceCheckList_id: new mongoose.Types.ObjectId( requestData.groupByValue ) } );
1484
+ }
1485
+
1486
+ if ( requestData.groupByType == 'User' ) {
1487
+ findAndQuery.push( { userEmail: requestData.groupByValue } );
1488
+ }
1489
+
1490
+ if ( requestData.groupByType == 'Store' ) {
1491
+ findAndQuery.push( { store_id: requestData.groupByValue } );
1492
+ }
1493
+
1494
+ findQuery.push( { $match: { $and: findAndQuery } } );
1495
+
1496
+ if ( requestData.searchValue && requestData.searchValue != '' ) {
1497
+ if ( requestData.groupByType == 'Checklist' ) {
1498
+ // findQuery.push( { $match: { $or: [ { storeName: { $regex: requestData.searchValue, $options: 'i' } } ] } } );
1499
+ let storeList = requestData.searchValue.split( ',' ).map( ( item ) => item.trim().toLowerCase() );
1500
+ let query;
1501
+ if ( storeList.length > 1 ) {
1502
+ findQuery.push( { $addFields: { store: { $toLower: '$storeName' } } } );
1503
+ query = { store: { $in: storeList } };
1504
+ } else {
1505
+ query = { $or: [
1506
+ { storeName: { $regex: requestData.searchValue.trim(), $options: 'i' } },
1507
+ { userEmail: { $regex: requestData.searchValue.trim(), $options: 'i' } },
1508
+ { userName: { $regex: requestData.searchValue.trim(), $options: 'i' } },
1509
+ ] };
1510
+ }
1511
+ findQuery.push( { $match: { $or: [ query ] } } );
1512
+ } else {
1513
+ // findQuery.push( { $match: { $or: [ { checkListName: { $regex: requestData.searchValue, $options: 'i' } } ] } } );
1514
+ let checkListSearch = requestData.searchValue.split( ',' ).map( ( item ) => item.trim().toLowerCase() );
1515
+ let query;
1516
+ if ( checkListSearch.length > 1 ) {
1517
+ findQuery.push( { $addFields: { cheklistlowercase: { $toLower: '$checkListName' } } } );
1518
+ query = { cheklistlowercase: { $in: checkListSearch } };
1519
+ } else {
1520
+ query = { checkListName: { $regex: requestData.searchValue.trim(), $options: 'i' } };
1521
+ }
1522
+ findQuery.push( { $match: { $or: [ query ] } } );
1523
+ }
1524
+ }
1525
+
1526
+ findQuery.push( { $sort: { _id: -1 } } );
1527
+
1528
+ // findQuery.push( {
1529
+ // $group: {
1530
+ // _id: { store: '$store_id', email: '$userEmail', checklistId: '$sourceCheckList_id' },
1531
+ // checkListName: { $first: '$checkListName' },
1532
+ // coverage: { $first: '$coverage' },
1533
+ // createdByName: { $first: '$createdByName' },
1534
+ // userName: { $first: '$userName' },
1535
+ // checklistStatus: { $last: '$checklistStatus' },
1536
+ // userEmail: { $first: '$userEmail' },
1537
+ // submitTime_string: { $push: '$submitTime_string' },
1538
+ // storeName: { $first: '$storeName' },
1539
+ // checkListType: { $first: '$checkListType' },
1540
+ // scheduleRepeatedType: { $first: '$scheduleRepeatedType' },
1541
+ // timeFlag: { $sum: '$timeFlag' },
1542
+ // questionFlag: { $sum: '$questionFlag' },
1543
+ // date_iso: { $first: '$date_iso' },
1544
+ // store_id: { $first: '$store_id' },
1545
+ // date_string: { $first: '$date_string' },
1546
+ // sourceCheckList_id: { $first: '$sourceCheckList_id' },
1547
+ // reinitiateStatus: { $first: '$reinitiateStatus' },
1548
+ // redoStatus: { $first: '$redoStatus' },
1549
+ // submitCount: { $sum: {
1550
+ // $cond: {
1551
+ // if: { $eq: [ '$checklistStatus', 'submit' ] },
1552
+ // then: 1,
1553
+ // else: 0,
1554
+ // },
1555
+ // } },
1556
+ // approvalByEmail: { $first: '$approvalByEmail' },
1557
+ // approvalTime_string: { $push: '$approvalTime_string' },
1558
+ // idList: { $push: '$_id' },
1559
+ // },
1560
+ // } );
1561
+
1562
+ findQuery.push( {
1563
+ $project: {
1564
+ _id: 0,
1565
+ idList: 1,
1566
+ checkListName: 1,
1567
+ coverage: 1,
1568
+ createdByName: 1,
1569
+ userName: 1,
1570
+ checklistStatus: 1,
1571
+ // userEmail: '$_id.email',
1572
+ // submitTime_string: { $arrayElemAt: [ '$submitTime_string', 0 ] },
1573
+ userEmail: 1,
1574
+ submitTime_string: 1,
1575
+ storeName: 1,
1576
+ checkListType: 1,
1577
+ scheduleRepeatedType: 1,
1578
+ timeFlag: 1,
1579
+ questionFlag: 1,
1580
+ date_iso: 1,
1581
+ // store_id: '$_id.store',
1582
+ store_id: 1,
1583
+ timeFlag: 1,
1584
+ date_string: 1,
1585
+ sourceCheckList_id: 1,
1586
+ reinitiateStatus: 1,
1587
+ redoStatus: 1,
1588
+ // submitCount: 1,
1589
+ submitCount: { $sum: {
1590
+ $cond: {
1591
+ if: { $eq: [ '$checklistStatus', 'submit' ] },
1592
+ then: 1,
1593
+ else: 0,
1594
+ },
1595
+ } },
1596
+ approvalByEmail: 1,
1597
+ approvalTime_string: 1,
1598
+ },
1599
+ } );
1600
+
1601
+ findQuery.push( {
1602
+ $project: {
1603
+ idList: 1,
1604
+ checkListName: 1,
1605
+ coverage: 1,
1606
+ checkListChar: { $substr: [ '$checkListName', 0, 2 ] },
1607
+ createdByName: 1,
1608
+ userName: 1,
1609
+ checklistStatus: {
1610
+ $cond: {
1611
+ if: { $eq: [ '$checklistStatus', 'submit' ] },
1612
+ then: 'Submitted',
1613
+ else: {
1614
+ $cond: {
1615
+ if: { $eq: [ '$checklistStatus', 'open' ] },
1616
+ then: 'Open',
1617
+ else: 'In Progress',
1618
+ },
1619
+ },
1620
+ },
1621
+ },
1622
+ userEmail: 1,
1623
+ // submitTime_string: 1,
1624
+ submitTime_string: {
1625
+ $cond: {
1626
+ if: { $eq: [ '$checklistStatus', 'submit' ] },
1627
+ then: '$submitTime_string',
1628
+ else: '',
1629
+ },
1630
+ },
1631
+ storeName: 1,
1632
+ checkListType: 1,
1633
+ scheduleRepeatedType: 1,
1634
+ flaggedChecklist: { $add: [ '$timeFlag', '$questionFlag' ] },
1635
+ timeFlag: 1,
1636
+ questionFlag: 1,
1637
+ date_iso: 1,
1638
+ store_id: 1,
1639
+ timeFlag: 1,
1640
+ date_string: 1,
1641
+ checklistDate: '$date_string',
1642
+ sourceCheckList_id: 1,
1643
+ reinitiateStatus: 1,
1644
+ redoStatus: 1,
1645
+ submitCount: 1,
1646
+ approvalByEmail: 1,
1647
+ approvalTime_string: 1,
1648
+ },
1649
+ } );
1650
+
1651
+ // let getTotalCount = await processedchecklistService.aggregate( findQuery );
1652
+ // if ( !getTotalCount.length ) {
1653
+ // return res.sendError( { error: 'No Data Found' }, 204 );
1654
+ // }
1655
+
1656
+ if ( requestData.sortColumnName && requestData.sortColumnName != '' && requestData.sortBy && requestData.sortBy !='' ) {
1657
+ findQuery.push( { $sort: { [requestData.sortColumnName]: requestData.sortBy } } );
1658
+ }
1659
+ let limit = parseInt( requestData?.limit ) || 10;
1660
+ let skip = limit * ( requestData?.offset ) || 0;
1661
+
1662
+ findQuery.push(
1663
+ {
1664
+ $facet: {
1665
+ data: [
1666
+ { $skip: skip }, { $limit: limit },
1667
+ ],
1668
+ count: [
1669
+ { $count: 'total' },
1670
+ ],
1671
+ },
1672
+ },
1673
+ );
1674
+
1675
+
1676
+ let getChecklistPerformanceData = await processedchecklistService.aggregate( findQuery );
1677
+ if ( !getChecklistPerformanceData[0].data.length ) {
1678
+ return res.sendError( 'No data found', 204 );
1679
+ }
1680
+ result = {
1681
+ totalCount: getChecklistPerformanceData?.[0]?.count?.[0]?.total || 0,
1682
+ checklistInfo: getChecklistPerformanceData?.[0]?.data || [],
1683
+ };
1684
+
1685
+ result.checklistInfo.forEach( ( item ) => {
1686
+ item.date_string = dayjs( item.date_string, 'YYYY-MM-DD' ).format( 'DD MMM YYYY' );
1687
+ } );
1688
+ if ( requestData.export ) {
1689
+ const exportdata = [];
1690
+ result.checklistInfo.forEach( ( element ) => {
1691
+ if ( requestData.groupByType==='Checklist' ) {
1692
+ exportdata.push( {
1693
+ 'Date': element.date_string || '--',
1694
+ 'Store Name': element.storeName || '--',
1695
+ 'Checklist Owner': element.userName || '--',
1696
+ 'Status': element.checklistStatus || '--',
1697
+ 'Submitted By': element.userName || '--',
1698
+ 'Submitted On': element.submitTime_string || '--',
1699
+ 'Flags': element.flaggedChecklist || '--',
1700
+ 'Approval By': element.approvalByEmail || '--',
1701
+ 'Approval On': element.approvalTime_string || '--',
1702
+ } );
1703
+ } else if ( requestData.groupByType==='Store' ) {
1704
+ exportdata.push( {
1705
+ 'CheckList Name': element.checkListName || '--',
1706
+ 'Checklist Owner': element.userName || '--',
1707
+ 'Status': element.checklistStatus || '--',
1708
+ 'Submitted By': element.userName || '--',
1709
+ 'Submitted On': element.submitTime_string || '--',
1710
+ 'Flags': element.flaggedChecklist || '--',
1711
+ 'Approval By': element.approvalByEmail || '--',
1712
+ 'Approval On': element.approvalTime_string || '--',
1713
+
1714
+ } );
1715
+ } else {
1716
+ exportdata.push( {
1717
+ 'Date': element.date_string || '--',
1718
+ 'CheckList Name': element.checkListName || '--',
1719
+ 'Store Name': element.storeName || '--',
1720
+ 'Checklist Owner': element.userName || '--',
1721
+ 'Status': element.checklistStatus || '--',
1722
+ 'Submitted On': element.submitTime_string || '--',
1723
+ 'Flags': element.flaggedChecklist || '--',
1724
+ 'Approval By': element.approvalByEmail || '--',
1725
+ 'Approval On': element.approvalTime_string || '--',
1726
+ } );
1727
+ }
1728
+ } );
1729
+ return await download( exportdata, res );
1730
+ }
1731
+ return res.sendSuccess( result );
1732
+ } catch ( error ) {
1733
+ console.log( 'error =>', error );
1734
+ logger.error( { error: error, message: req.query, function: 'checklistInfo' } );
1735
+ return res.sendError( { error: error }, 500 );
1736
+ }
1737
+ };
1738
+
1448
1739
  export const infoCardsOld = async ( req, res ) => {
1449
1740
  try {
1450
1741
  let requestData = req.body;
@@ -2481,14 +2772,14 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
2481
2772
  rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
2482
2773
  } else if ( requestData.dateType == 'monthly' ) {
2483
2774
  rangeOneFromDate = new Date( requestData.toDate );
2484
- rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 30 );
2775
+ rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 29 );
2485
2776
  rangeOneToDate = new Date( requestData.toDate );
2486
2777
  rangeOneToDate = new Date( rangeOneToDate.getTime() - userTimezoneOffset );
2487
2778
  rangeOneToDate.setUTCHours( 23, 59, 59, 59 );
2488
2779
  rangeTwoToDate = new Date( requestData.toDate );
2489
- rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 31 );
2780
+ rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 30 );
2490
2781
  rangeTwoFromDate = new Date( rangeTwoToDate );
2491
- rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 30 );
2782
+ rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 29 );
2492
2783
  rangeTwoToDate = new Date( rangeTwoToDate.getTime() - userTimezoneOffset );
2493
2784
  rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
2494
2785
  } else {
@@ -2681,6 +2972,13 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
2681
2972
  overallComparisonCards.complianceRate.comparisonData = Math.abs( overallComparisonCards.complianceRate.comparisonData );
2682
2973
  }
2683
2974
 
2975
+ overallComparisonCards.traxMonthlyComparison = false;
2976
+ let traxMonthlyComparisonData = await clientService.findOne( { clientId: requestData.clientId }, { traxMonthlyComparison: 1 } );
2977
+ // console.log( 'traxMonthlyComparisonData', traxMonthlyComparisonData );
2978
+ if ( traxMonthlyComparisonData && traxMonthlyComparisonData.traxMonthlyComparison ) {
2979
+ overallComparisonCards.traxMonthlyComparison = traxMonthlyComparisonData.traxMonthlyComparison;
2980
+ }
2981
+
2684
2982
  let result = {
2685
2983
  'overallComparisonCards': overallComparisonCards,
2686
2984
  };
@@ -3003,14 +3301,14 @@ export const infoComparisonCardsV1 = async ( req, res ) => {
3003
3301
  rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
3004
3302
  } else if ( requestData.dateType == 'monthly' ) {
3005
3303
  rangeOneFromDate = new Date( requestData.toDate );
3006
- rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 30 );
3304
+ rangeOneFromDate.setDate( rangeOneFromDate.getDate() - 29 );
3007
3305
  rangeOneToDate = new Date( requestData.toDate );
3008
3306
  rangeOneToDate = new Date( rangeOneToDate.getTime() - userTimezoneOffset );
3009
3307
  rangeOneToDate.setUTCHours( 23, 59, 59, 59 );
3010
3308
  rangeTwoToDate = new Date( requestData.toDate );
3011
- rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 31 );
3309
+ rangeTwoToDate.setDate( rangeTwoToDate.getDate() - 30 );
3012
3310
  rangeTwoFromDate = new Date( rangeTwoToDate );
3013
- rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 30 );
3311
+ rangeTwoFromDate.setDate( rangeTwoFromDate.getDate() - 29 );
3014
3312
  rangeTwoToDate = new Date( rangeTwoToDate.getTime() - userTimezoneOffset );
3015
3313
  rangeTwoToDate.setUTCHours( 23, 59, 59, 59 );
3016
3314
  } else {
@@ -3066,8 +3364,14 @@ export const infoComparisonCardsV1 = async ( req, res ) => {
3066
3364
  'flags': flags,
3067
3365
  'completionScore': completionScore,
3068
3366
  'complianceRate': complianceRate,
3367
+ 'traxMonthlyComparison': false,
3069
3368
  };
3070
3369
 
3370
+ let traxMonthlyComparisonData = await clientService.findOne( { clientId: requestData.clientId }, { traxMonthlyComparison: 1 } );
3371
+ if ( traxMonthlyComparisonData && traxMonthlyComparisonData.traxMonthlyComparison ) {
3372
+ infoComparisonCards.traxMonthlyComparison = traxMonthlyComparisonData.traxMonthlyComparison;
3373
+ }
3374
+
3071
3375
  // Get User Based Checklist //
3072
3376
  // let loginUser = { clientId: requestData.clientId, role: req.user.role, userType: req.user.userType, userEmail: req.user.email };
3073
3377
  // let getUserEmails = await getChecklistUsers( loginUser );
@@ -3220,7 +3524,11 @@ export const infoComparisonCardsV1 = async ( req, res ) => {
3220
3524
  let rangeTwoData = await processedchecklistService.aggregate( rangeTwoFindQuery );
3221
3525
 
3222
3526
  if ( !rangeOneData.length ) {
3223
- return res.sendError( { error: 'No Data Found' }, 204 );
3527
+ // return res.sendError( { error: 'No Data Found' }, 204 );
3528
+ let result = {
3529
+ 'infoComparisonCards': infoComparisonCards,
3530
+ };
3531
+ return res.sendSuccess( result );
3224
3532
  }
3225
3533
 
3226
3534
  if ( rangeOneData.length >0 && rangeTwoData.length >0 ) {
@@ -22,6 +22,7 @@ internalTraxRouter
22
22
  .get( '/getOTP', isAllowedInternalAPIHandler, internalController.getOTP )
23
23
  .get( '/getDownloads', isAllowedInternalAPIHandler, internalController.getDownloads )
24
24
  .post( '/sendPushNotification', isAllowedInternalAPIHandler, internalController.internalSendPushNotification )
25
- .post( '/sendAiPushNotification', isAllowedInternalAPIHandler, internalController.internalAISendPushNotification );
25
+ .post( '/sendAiPushNotification', isAllowedInternalAPIHandler, internalController.internalAISendPushNotification )
26
+ .post( '/getLiveChecklistClients', isAllowedInternalAPIHandler, internalController.getLiveChecklistClients );
26
27
 
27
28