tango-app-api-trax 3.7.47 → 3.7.48

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.7.47",
3
+ "version": "3.7.48",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -620,7 +620,7 @@ export const flagCardsV1 = async ( req, res ) => {
620
620
  const detectionPayload = { fromDate, toDate, storeId, clientId };
621
621
  const lambdaURL = 'https://f65azvtljclaxp6l7rnx65cdmm0lcgvp.lambda-url.ap-south-1.on.aws/';
622
622
  const resultData = await LamdaServiceCall( lambdaURL, detectionPayload );
623
- console.log( '🚀 ~ flagCardsV1 ~ resultData:', resultData );
623
+
624
624
 
625
625
  const published = publishedAiChecklists.map( ( val ) => val?.checkListType );
626
626
 
@@ -2022,7 +2022,7 @@ export const flagChecklistCardsV1 = async ( req, res ) => {
2022
2022
  client_id: reqestData.clientId,
2023
2023
  sourceCheckList_id: new mongoose.Types.ObjectId( reqestData.sourceCheckList_id ),
2024
2024
  // store_id: { $in: reqestData.storeId },
2025
- $or: [ { store_id: { $in: reqestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: reqestData.userEmailes } } ],
2025
+ $or: [ { store_id: { $in: reqestData.storeId } }, { aiStoreList: { $in: reqestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: reqestData.userEmailes } } ],
2026
2026
  },
2027
2027
  },
2028
2028
  {
@@ -2038,9 +2038,11 @@ export const flagChecklistCardsV1 = async ( req, res ) => {
2038
2038
  },
2039
2039
  ];
2040
2040
  const checklist = await aggregate( pipeline );
2041
+ console.log( '🚀 ~ flagChecklistCardsV1 ~ checklist:', checklist );
2041
2042
  reqestData.storeCount = checklist[0]?.storeCount | 0;
2042
2043
  let LamdaURL = 'https://k462fpztd3zaucty5ruoks6z540qqgqj.lambda-url.ap-south-1.on.aws/';
2043
2044
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
2045
+ console.log( '🚀 ~ flagChecklistCardsV1 ~ resultData:', resultData );
2044
2046
  if ( resultData ) {
2045
2047
  if ( resultData.status_code == '200' ) {
2046
2048
  if ( resultData.customerunattendedCards && resultData.customerunattendedCards.timeTakentoAssistsec && resultData.customerunattendedCards.timeTakentoAssistsec.secs ) {
@@ -180,7 +180,7 @@ export const create = async ( req, res ) => {
180
180
  { $match: { client_id: req.body.clientId, type: 'checklist' } },
181
181
  { $group: { _id: null, maxCheckListNumber: { $max: '$checkListNumber' } } },
182
182
  ] );
183
- checkNumber = result.length > 0 ? result[0].maxCheckListNumber+1 : 0;
183
+ checkNumber = result.length > 0 ? result[0].maxCheckListNumber + 1 : 0;
184
184
 
185
185
  let runAIQuestionCount = 0;
186
186
 
@@ -192,7 +192,7 @@ export const create = async ( req, res ) => {
192
192
  questionCount = questionCount + element?.questions?.length;
193
193
  }
194
194
  let runAiQuestions = element?.questions.filter( ( qn ) => qn.runAI );
195
- runAIQuestionCount +=runAiQuestions.length;
195
+ runAIQuestionCount += runAiQuestions.length;
196
196
  } );
197
197
 
198
198
  let checkListDetails = {
@@ -268,12 +268,12 @@ export const create = async ( req, res ) => {
268
268
 
269
269
  let maxQID = 0;
270
270
  if ( section.questions && section.questions.length > 0 ) {
271
- // let qids = section.questions
272
- // .filter( ( q ) => q.uniqueqno != null )
273
- // .map( ( q ) => Number( q.uniqueqno ) );
274
- // console.log( 'Extracted QIDs =>', qids );
275
- // let maxQID = Math.max( 0, ...qids );
276
- // console.log( 'maxQID =>', maxQID );
271
+ // let qids = section.questions
272
+ // .filter( ( q ) => q.uniqueqno != null )
273
+ // .map( ( q ) => Number( q.uniqueqno ) );
274
+ // console.log( 'Extracted QIDs =>', qids );
275
+ // let maxQID = Math.max( 0, ...qids );
276
+ // console.log( 'maxQID =>', maxQID );
277
277
 
278
278
  for ( let [ index1, questions ] of section.questions.entries() ) {
279
279
  if ( !questions.uniqueqno ) {
@@ -290,7 +290,7 @@ export const create = async ( req, res ) => {
290
290
  await processNested( index, question );
291
291
  }
292
292
 
293
- async function processNested( qIdx, question, nestedIndex=-1 ) {
293
+ async function processNested( qIdx, question, nestedIndex = -1 ) {
294
294
  if ( question?.answers?.length ) {
295
295
  for ( let [ index, answer ] of question?.answers?.entries() ) {
296
296
  if ( !section.questions[qIdx].answers[index]?.nestedQuestion && nestedIndex == -1 ) {
@@ -339,7 +339,7 @@ export const create = async ( req, res ) => {
339
339
  let teamsMsg;
340
340
  let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
341
341
  actionType = 'Create';
342
- teamsMsg = 'ClientId: '+ req.body.clientId + ', Action: '+ actionType + ', ChecklistId: '+ checkListId + ', Checklist Name: '+ inputBody.checklistName + ', UpDatedBy: '+ req.user.email;
342
+ teamsMsg = 'ClientId: ' + req.body.clientId + ', Action: ' + actionType + ', ChecklistId: ' + checkListId + ', Checklist Name: ' + inputBody.checklistName + ', UpDatedBy: ' + req.user.email;
343
343
  sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
344
344
 
345
345
  let logObj = {
@@ -541,7 +541,7 @@ export const getConfigDetails = async ( req, res ) => {
541
541
  return { id: item.assignId, type: 'cluster' };
542
542
  } );
543
543
  } else {
544
- singleAssign = assignList.filter( ( item ) => typeof item?.userEmail != 'undefined' && item?.userEmail !='' ).map( ( item ) => {
544
+ singleAssign = assignList.filter( ( item ) => typeof item?.userEmail != 'undefined' && item?.userEmail != '' ).map( ( item ) => {
545
545
  return { id: item.assignId, type: 'user' };
546
546
  } );
547
547
  groupAssign = assignList.filter( ( item ) => typeof item?.teamName != 'undefined' && item?.teamName != '' ).map( ( item ) => {
@@ -597,6 +597,10 @@ export const zoneList = async ( req, res ) => {
597
597
  'Store Half Shutter Detection',
598
598
  'Mobile usage detection',
599
599
  'Store TV Compliance',
600
+ 'Queue Wait Time Breach',
601
+ ];
602
+ const allowedChecklistsStreams = [
603
+ 'Camera Angle Change Compliance',
600
604
  ];
601
605
 
602
606
  if ( inputBody.checkListName && allowedChecklists.includes( inputBody.checkListName ) ) {
@@ -627,6 +631,8 @@ export const zoneList = async ( req, res ) => {
627
631
  }
628
632
 
629
633
  return res.sendSuccess( zoneList );
634
+ } else if ( inputBody.checkListName && allowedChecklistsStreams.includes( inputBody.checkListName ) ) {
635
+ return res.sendSuccess( [ { zone: 'Camera Angle Change Compliance' } ] );
630
636
  } else {
631
637
  let query = [
632
638
  {
@@ -803,7 +809,7 @@ export const deleteChecklist = async ( req, res ) => {
803
809
  let actionType = 'Deleted';
804
810
  let teamsMsg;
805
811
  let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
806
- teamsMsg = 'ClientId: '+ checklistDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ req.params.checklistId + ', Checklist Name: '+ checklistDetails.checkListName + ', UpDatedBy: '+ req.user.email;
812
+ teamsMsg = 'ClientId: ' + checklistDetails.client_id + ', Action: ' + actionType + ', ChecklistId: ' + req.params.checklistId + ', Checklist Name: ' + checklistDetails.checkListName + ', UpDatedBy: ' + req.user.email;
807
813
  sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
808
814
 
809
815
  let logObj = {
@@ -851,7 +857,7 @@ export const duplicateChecklist = async ( req, res ) => {
851
857
  let checkListNameDetails = await checklistService.find( { checkListName: { $regex: name }, client_id: req.query.clientId, type: 'checklist' } );
852
858
  if ( checkListNameDetails.length ) {
853
859
  let nameLength = checkListNameDetails.length + 1;
854
- dupDetails.checkListName = dupDetails.checkListName.split( '(' )[0] + '(' + nameLength +')';
860
+ dupDetails.checkListName = dupDetails.checkListName.split( '(' )[0] + '(' + nameLength + ')';
855
861
  } else {
856
862
  dupDetails.checkListName = dupDetails.checkListName + '(1)';
857
863
  }
@@ -859,7 +865,7 @@ export const duplicateChecklist = async ( req, res ) => {
859
865
  dupDetails.createdAt = new Date();
860
866
  dupDetails.updatedAt = new Date();
861
867
  dupDetails.publishDate = '';
862
- dupDetails.checkListNumber = dupDetails.checkListNumber+1;
868
+ dupDetails.checkListNumber = dupDetails.checkListNumber + 1;
863
869
  dupDetails.rawImageUpload = false;
864
870
  dupDetails.rawVideoUpload = false;
865
871
  dupDetails.videoUploadTimeLimit = 0;
@@ -890,7 +896,7 @@ export const duplicateChecklist = async ( req, res ) => {
890
896
  }
891
897
  let sectionList = await questionService.findSort( { checkListId: checkDetails._id, client_id: req.query.clientId, isdeleted: false }, {}, { sectionNumber: 1 } );
892
898
  if ( sectionList.length ) {
893
- let sections= [];
899
+ let sections = [];
894
900
  for ( let i = 0; i < sectionList.length; i++ ) {
895
901
  let sectionDetails = { ...sectionList[i]._doc };
896
902
  sectionDetails.checkListId = data._id;
@@ -915,8 +921,8 @@ export const duplicateChecklist = async ( req, res ) => {
915
921
  let actionType = 'Duplicated';
916
922
  let teamsMsg;
917
923
  let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
918
- if ( teamsAlertUrls && teamsAlertUrls !='' ) {
919
- teamsMsg = 'ClientId: '+ checkDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ data._id + ', Checklist Name: '+ checkDetails.checkListName + ', UpDatedBy: '+ req.user.email;
924
+ if ( teamsAlertUrls && teamsAlertUrls != '' ) {
925
+ teamsMsg = 'ClientId: ' + checkDetails.client_id + ', Action: ' + actionType + ', ChecklistId: ' + data._id + ', Checklist Name: ' + checkDetails.checkListName + ', UpDatedBy: ' + req.user.email;
920
926
  sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
921
927
  }
922
928
 
@@ -984,7 +990,7 @@ export const update = async ( req, res ) => {
984
990
  questionCount = questionCount + element.questions.length;
985
991
  }
986
992
  let runAiQuestions = element?.questions.filter( ( qn ) => qn.runAI );
987
- runAIQuestionCount +=runAiQuestions.length;
993
+ runAIQuestionCount += runAiQuestions.length;
988
994
  } );
989
995
 
990
996
 
@@ -1008,7 +1014,7 @@ export const update = async ( req, res ) => {
1008
1014
  // createdByEmail: req.user.email,
1009
1015
  // };
1010
1016
  // await checklistLogs.create( logInsertData );
1011
- let sectionList =[];
1017
+ let sectionList = [];
1012
1018
  if ( inputBody.sections.length ) {
1013
1019
  for ( let i = 0; i < inputBody?.sections?.length; i++ ) {
1014
1020
  let section = inputBody.sections[i];
@@ -1063,7 +1069,7 @@ export const update = async ( req, res ) => {
1063
1069
  await processNested( index, question );
1064
1070
  }
1065
1071
 
1066
- async function processNested( qIdx, question, nestedIndex=-1 ) {
1072
+ async function processNested( qIdx, question, nestedIndex = -1 ) {
1067
1073
  if ( question?.answers?.length ) {
1068
1074
  for ( let [ index, answer ] of question?.answers?.entries() ) {
1069
1075
  if ( !section.questions[qIdx].answers[index]?.nestedQuestion && nestedIndex == -1 ) {
@@ -1207,14 +1213,18 @@ export const update = async ( req, res ) => {
1207
1213
  createdBy: req.user.userName,
1208
1214
  coverage: checkListDetails.coverage,
1209
1215
  logDetails: {
1210
- ...( inputBody.checklistName.toLowerCase() == checkListDetails.checkListName.toLowerCase() ) ? { updatedChecklistName: {} } :{ updatedChecklistName: {
1211
- previous: checkListDetails.checkListName,
1212
- new: inputBody.checklistName,
1213
- } },
1214
- ...( inputBody.checklistDescription.toLowerCase() == checkListDetails.checkListDescription.toLowerCase() ) ? { updatedChecklistDescription: {} } :{ updatedChecklistDescription: {
1215
- previous: checkListDetails.checkListDescription,
1216
- new: inputBody.checklistDescription,
1217
- } },
1216
+ ...( inputBody.checklistName.toLowerCase() == checkListDetails.checkListName.toLowerCase() ) ? { updatedChecklistName: {} } : {
1217
+ updatedChecklistName: {
1218
+ previous: checkListDetails.checkListName,
1219
+ new: inputBody.checklistName,
1220
+ },
1221
+ },
1222
+ ...( inputBody.checklistDescription.toLowerCase() == checkListDetails.checkListDescription.toLowerCase() ) ? { updatedChecklistDescription: {} } : {
1223
+ updatedChecklistDescription: {
1224
+ previous: checkListDetails.checkListDescription,
1225
+ new: inputBody.checklistDescription,
1226
+ },
1227
+ },
1218
1228
  updatedSectionName: updateSection,
1219
1229
  questionAdd: questionList.questionAdd,
1220
1230
  questionEdit: questionList.questionEdit,
@@ -1227,7 +1237,7 @@ export const update = async ( req, res ) => {
1227
1237
  // / Teams Alert
1228
1238
  let teamsMsg;
1229
1239
  let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
1230
- teamsMsg = 'ClientId: '+ insertLogData.client_id + ', Type: Checklist, Action: Checklist Question Edited, ChecklistId: '+ insertLogData.sourceCheckList_id + ', Checklist Name: '+ insertLogData.checkListName +', UpDatedBy: '+ req.user.email;
1240
+ teamsMsg = 'ClientId: ' + insertLogData.client_id + ', Type: Checklist, Action: Checklist Question Edited, ChecklistId: ' + insertLogData.sourceCheckList_id + ', Checklist Name: ' + insertLogData.checkListName + ', UpDatedBy: ' + req.user.email;
1231
1241
  if ( teamsAlertUrls && teamsAlertUrls.questionEditAlert ) {
1232
1242
  sendTeamsNotification( teamsAlertUrls.questionEditAlert, teamsMsg );
1233
1243
  }
@@ -1285,7 +1295,7 @@ export const update = async ( req, res ) => {
1285
1295
  let actionType = 'Checklist Updated';
1286
1296
  let teamsMsg;
1287
1297
  let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
1288
- teamsMsg = 'ClientId: '+ req.body.clientId + ', Action: '+ actionType + ', ChecklistId: '+ checkListId + ', Checklist Name: '+ inputBody.checklistName + ', UpDatedBy: '+ req.user.email;
1298
+ teamsMsg = 'ClientId: ' + req.body.clientId + ', Action: ' + actionType + ', ChecklistId: ' + checkListId + ', Checklist Name: ' + inputBody.checklistName + ', UpDatedBy: ' + req.user.email;
1289
1299
  sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
1290
1300
  return res.sendSuccess( { message: 'CheckList Updated Successfully', checklistId: req.params.checklistId } );
1291
1301
  } catch ( e ) {
@@ -1579,7 +1589,7 @@ export const runAIInsert = async ( req, res ) => {
1579
1589
  }
1580
1590
  };
1581
1591
 
1582
- export const updateConfigure =async ( req, res ) => {
1592
+ export const updateConfigure = async ( req, res ) => {
1583
1593
  try {
1584
1594
  let inputBody = req.body;
1585
1595
  let storeCount = 0;
@@ -1724,7 +1734,7 @@ export const updateConfigure =async ( req, res ) => {
1724
1734
  let name = checklistDetails.checkListName.split( '(' )[0];
1725
1735
  let checkListNameDetails = await checklistService.find( { checkListName: { $regex: name }, client_id: req.body.clientId, type: 'checklist', isdeleted: false } );
1726
1736
  if ( checkListNameDetails.length ) {
1727
- let nameLength = ( checkListNameDetails.length-1 ) + 1;
1737
+ let nameLength = ( checkListNameDetails.length - 1 ) + 1;
1728
1738
  checklistDetails.checkListName = checklistDetails.checkListName.split( '(' )[0] + '(' + nameLength + ')';
1729
1739
  } else {
1730
1740
  checklistDetails.checkListName = checklistDetails.checkListName;
@@ -1737,15 +1747,15 @@ export const updateConfigure =async ( req, res ) => {
1737
1747
  } else {
1738
1748
  configDetails.checkListNumber = 1;
1739
1749
  }
1740
- configDetails.createdBy= req.user._id;
1741
- configDetails.createdByName=req.user.userName;
1750
+ configDetails.createdBy = req.user._id;
1751
+ configDetails.createdByName = req.user.userName;
1742
1752
  delete inputBody.checkListDetails['_id'];
1743
1753
  if ( [ 'storeopenandclose', 'uniformdetection' ].includes( checklistDetails.checkListType ) ) {
1744
1754
  let query = { client_id: req.body.clientId, type: 'checklist', isdeleted: false };
1745
1755
  if ( checklistDetails.checkListType == 'storeopenandclose' ) {
1746
- query.checkListType= 'storeopenandclose';
1756
+ query.checkListType = 'storeopenandclose';
1747
1757
  } else {
1748
- query.checkListType= 'uniformdetection';
1758
+ query.checkListType = 'uniformdetection';
1749
1759
  }
1750
1760
  let storeChecklisDetails = await checklistService.findOne( query );
1751
1761
  if ( storeChecklisDetails ) {
@@ -1779,7 +1789,7 @@ export const updateConfigure =async ( req, res ) => {
1779
1789
  let storeDetails = await assignedService.find( { checkListId: id, checkFlag: true }, { _id: 0, store_id: 1, userEmail: 1 } );
1780
1790
  let storeList = storeDetails.map( ( store ) => store.store_id );
1781
1791
  let emailList = storeDetails.map( ( user ) => user.userEmail );
1782
- let userChunk =await chunkArray( emailList, 10 );
1792
+ let userChunk = await chunkArray( emailList, 10 );
1783
1793
 
1784
1794
  await Promise.all( userChunk.map( async ( chunk ) => {
1785
1795
  updateUserStore( chunk );
@@ -1869,7 +1879,7 @@ export const updateConfigure =async ( req, res ) => {
1869
1879
  }
1870
1880
  };
1871
1881
 
1872
- export const updateConfigurev1 =async ( req, res ) => {
1882
+ export const updateConfigurev1 = async ( req, res ) => {
1873
1883
  try {
1874
1884
  console.log( '123' );
1875
1885
  let inputBody = req.body;
@@ -1999,7 +2009,7 @@ export const updateConfigurev1 =async ( req, res ) => {
1999
2009
  let name = checklistDetails.checkListName.split( '(' )[0];
2000
2010
  let checkListNameDetails = await checklistService.find( { checkListName: { $regex: name }, client_id: req.body.clientId, type: 'checklist', isdeleted: false } );
2001
2011
  if ( checkListNameDetails.length ) {
2002
- let nameLength = ( checkListNameDetails.length-1 ) + 1;
2012
+ let nameLength = ( checkListNameDetails.length - 1 ) + 1;
2003
2013
  checklistDetails.checkListName = checklistDetails.checkListName.split( '(' )[0] + '(' + nameLength + ')';
2004
2014
  } else {
2005
2015
  checklistDetails.checkListName = checklistDetails.checkListName;
@@ -2012,15 +2022,15 @@ export const updateConfigurev1 =async ( req, res ) => {
2012
2022
  } else {
2013
2023
  configDetails.checkListNumber = 1;
2014
2024
  }
2015
- configDetails.createdBy= req.user._id;
2016
- configDetails.createdByName=req.user.userName;
2025
+ configDetails.createdBy = req.user._id;
2026
+ configDetails.createdByName = req.user.userName;
2017
2027
  delete inputBody.checkListDetails['_id'];
2018
2028
  if ( [ 'storeopenandclose', 'uniformdetection' ].includes( checklistDetails.checkListType ) ) {
2019
2029
  let query = { client_id: req.body.clientId, type: 'checklist', isdeleted: false };
2020
2030
  if ( checklistDetails.checkListType == 'storeopenandclose' ) {
2021
- query.checkListType= 'storeopenandclose';
2031
+ query.checkListType = 'storeopenandclose';
2022
2032
  } else {
2023
- query.checkListType= 'uniformdetection';
2033
+ query.checkListType = 'uniformdetection';
2024
2034
  }
2025
2035
  let storeChecklisDetails = await checklistService.findOne( query );
2026
2036
  if ( storeChecklisDetails ) {
@@ -2110,26 +2120,26 @@ export const updateConfigurev1 =async ( req, res ) => {
2110
2120
  logDetails: {
2111
2121
  schedule: {
2112
2122
  previous: {
2113
- ...( showSchedule && checklistDetails.schedule == 'onetime' ) ? { scheduleDateString: dayjs( checklistDetails?.scheduleDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
2123
+ ...( showSchedule && checklistDetails.schedule == 'onetime' ) ? { scheduleDateString: dayjs( checklistDetails?.scheduleDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
2114
2124
  schedule: showSchedule ? checklistDetails.schedule : '',
2115
2125
  time: ( ( showSchedule ) && ( checklistDetails.scheduleStartTime != '' || checklistDetails.scheduleEndTime != '' ) ) ? checklistDetails.scheduleStartTime + ' to ' + checklistDetails.scheduleEndTime : '',
2116
2126
  scheduleRepeatedDay: showSchedule ? checklistDetails?.scheduleRepeatedDay : '',
2117
2127
  scheduleRepeatedType: showSchedule ? checklistDetails?.scheduleRepeatedType : '',
2118
- ...( showSchedule && checklistDetails?.configStartDate ) ? { configStartDate: dayjs( checklistDetails?.configStartDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
2119
- ...( showSchedule && checklistDetails?.configEndDate ) ? { configEndDate: dayjs( checklistDetails?.configEndDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
2128
+ ...( showSchedule && checklistDetails?.configStartDate ) ? { configStartDate: dayjs( checklistDetails?.configStartDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
2129
+ ...( showSchedule && checklistDetails?.configEndDate ) ? { configEndDate: dayjs( checklistDetails?.configEndDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
2120
2130
  scheduleWeekDays: showSchedule ? checklistDetails?.scheduleWeekDays : [],
2121
2131
  scheduleRepeatedMonthWeek: showSchedule ? checklistDetails?.scheduleRepeatedMonthWeek : '',
2122
2132
  specificDate: showSchedule ? checklistDetails?.specificDate : [],
2123
2133
 
2124
2134
  },
2125
2135
  new: {
2126
- ...( showSchedule && configDetails.schedule == 'onetime' ) ? { scheduleDateString: dayjs( configDetails?.scheduleDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
2136
+ ...( showSchedule && configDetails.schedule == 'onetime' ) ? { scheduleDateString: dayjs( configDetails?.scheduleDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
2127
2137
  schedule: showSchedule ? configDetails.schedule : '',
2128
2138
  time: ( ( showSchedule ) && ( configDetails.scheduleStartTime != '' || configDetails.scheduleEndTime != '' ) ) ? configDetails.scheduleStartTime + ' to ' + configDetails.scheduleEndTime : '',
2129
2139
  scheduleRepeatedDay: showSchedule ? configDetails?.scheduleRepeatedDay : '',
2130
2140
  scheduleRepeatedType: showSchedule ? configDetails?.scheduleRepeatedType : '',
2131
- ...( showSchedule && configDetails?.configStartDate ) ? { configStartDate: dayjs( configDetails?.configStartDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
2132
- ...( showSchedule && configDetails?.configEndDate ) ? { configEndDate: dayjs( configDetails?.configEndDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
2141
+ ...( showSchedule && configDetails?.configStartDate ) ? { configStartDate: dayjs( configDetails?.configStartDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
2142
+ ...( showSchedule && configDetails?.configEndDate ) ? { configEndDate: dayjs( configDetails?.configEndDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
2133
2143
  scheduleWeekDays: showSchedule ? configDetails?.scheduleWeekDays : [],
2134
2144
  scheduleRepeatedMonthWeek: showSchedule ? configDetails?.scheduleRepeatedMonthWeek : '',
2135
2145
  specificDate: showSchedule ? configDetails?.specificDate : [],
@@ -2138,29 +2148,35 @@ export const updateConfigurev1 =async ( req, res ) => {
2138
2148
  response: {
2139
2149
  previous: [
2140
2150
  ...( differences?.allowedStoreLocation && checklistDetails.allowedStoreLocation ? [ 'Geo fencing' ] : [] ),
2141
- ...( differences?.allowedMultiSubmit && checklistDetails.allowedMultiSubmit? [ 'Allow multiple responses' ] : [] ),
2151
+ ...( differences?.allowedMultiSubmit && checklistDetails.allowedMultiSubmit ? [ 'Allow multiple responses' ] : [] ),
2142
2152
  ...( differences?.allowedOverTime && checklistDetails.allowedOverTime ? [ 'Fill response after configure time.' ] : [] ),
2143
2153
  ...( differences?.allowOnce && checklistDetails.allowOnce ? [ 'Only one time' ] : [] ),
2144
2154
  ],
2145
2155
  new: [
2146
2156
  ...( differences?.allowedStoreLocation && configDetails.allowedStoreLocation ? [ 'Geo fencing' ] : [] ),
2147
- ...( differences?.allowedMultiSubmit && configDetails.allowedMultiSubmit? [ 'Allow multiple responses' ] : [] ),
2157
+ ...( differences?.allowedMultiSubmit && configDetails.allowedMultiSubmit ? [ 'Allow multiple responses' ] : [] ),
2148
2158
  ...( differences?.allowedOverTime && configDetails.allowedOverTime ? [ 'Fill response after configure time' ] : [] ),
2149
2159
  ...( differences?.allowOnce && configDetails.allowOnce ? [ 'Only one time' ] : [] ),
2150
2160
  ],
2151
2161
  },
2152
- ...( differences?.approver ) ? { approver:
2153
- { previous: checklistDetails?.approver.map( ( item ) => item.name ).toString(),
2154
- new: configDetails?.approver.map( ( item ) => item.name ).toString() },
2162
+ ...( differences?.approver ) ? {
2163
+ approver:
2164
+ {
2165
+ previous: checklistDetails?.approver.map( ( item ) => item.name ).toString(),
2166
+ new: configDetails?.approver.map( ( item ) => item.name ).toString(),
2167
+ },
2155
2168
  } : { approver: {} },
2156
- ...( differences?.owner ) ? { owner:
2157
- { previous: checklistDetails?.owner.map( ( item ) => item.name ).toString(),
2158
- new: configDetails?.owner.map( ( item ) => item.name ).toString() },
2169
+ ...( differences?.owner ) ? {
2170
+ owner:
2171
+ {
2172
+ previous: checklistDetails?.owner.map( ( item ) => item.name ).toString(),
2173
+ new: configDetails?.owner.map( ( item ) => item.name ).toString(),
2174
+ },
2159
2175
  } : { owner: {} },
2160
- ...( req.body.checkListDetails.coverage == 'store' ) ? { storeAdded: req.body.added } :{ storeAdded: [] },
2161
- ...( req.body.removed.store.length ) ? { storeRemoved: req.body.removed.store } :{ storeRemoved: [] },
2162
- ...( req.body.checkListDetails.coverage == 'user' ) ? { userAdded: req.body.added } :{ userAdded: [] },
2163
- ...( req.body.removed.user.length ) ? { userRemoved: req.body.removed.user } :{ userRemoved: [] },
2176
+ ...( req.body.checkListDetails.coverage == 'store' ) ? { storeAdded: req.body.added } : { storeAdded: [] },
2177
+ ...( req.body.removed.store.length ) ? { storeRemoved: req.body.removed.store } : { storeRemoved: [] },
2178
+ ...( req.body.checkListDetails.coverage == 'user' ) ? { userAdded: req.body.added } : { userAdded: [] },
2179
+ ...( req.body.removed.user.length ) ? { userRemoved: req.body.removed.user } : { userRemoved: [] },
2164
2180
  },
2165
2181
  userType: req.user.userType,
2166
2182
  };
@@ -2190,7 +2206,7 @@ export const updateConfigurev1 =async ( req, res ) => {
2190
2206
  let teamsMsg;
2191
2207
  actionType = inputBody.checkListDetails.publish ? 'configPublish' : 'configDraft';
2192
2208
  let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
2193
- teamsMsg = 'ClientId: '+ checklistDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ checklistDetails._id + ', Checklist Name: '+ checklistDetails.checkListName + ', UpDatedBy: '+ req.user.email;
2209
+ teamsMsg = 'ClientId: ' + checklistDetails.client_id + ', Action: ' + actionType + ', ChecklistId: ' + checklistDetails._id + ', Checklist Name: ' + checklistDetails.checkListName + ', UpDatedBy: ' + req.user.email;
2194
2210
  sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
2195
2211
  if ( response?.modifiedCount || response?.matchedCount || response?.upsertedCount ) {
2196
2212
  return res.sendSuccess( { id, message: 'Configured Updated Successfully' } );
@@ -2395,7 +2411,7 @@ export const updatePublish = async ( req, res ) => {
2395
2411
  let teamsMsg;
2396
2412
  actionType = req.body.publish ? 'publish' : 'unpublish';
2397
2413
  let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
2398
- teamsMsg = 'ClientId: '+ getCheckDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ getCheckDetails._id + ', Checklist Name: '+ getCheckDetails.checkListName + ', UpDatedBy: '+ req.user.email;
2414
+ teamsMsg = 'ClientId: ' + getCheckDetails.client_id + ', Action: ' + actionType + ', ChecklistId: ' + getCheckDetails._id + ', Checklist Name: ' + getCheckDetails.checkListName + ', UpDatedBy: ' + req.user.email;
2399
2415
  sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
2400
2416
  return res.sendSuccess( { checklistName: getCheckDetails.checkListName, message: 'Updated Successfully' } );
2401
2417
  } catch ( e ) {
@@ -3017,7 +3033,7 @@ async function uploadUser( req, res ) {
3017
3033
  }
3018
3034
  }
3019
3035
 
3020
- export async function insertSingleProcessData( checklistId, processId = 0, oldData = false, editSubmit = false, showEdit=false ) {
3036
+ export async function insertSingleProcessData( checklistId, processId = 0, oldData = false, editSubmit = false, showEdit = false ) {
3021
3037
  try {
3022
3038
  let currentdate = new Date();
3023
3039
  let date = dayjs( currentdate ).format( 'YYYY-MM-DD' );
@@ -3037,7 +3053,7 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
3037
3053
  newDate = dayjs( checkExists.date_string );
3038
3054
  }
3039
3055
  let diff = parseInt( dayjs.utc( date ).diff( newDate, 'day' ) );
3040
- diff = diff < 9 ? '0'+ diff : diff;
3056
+ diff = diff < 9 ? '0' + diff : diff;
3041
3057
  if ( diff == parseInt( getCLconfig.scheduleRepeatedDay[0] ) ) {
3042
3058
  validation = true;
3043
3059
  }
@@ -3058,7 +3074,7 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
3058
3074
  let startWeek = dayjs.utc( newDate ).startOf( 'week' );
3059
3075
  let endWeek = dayjs.utc( newDate ).clone().endOf( 'week' );
3060
3076
  let diff = parseInt( dayjs( date ).diff( startWeek, 'week' ) );
3061
- diff = diff < 9 ? '0'+diff : diff;
3077
+ diff = diff < 9 ? '0' + diff : diff;
3062
3078
  if ( diff == getCLconfig.scheduleRepeatedDay[0] || ( startWeek.format( 'YYYY-MM-DD' ) <= date && endWeek.format( 'YYYY-MM-DD' ) >= date ) ) {
3063
3079
  validation = true;
3064
3080
  }
@@ -3086,11 +3102,11 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
3086
3102
  }
3087
3103
 
3088
3104
  if ( getCLconfig.scheduleRepeatedMonthWeek.split( ' ' )[0] == 5 ) {
3089
- if ( days[days.length -1] == date ) {
3105
+ if ( days[days.length - 1] == date ) {
3090
3106
  validation = true;
3091
3107
  }
3092
3108
  } else {
3093
- if ( days[parseInt( getCLconfig.scheduleRepeatedMonthWeek.split( ' ' )[0] )-1] == date ) {
3109
+ if ( days[parseInt( getCLconfig.scheduleRepeatedMonthWeek.split( ' ' )[0] ) - 1] == date ) {
3094
3110
  validation = true;
3095
3111
  }
3096
3112
  }
@@ -3113,7 +3129,7 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
3113
3129
  let startMonth = newDate.startOf( 'month' );
3114
3130
  let endMonth = newDate.clone().endOf( 'month' );
3115
3131
  let diff = parseInt( dayjs.utc( date ).diff( startMonth, 'month' ) );
3116
- diff = diff < 9 ? '0'+diff : diff;
3132
+ diff = diff < 9 ? '0' + diff : diff;
3117
3133
 
3118
3134
  if ( diff == parseInt( getCLconfig.scheduleRepeatedDay[0] ) || ( startMonth.format( 'YYYY-MM-DD' ) <= date && endMonth.format( 'YYYY-MM-DD' ) >= date ) ) {
3119
3135
  validation = true;
@@ -3731,7 +3747,8 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3731
3747
  $and: [ {
3732
3748
  date_iso: {
3733
3749
  $gte: new Date( startDate.format( 'YYYY-MM-DD' ) ),
3734
- $lte: new Date( endDate.format( 'YYYY-MM-DD' ) ) },
3750
+ $lte: new Date( endDate.format( 'YYYY-MM-DD' ) ),
3751
+ },
3735
3752
  } ],
3736
3753
  };
3737
3754
  } else {
@@ -3955,16 +3972,18 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3955
3972
  } else {
3956
3973
  let deletedList = [];
3957
3974
 
3958
- await processedchecklist.deleteMany( { date_string: insertdata.date_string,
3975
+ await processedchecklist.deleteMany( {
3976
+ date_string: insertdata.date_string,
3959
3977
  date_iso: insertdata.date_iso,
3960
3978
  client_id: insertdata.client_id,
3961
- checkListId: updatedchecklist._id, checklistStatus: 'open' } );
3979
+ checkListId: updatedchecklist._id, checklistStatus: 'open',
3980
+ } );
3962
3981
 
3963
3982
 
3964
3983
  let actionType = 'deleteOpenUsers';
3965
3984
  let teamsMsg;
3966
3985
  let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
3967
- teamsMsg = 'ClientId: '+ insertdata.client_id + ', Action: '+ actionType + ', ChecklistId: '+ getCLconfig._id + ', Checklist Name: '+ getCLconfig.checkListName;
3986
+ teamsMsg = 'ClientId: ' + insertdata.client_id + ', Action: ' + actionType + ', ChecklistId: ' + getCLconfig._id + ', Checklist Name: ' + getCLconfig.checkListName;
3968
3987
  sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
3969
3988
 
3970
3989
  let inprogressData = await processedchecklist.find( {
@@ -3997,7 +4016,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
3997
4016
  actionType = 'insertAssignUsers';
3998
4017
  teamsMsg;
3999
4018
  teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
4000
- teamsMsg = 'ClientId: '+ insertdata.client_id + ', Action: '+ actionType + ', ChecklistId: '+ getCLconfig._id + ', Checklist Name: '+ getCLconfig.checkListName + ', assignedUserCount:'+ assignUserList.length+', inprogressSubmitCount:' + submittedDetails?.length;
4019
+ teamsMsg = 'ClientId: ' + insertdata.client_id + ', Action: ' + actionType + ', ChecklistId: ' + getCLconfig._id + ', Checklist Name: ' + getCLconfig.checkListName + ', assignedUserCount:' + assignUserList.length + ', inprogressSubmitCount:' + submittedDetails?.length;
4001
4020
  sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
4002
4021
  }
4003
4022
 
@@ -4082,7 +4101,7 @@ export const aiChecklist = async ( req, res ) => {
4082
4101
  let existList = publishList.map( ( item ) => item.checkListType );
4083
4102
  aiList = aiList.filter( ( item ) => !existList.includes( item ) );
4084
4103
  }
4085
- unpublishList= await checklistService.find( { client_id: { $exists: false }, checkListType: { $in: aiList } }, { publish: 1, checkListName: 1, checkListType: 1, checkListDescription: 1 } );
4104
+ unpublishList = await checklistService.find( { client_id: { $exists: false }, checkListType: { $in: aiList } }, { publish: 1, checkListName: 1, checkListType: 1, checkListDescription: 1 } );
4086
4105
  checklistDetails = [ ...publishList, ...unpublishList ];
4087
4106
 
4088
4107
  checklistDetails.forEach( ( item ) => {
@@ -4410,11 +4429,11 @@ export async function checklistAssign( req, res ) {
4410
4429
  return acc;
4411
4430
  }, {} );
4412
4431
 
4413
- uniqueArr= Object.values( uniqueArr );
4432
+ uniqueArr = Object.values( uniqueArr );
4414
4433
  } else {
4415
4434
  uniqueArr = uniqueArr.reduce( ( acc, obj ) => {
4416
4435
  if ( acc[obj.userEmail] ) {
4417
- acc[obj.userEmail].teamName += ','+ obj.teamName;
4436
+ acc[obj.userEmail].teamName += ',' + obj.teamName;
4418
4437
  acc[obj.userEmail].id.push( ...obj.id );
4419
4438
  } else {
4420
4439
  acc[obj.userEmail] = { ...obj };
@@ -4467,7 +4486,7 @@ export async function updateAssign( req, res ) {
4467
4486
  let storeClusterDetails = getAssignedDetails.filter( ( ele ) => ele?.storeName || ele?.clusterName );
4468
4487
  let userTeamDetails = getAssignedDetails.filter( ( ele ) => !ele?.storeName && ( ele?.userName || ele?.teamName ) );
4469
4488
  storeClusterDetails = [ ...new Set( storeClusterDetails.map( ( ele ) => ele?.storeName || ele?.clusterName ) ) ];
4470
- userTeamDetails= [ ...new Set( userTeamDetails.map( ( ele ) => ele?.userName || ele?.teamName ) ) ];
4489
+ userTeamDetails = [ ...new Set( userTeamDetails.map( ( ele ) => ele?.userName || ele?.teamName ) ) ];
4471
4490
  getAssignedDetails = [ ...storeClusterDetails, ...userTeamDetails ];
4472
4491
  }
4473
4492
  let assignedAllList = [ ...req.body.assignedList, ...groupList ];
@@ -4630,7 +4649,7 @@ export async function updateAiConfigure( req, res ) {
4630
4649
  type: 'checklist',
4631
4650
  checkListType: aiChecklistDetails.checkListType,
4632
4651
  schedule: 'daily',
4633
- ...( req.body.publish ) ? { publishDate: new Date() } :{},
4652
+ ...( req.body.publish ) ? { publishDate: new Date() } : {},
4634
4653
  approver: req.body?.approver || [],
4635
4654
  scheduleRepeatedDay: [ '01' ],
4636
4655
  scheduleStartTime: '06:00 AM',
@@ -4668,7 +4687,7 @@ export async function updateAiConfigure( req, res ) {
4668
4687
  req.body.storeList.forEach( ( ele ) => {
4669
4688
  let eventTime = [];
4670
4689
  Object.keys( ele ).forEach( ( key ) => {
4671
- let keyValue ={};
4690
+ let keyValue = {};
4672
4691
  if ( req.body.aiConfig?.assignConfig && req.body.aiConfig?.assignConfig == 'store' && key.includes( 'startTime' ) ) {
4673
4692
  let num = key.slice( -1 );
4674
4693
  if ( ele[key] && ele[`configTime${num}`] ) {
@@ -4722,7 +4741,7 @@ export async function updateAiConfigure( req, res ) {
4722
4741
  locationCount: 1,
4723
4742
  checkListType: aiChecklistDetails.checkListType,
4724
4743
  scheduleRepeatedType: 'daily',
4725
- aiStoreList: storeData.length? storeData.map( ( store ) => {
4744
+ aiStoreList: storeData.length ? storeData.map( ( store ) => {
4726
4745
  return { storeName: store.storeName, events: store.events, storeId: store.store_id };
4727
4746
  } ) : [],
4728
4747
  aiConfig: req.body.aiConfig,
@@ -4794,8 +4813,8 @@ export async function getAiDetails( req, res ) {
4794
4813
  }
4795
4814
  if ( [ 'cleaning', 'scrum' ].includes( checklistDetails.checkListType ) && checklistDetails?.aiConfig?.assignConfig == 'store' ) {
4796
4815
  ele.events.forEach( ( event, index ) => {
4797
- element[`startTime${index+1}`] = event.time;
4798
- element[`configTime${index+1}`] = event.duration;
4816
+ element[`startTime${index + 1}`] = event.time;
4817
+ element[`configTime${index + 1}`] = event.duration;
4799
4818
  } );
4800
4819
  }
4801
4820
  data.push( element );
@@ -4811,7 +4830,7 @@ export async function getAiDetails( req, res ) {
4811
4830
  storeList: storeList,
4812
4831
  approver: checklistDetails?.approver,
4813
4832
  storeCount: checklistDetails?.storeCount,
4814
- ...( checklistDetails?.client_id ) ? { clientId: checklistDetails?.client_id } :{},
4833
+ ...( checklistDetails?.client_id ) ? { clientId: checklistDetails?.client_id } : {},
4815
4834
  enableNewDeployedStore: checklistDetails?.enableNewDeployedStore,
4816
4835
  product: clientDetails?.planDetails?.product.map( ( product ) => product.productName ),
4817
4836
  };
@@ -5017,7 +5036,7 @@ export async function updateOSProcessedData( req, res ) {
5017
5036
  ],
5018
5037
  },
5019
5038
  } ];
5020
- if ( requestData.type && requestData.type=='checklist' ) {
5039
+ if ( requestData.type && requestData.type == 'checklist' ) {
5021
5040
  let getchecklist = await processedchecklist.aggregate( findQuery );
5022
5041
  if ( getchecklist && getchecklist.length > 0 ) {
5023
5042
  const requestOptions = {
@@ -5033,7 +5052,7 @@ export async function updateOSProcessedData( req, res ) {
5033
5052
  } else {
5034
5053
  return res.sendError( { message: 'invalid _id' }, 400 );
5035
5054
  }
5036
- } else if ( requestData.type && requestData.type=='task' ) {
5055
+ } else if ( requestData.type && requestData.type == 'task' ) {
5037
5056
  let gettask = await processedTaskService.aggregate( findQuery );
5038
5057
  if ( gettask && gettask.length > 0 ) {
5039
5058
  const requestOptions = {