tango-app-api-trax 3.7.66 → 3.7.68

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.66",
3
+ "version": "3.7.68",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1363,6 +1363,43 @@ export async function insertTimeDelayFlags( req, res ) {
1363
1363
 
1364
1364
  let updatedDetails = await processedchecklist.updateMany( { _id: { $in: checklistId } }, { timeFlag: 1 } );
1365
1365
 
1366
+
1367
+ let notifyStores = await processedchecklist.find( { _id: { $in: checklistId }, notify: { $exists: false } } );
1368
+
1369
+ if ( notifyStores.length ) {
1370
+ Promise.all( notifyStores.map( async ( store ) => {
1371
+ let checklistDetails = await checklistService.findOne( { _id: store.sourceCheckList_id }, { notifyFlags: 1, approver: 1 } );
1372
+ if ( checklistDetails?.notifyFlags?.notifyType?.length ) {
1373
+ let emailList = checklistDetails?.notifyFlags?.notifyType.includes( 'approver' ) ? checklistDetails.approver.map( ( ele ) => ele?.value ): [];
1374
+ emailList = [ ...emailList, ...checklistDetails?.notifyFlags?.users?.map( ( ele ) => ele?.value ) ];
1375
+ let data = {
1376
+ storeName: store.storeName,
1377
+ flagCount: 1,
1378
+ checklistName: store.checkListName?.trim(),
1379
+ submittedBy: '--',
1380
+ time: '--',
1381
+ domain: `${JSON.parse( process.env.URL ).domain}/manage/trax/flags`,
1382
+ type: 'delay',
1383
+ answerType: [ 'yes/no', 'descriptive', 'multiplechoicesingle', 'multiplechoicemultiple', 'dropdown' ],
1384
+ };
1385
+ const fileContent = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/flag.hbs', 'utf8' );
1386
+ const htmlContent = handlebars.compile( fileContent );
1387
+ const html = htmlContent( { data: data } );
1388
+ emailList.forEach( ( email ) => {
1389
+ let params = {
1390
+ toEmail: email,
1391
+ mailSubject: 'TangoEye | Checklist Flag',
1392
+ htmlBody: html,
1393
+ attachment: '',
1394
+ sourceEmail: JSON.parse( process.env.SES ).adminEmail,
1395
+ };
1396
+ sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
1397
+ } );
1398
+ }
1399
+ await processedchecklist.updateOne( { _id: store._id }, { notify: true } );
1400
+ } ) );
1401
+ }
1402
+
1366
1403
  if ( updatedDetails ) {
1367
1404
  return res.sendSuccess( { message: 'Time Delay Updated Successfully' } );
1368
1405
  }
@@ -229,6 +229,7 @@ export async function startChecklist( req, res ) {
229
229
  },
230
230
  questionAnswers: { $ifNull: [ '$questionAnswers', '' ] },
231
231
  redoStatus: { $ifNull: [ '$redoStatus', '' ] },
232
+ export: { $ifNull: [ '$export', '' ] },
232
233
  },
233
234
  } );
234
235
  let getupdatedchecklist = await processedchecklist.aggregate( findQuery );
@@ -2014,31 +2015,33 @@ export async function submitChecklist( req, res ) {
2014
2015
  };
2015
2016
  console.log( 'inserttraxlogs =>', inserttraxlogs );
2016
2017
  insertOpenSearchData( openSearch.traxActivityLog, inserttraxlogs );
2017
- let checklistDetails = await checklistService.findOne( { _id: getchecklist[0].sourceCheckList_id }, { notifyFlags: 1, approver: 1 } );
2018
- if ( checklistDetails?.notifyFlags?.notifyType?.length ) {
2019
- let emailList = checklistDetails?.notifyFlags?.notifyType.includes( 'approver' ) ? checklistDetails.approver.flatMap( ( ele ) => ele?.value ): [];
2020
- emailList = [ ...emailList, ...checklistDetails?.notifyFlags?.users?.map( ( ele ) => ele?.value ) ];
2021
- let data = {
2022
- storeName: getchecklist[0].storeName,
2023
- flagCount: updateData.questionFlag,
2024
- checklistName: getchecklist[0].checkListName,
2025
- submittedBy: getchecklist[0].userName,
2026
- time: updateData.submitMobileTime,
2027
- domain: JSON.parse( process.env.URL ).domain,
2028
- };
2029
- const fileContent = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/flag.hbs', 'utf8' );
2030
- const htmlContent = handlebars.compile( fileContent );
2031
- const html = htmlContent( { data: data } );
2032
- emailList.forEach( ( email ) => {
2033
- let params = {
2034
- toEmail: email,
2035
- mailSubject: 'TangoEye | Checklist Flag',
2036
- htmlBody: html,
2037
- attachment: '',
2038
- sourceEmail: JSON.parse( process.env.SES ).adminEmail,
2018
+ if ( updateData.questionFlag ) {
2019
+ let checklistDetails = await checklistService.findOne( { _id: getchecklist[0].sourceCheckList_id }, { notifyFlags: 1, approver: 1 } );
2020
+ if ( checklistDetails?.notifyFlags?.notifyType?.length ) {
2021
+ let emailList = checklistDetails?.notifyFlags?.notifyType.includes( 'approver' ) ? checklistDetails.approver.map( ( ele ) => ele?.value ): [];
2022
+ emailList = [ ...emailList, ...checklistDetails?.notifyFlags?.users?.map( ( ele ) => ele?.value ) ];
2023
+ let data = {
2024
+ storeName: getchecklist[0].storeName,
2025
+ flagCount: updateData.questionFlag,
2026
+ checklistName: getchecklist[0].checkListName?.trim(),
2027
+ submittedBy: getchecklist[0].userName,
2028
+ time: updateData.submitMobileTime,
2029
+ domain: `${JSON.parse( process.env.URL ).domain}/manage/trax/flags`,
2039
2030
  };
2040
- sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
2041
- } );
2031
+ const fileContent = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/flag.hbs', 'utf8' );
2032
+ const htmlContent = handlebars.compile( fileContent );
2033
+ const html = htmlContent( { data: data } );
2034
+ emailList.forEach( ( email ) => {
2035
+ let params = {
2036
+ toEmail: email,
2037
+ mailSubject: 'TangoEye | Checklist Flag',
2038
+ htmlBody: html,
2039
+ attachment: '',
2040
+ sourceEmail: JSON.parse( process.env.SES ).adminEmail,
2041
+ };
2042
+ sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
2043
+ } );
2044
+ }
2042
2045
  }
2043
2046
  }
2044
2047
 
@@ -3294,6 +3297,7 @@ export async function questionList( req, res ) {
3294
3297
  videoUploadTimeLimit: { $ifNull: [ '$videoUploadTimeLimit', 0 ] },
3295
3298
  taskType: { $ifNull: [ '$planoType', '' ] },
3296
3299
  streamId: { $ifNull: [ '$streamId', '' ] },
3300
+ export: { $ifNull: [ '$export', '' ] },
3297
3301
  },
3298
3302
  } );
3299
3303
 
@@ -293,9 +293,9 @@ export const checklistPerformance = async ( req, res ) => {
293
293
 
294
294
  let complianceURL = 'https://h5gwudrwylz65s4vb6h2evwxeq0kkjog.lambda-url.ap-south-1.on.aws/';
295
295
  const complianceData = await LamdaServiceCall( complianceURL, detectionPayload );
296
- if ( complianceData ) {
296
+ if ( complianceData?.data?.length && requestData?.sortColumnName == 'questionCompliance' ) {
297
297
  const end = skip + requestData?.limit;
298
- checklistIdList = complianceData.slice( skip, end )?.map( ( ele ) => ele?.checklistId );
298
+ checklistIdList = complianceData.data.slice( skip, end )?.map( ( ele ) => ele?.sourceCheckList_id );
299
299
  }
300
300
 
301
301
 
@@ -446,16 +446,17 @@ export const checklistPerformance = async ( req, res ) => {
446
446
  },
447
447
  } );
448
448
  let getChecklistPerformanceData = await processedchecklistService.aggregate( findQuery );
449
+ console.log( getChecklistPerformanceData );
449
450
  if ( !getChecklistPerformanceData[0].data.length ) {
450
451
  return res.sendError( 'no data found', 204 );
451
452
  }
452
453
 
453
- getChecklistPerformanceData.forEach( ( ele ) => {
454
+ getChecklistPerformanceData?.[0]?.data.forEach( ( ele ) => {
454
455
  let findCompliance;
455
- if ( complianceData ) {
456
- findCompliance = complianceData?.find( ( data ) => data.checklistId == ele?.sourceCheckList_id );
456
+ if ( complianceData?.data?.length ) {
457
+ findCompliance = complianceData?.data?.find( ( data ) => data.sourceCheckList_id == ele?.sourceCheckList_id );
457
458
  }
458
- ele['questionComplianceRate'] = findCompliance?.compliance ?? 0;
459
+ ele['questionComplianceRate'] = findCompliance?.compliancePercentage ?? 0;
459
460
  } );
460
461
 
461
462
  if ( requestData.export ) {