tango-app-api-trax 3.5.1-alpha-3 → 3.5.2-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": "3.5.1-alpha-3",
3
+ "version": "3.5.2-alpha-2",
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 && !requestData?.editSubmit ) {
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 = [];