tango-app-api-trax 3.7.65 → 3.7.67

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.65",
3
+ "version": "3.7.67",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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,32 +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?.notifyType?.users.flatMap( ( 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
- emailList = [ 'hs9628sh@gmail.com' ];
2030
- const fileContent = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/flag.hbs', 'utf8' );
2031
- const htmlContent = handlebars.compile( fileContent );
2032
- const html = htmlContent( { data: data } );
2033
- emailList.forEach( ( email ) => {
2034
- let params = {
2035
- toEmail: email,
2036
- mailSubject: 'TangoEye | Checklist Flag',
2037
- htmlBody: html,
2038
- attachment: '',
2039
- 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,
2027
+ submittedBy: getchecklist[0].userName,
2028
+ time: updateData.submitMobileTime,
2029
+ domain: `${JSON.parse( process.env.URL ).domain}/manage/trax/flags`,
2040
2030
  };
2041
- sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
2042
- } );
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
+ }
2043
2045
  }
2044
2046
  }
2045
2047
 
@@ -3295,6 +3297,7 @@ export async function questionList( req, res ) {
3295
3297
  videoUploadTimeLimit: { $ifNull: [ '$videoUploadTimeLimit', 0 ] },
3296
3298
  taskType: { $ifNull: [ '$planoType', '' ] },
3297
3299
  streamId: { $ifNull: [ '$streamId', '' ] },
3300
+ export: { $ifNull: [ '$export', '' ] },
3298
3301
  },
3299
3302
  } );
3300
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( start, end )?.map( ( ele ) => ele?.checklistId );
298
+ checklistIdList = complianceData.data.slice( skip, end )?.map( ( ele ) => ele?.sourceCheckList_id );
299
299
  }
300
300
 
301
301
 
@@ -450,12 +450,12 @@ export const checklistPerformance = async ( req, res ) => {
450
450
  return res.sendError( 'no data found', 204 );
451
451
  }
452
452
 
453
- getChecklistPerformanceData.forEach( ( ele ) => {
453
+ getChecklistPerformanceData?.[0]?.data.forEach( ( ele ) => {
454
454
  let findCompliance;
455
- if ( complianceData ) {
456
- findCompliance = complianceData?.find( ( data ) => data.checklistId == ele?.sourceCheckList_id );
455
+ if ( complianceData?.data?.length ) {
456
+ findCompliance = complianceData?.data?.find( ( data ) => data.sourceCheckList_id == ele?.sourceCheckList_id );
457
457
  }
458
- ele['questionComplianceRate'] = findCompliance?.compliance ?? 0;
458
+ ele['questionComplianceRate'] = findCompliance?.compliancePercentage ?? 0;
459
459
  } );
460
460
 
461
461
  if ( requestData.export ) {