tango-app-api-trax 3.3.1-hotfix-6 → 3.4.1-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.3.1-hotfix-6",
3
+ "version": "3.4.1-alpha-2",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -205,15 +205,17 @@ export async function startChecklist( req, res ) {
205
205
  },
206
206
  } );
207
207
  let getupdatedchecklist = await processedchecklist.aggregate( findQuery );
208
- let bucket = JSON.parse( process.env.BUCKET );
208
+ // let bucket = JSON.parse( process.env.BUCKET );
209
209
  getupdatedchecklist[0].questionAnswers.forEach( ( section ) => {
210
210
  section.questions.forEach( async ( question ) => {
211
211
  if ( question.questionReferenceImage && question.questionReferenceImage!='' ) {
212
- question.questionReferenceImage = await signedUrl( { Bucket: bucket.sop, file_path: decodeURIComponent( question.questionReferenceImage ) } );
212
+ question.questionReferenceImage = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + question.questionReferenceImage;
213
+ // question.questionReferenceImage = await signedUrl( { Bucket: bucket.sop, file_path: decodeURIComponent( question.questionReferenceImage ) } );
213
214
  }
214
215
  question.answers.forEach( async ( answer ) => {
215
216
  if ( answer.referenceImage != '' ) {
216
- answer.referenceImage = await signedUrl( { Bucket: bucket.sop, file_path: decodeURIComponent( answer.referenceImage ) } );
217
+ answer.referenceImage = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + answer.referenceImage;
218
+ // answer.referenceImage = await signedUrl( { Bucket: bucket.sop, file_path: decodeURIComponent( answer.referenceImage ) } );
217
219
  }
218
220
  } );
219
221
  } );
@@ -234,30 +236,77 @@ export async function startChecklist( req, res ) {
234
236
  await checklistLogs.create( logInsertData );
235
237
  let getchecklist = getupdatedchecklist;
236
238
  let questions = [];
237
- function processQuestion( question, section, questions, nested=false ) {
238
- let findExists = questions.find( ( item ) => item?.qno && item.qno == question.qno );
239
- if ( findExists && nested ) {
240
- let findIndex = questions.findIndex( ( item ) => item?.qno && item.qno == question.qno );
241
- questions.splice( findIndex, 1 );
242
- questions.push( question );
243
- }
244
- if ( !findExists ) {
245
- questions.push( question );
246
- for ( let answer of question.answers ) {
247
- if ( answer.showLinked && answer?.linkedQuestion != '' ) {
248
- let linkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
249
- if ( linkedQuestion ) {
250
- processQuestion( linkedQuestion, section, questions, true );
251
- }
252
- }
253
- }
254
- }
255
- }
239
+ // function processQuestion( question, section, questions, nested=false ) {
240
+ // let findExists = questions.find( ( item ) => item?.qno && item.qno == question.qno );
241
+ // if ( findExists && nested ) {
242
+ // let findIndex = questions.findIndex( ( item ) => item?.qno && item.qno == question.qno );
243
+ // questions.splice( findIndex, 1 );
244
+ // questions.push( question );
245
+ // }
246
+ // if ( !findExists ) {
247
+ // questions.push( question );
248
+ // for ( let answer of question.answers ) {
249
+ // if ( answer.showLinked && answer?.linkedQuestion != '' ) {
250
+ // let linkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
251
+ // if ( linkedQuestion ) {
252
+ // processQuestion( linkedQuestion, section, questions, true );
253
+ // }
254
+ // }
255
+ // }
256
+ // }
257
+ // }
256
258
  for ( let [ index, data ] of getchecklist.entries() ) {
257
259
  for ( let [ secIndex, section ] of data.questionAnswers.entries() ) {
258
260
  questions = [];
259
261
  for ( let question of section.questions ) {
260
- processQuestion( question, section, questions );
262
+ let linkedQuestions;
263
+ if ( !question.linkType ) {
264
+ question.uniqueNo = parseInt( getOtp() );
265
+ questions.push( question );
266
+ linkedQuestions = [];
267
+ let questionList = new Map( section.questions.map( ( ele ) => [ ele.qno, ele ] ) );
268
+ question.answers.forEach( ( answer ) => {
269
+ if ( answer.linkedQuestion ) {
270
+ let nesedQuestion = [];
271
+ answer.nestedQuestion.forEach( ( qn, qidx ) => {
272
+ let getQn = questionList.get( qn );
273
+ if ( getQn ) {
274
+ let randomNo = parseInt( getOtp() );
275
+ getQn = JSON.parse( JSON.stringify( getQn ) );
276
+ getQn = { ...getQn, uniqueNo: randomNo };
277
+ nesedQuestion.push( getQn );
278
+ if ( answer.linkedQuestion == getQn.qno ) {
279
+ answer.linkedQuestion = randomNo;
280
+ }
281
+ answer.nestedQuestion[qidx] = randomNo;
282
+ }
283
+ } );
284
+ nesedQuestion.forEach( ( ele ) => {
285
+ let nestedLinkqn = [];
286
+ ele.answers.forEach( ( ans ) => {
287
+ console.log( ans );
288
+ console.log( ans.nestedQuestion );
289
+ if ( ans.linkedQuestion ) {
290
+ ans.nestedQuestion.forEach( ( nested, idx ) => {
291
+ let findRandom = nesedQuestion.find( ( qn ) => qn.qno == nested && !nestedLinkqn.includes( qn.uniqueNo ) && !qn.updated );
292
+ if ( findRandom ) {
293
+ if ( ans.linkedQuestion == findRandom.qno ) {
294
+ ans.linkedQuestion = findRandom.uniqueNo;
295
+ }
296
+ ans.nestedQuestion[idx] = findRandom.uniqueNo;
297
+ nestedLinkqn.push( findRandom.uniqueNo );
298
+ }
299
+ } );
300
+ }
301
+ } );
302
+ ele.updated = true;
303
+ } );
304
+ linkedQuestions.push( ...nesedQuestion );
305
+ }
306
+ } );
307
+ questions.push( ...linkedQuestions );
308
+ }
309
+ // processQuestion( question, section, questions );
261
310
  }
262
311
  getchecklist[index].questionAnswers[secIndex].questions = questions;
263
312
  }
@@ -1101,6 +1150,8 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1101
1150
  structure.parentanswer = requestSection[i].parentanswer;
1102
1151
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1103
1152
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1153
+ structure.uniqueqno = requestSection[i]?.uniqueqno;
1154
+ structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1104
1155
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1105
1156
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1106
1157
  if ( qaAnswers[j]?.taskId ) {
@@ -1154,6 +1205,8 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1154
1205
  structure.parentanswer = requestSection[i].parentanswer;
1155
1206
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1156
1207
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1208
+ structure.uniqueqno = requestSection[i]?.uniqueqno;
1209
+ structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1157
1210
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1158
1211
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1159
1212
  if ( qaAnswers[j]?.taskId ) {
@@ -1213,6 +1266,8 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1213
1266
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1214
1267
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1215
1268
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1269
+ structure.uniqueqno = requestSection[i]?.uniqueqno;
1270
+ structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1216
1271
  if ( qaAnswers[j]?.taskId ) {
1217
1272
  structure.taskId = qaAnswers[j]?.taskId;
1218
1273
  structure.task = true;
@@ -1273,6 +1328,8 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1273
1328
  structure.parentanswer = requestSection[i].parentanswer;
1274
1329
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1275
1330
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1331
+ structure.uniqueqno = requestSection[i]?.uniqueqno;
1332
+ structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1276
1333
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1277
1334
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1278
1335
  if ( qaAnswers[j]?.taskId ) {
@@ -1333,6 +1390,8 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
1333
1390
  structure.parentanswer = requestSection[i].parentanswer;
1334
1391
  structure.questionReferenceImage = qaAnswers[j].questionReferenceImage;
1335
1392
  structure.descriptivetype = qaAnswers[j].descriptivetype;
1393
+ structure.uniqueqno = requestSection[i]?.uniqueqno;
1394
+ structure.nestedlinkedQuestion = requestSection[i]?.nestedlinkedQuestion;
1336
1395
  // structure.parentQuestion = requestSection[i]?.parentQuestion || qaAnswers[j].qno;
1337
1396
  structure.oldQname = qaAnswers[j]?.oldQname || qaAnswers[j].qname;
1338
1397
  if ( qaAnswers[j]?.taskId ) {
@@ -2565,19 +2624,21 @@ export async function questionList( req, res ) {
2565
2624
  return res.sendError( 'Check List Got Edited Please Fill Again', 422 );
2566
2625
  } else {
2567
2626
  logger.info( `v5 => Checklist Continue => store Name: ${getchecklist[0].storeName}, User Email: ${getchecklist[0].userEmail}, Checklist Name: ${getchecklist[0].checkListName}` );
2568
- let bucket = JSON.parse( process.env.BUCKET );
2627
+ // let bucket = JSON.parse( process.env.BUCKET );
2569
2628
  for ( let [ secIndex, section ] of getchecklist[0].questionAnswers.entries() ) {
2570
2629
  for ( let [ questionIndex, question ] of section.questions.entries() ) {
2571
2630
  let Multianswer = [];
2572
2631
  if ( getchecklist[0].questionAnswers[secIndex].questions[questionIndex].questionReferenceImage && getchecklist[0].questionAnswers[secIndex].questions[questionIndex].questionReferenceImage !='' ) {
2573
- getchecklist[0].questionAnswers[secIndex].questions[questionIndex].questionReferenceImage = await signedUrl( { file_path: decodeURIComponent( getchecklist[0].questionAnswers[secIndex].questions[questionIndex].questionReferenceImage ), Bucket: bucket.sop } );
2632
+ // getchecklist[0].questionAnswers[secIndex].questions[questionIndex].questionReferenceImage = await signedUrl( { file_path: decodeURIComponent( getchecklist[0].questionAnswers[secIndex].questions[questionIndex].questionReferenceImage ), Bucket: bucket.sop } );
2633
+ getchecklist[0].questionAnswers[secIndex].questions[questionIndex].questionReferenceImage = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + getchecklist[0].questionAnswers[secIndex].questions[questionIndex].questionReferenceImage;
2574
2634
  }
2575
2635
  for ( let [ ansIndex, answer ] of question.answers.entries() ) {
2576
2636
  if ( question.answerType == 'multiplechoicemultiple' ) {
2577
2637
  let checkvalidation = null;
2578
2638
  if ( answer.validationAnswer && answer.validationAnswer !='' ) {
2579
2639
  if ( answer.validationType != 'Descriptive Answer' ) {
2580
- checkvalidation = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
2640
+ // checkvalidation = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
2641
+ checkvalidation = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + answer.validationAnswer;
2581
2642
  } else {
2582
2643
  checkvalidation = answer.validationAnswer;
2583
2644
  }
@@ -2586,22 +2647,27 @@ export async function questionList( req, res ) {
2586
2647
  getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
2587
2648
  }
2588
2649
  if ( answer.referenceImage != '' ) {
2589
- getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].referenceImage = await signedUrl( { file_path: decodeURIComponent( answer.referenceImage ), Bucket: bucket.sop } );
2650
+ // getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].referenceImage = await signedUrl( { file_path: decodeURIComponent( answer.referenceImage ), Bucket: bucket.sop } );
2651
+ getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].referenceImage = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + answer.referenceImage;
2590
2652
  }
2591
2653
  if ( ( answer.validationType == 'Capture Image' || answer.validationType == 'Capture Video' ) && answer.validationAnswer && answer.validationAnswer != '' ) {
2592
- getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].validationAnswer = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
2654
+ // getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].validationAnswer = await signedUrl( { file_path: decodeURIComponent( answer.validationAnswer ), Bucket: bucket.sop } );
2655
+ getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].validationAnswer = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + answer.validationAnswer;
2593
2656
  }
2594
2657
  }
2595
2658
  if ( question?.userAnswer ) {
2596
2659
  for ( let [ userAnsIndex, userAns ] of question.userAnswer.entries() ) {
2597
2660
  if ( ( userAns.validationType == 'Capture Image' || userAns.validationType == 'Capture Video' ) && userAns.validationAnswer && userAns.validationAnswer != '' ) {
2598
- getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationAnswer = await signedUrl( { file_path: decodeURIComponent( userAns.validationAnswer ), Bucket: bucket.sop } );
2661
+ // getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationAnswer = await signedUrl( { file_path: decodeURIComponent( userAns.validationAnswer ), Bucket: bucket.sop } );
2662
+ getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].validationAnswer = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + userAns.validationAnswer;
2599
2663
  }
2600
2664
  if ( [ 'image', 'descriptiveImage', 'video' ].includes( question.answerType ) && userAns.answer != '' ) {
2601
- getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer = await signedUrl( { file_path: decodeURIComponent( userAns.answer ), Bucket: bucket.sop } );
2665
+ // getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer = await signedUrl( { file_path: decodeURIComponent( userAns.answer ), Bucket: bucket.sop } );
2666
+ getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].answer = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + userAns.answer;
2602
2667
  }
2603
2668
  if ( userAns.referenceImage != '' ) {
2604
- getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].referenceImage = await signedUrl( { file_path: decodeURIComponent( userAns.referenceImage ), Bucket: bucket.sop } );
2669
+ // getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].referenceImage = await signedUrl( { file_path: decodeURIComponent( userAns.referenceImage ), Bucket: bucket.sop } );
2670
+ getchecklist[0].questionAnswers[secIndex].questions[questionIndex].userAnswer[userAnsIndex].referenceImage = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + userAns.referenceImage;
2605
2671
  }
2606
2672
  if ( question.answerType == 'multiplechoicemultiple' ) {
2607
2673
  let ansIndex = Multianswer.findIndex( ( item ) => item.answer == userAns.answer );
@@ -2611,7 +2677,8 @@ export async function questionList( req, res ) {
2611
2677
  }
2612
2678
  if ( question.answerType == 'multipleImage' ) {
2613
2679
  if ( userAns && userAns.answer && userAns.answer !='' ) {
2614
- let manswer = await signedUrl( { file_path: decodeURIComponent( userAns.answer ), Bucket: bucket.sop } );
2680
+ // let manswer = await signedUrl( { file_path: decodeURIComponent( userAns.answer ), Bucket: bucket.sop } );
2681
+ let manswer = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + userAns.answer;
2615
2682
  Multianswer.push( { 'answer': manswer, 'no': userAnsIndex, 'validationAnswer': '' } );
2616
2683
  } else {
2617
2684
 
@@ -2643,38 +2710,84 @@ export async function questionList( req, res ) {
2643
2710
  }
2644
2711
 
2645
2712
  let questions = [];
2646
- function processQuestion( question, section, questions, nested=false ) {
2647
- let findExists = questions.find( ( item ) => item?.qno && item.qno == question.qno );
2648
- if ( findExists && nested ) {
2649
- let findIndex = questions.findIndex( ( item ) => item?.qno && item.qno == question.qno );
2650
- questions.splice( findIndex, 1 );
2651
- questions.push( question );
2652
- for ( let answer of question.answers ) {
2653
- if ( answer.showLinked && answer?.linkedQuestion != '' ) {
2654
- let linkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
2655
- if ( linkedQuestion ) {
2656
- processQuestion( linkedQuestion, section, questions, true );
2657
- }
2658
- }
2659
- }
2660
- }
2661
- if ( !findExists ) {
2662
- questions.push( question );
2663
- for ( let answer of question.answers ) {
2664
- if ( answer.showLinked && answer?.linkedQuestion != '' ) {
2665
- let linkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
2666
- if ( linkedQuestion ) {
2667
- processQuestion( linkedQuestion, section, questions, true );
2668
- }
2669
- }
2670
- }
2671
- }
2672
- }
2713
+ // function processQuestion( question, section, questions, nested=false ) {
2714
+ // let findExists = questions.find( ( item ) => item?.qno && item.qno == question.qno );
2715
+ // if ( findExists && nested ) {
2716
+ // let findIndex = questions.findIndex( ( item ) => item?.qno && item.qno == question.qno );
2717
+ // questions.splice( findIndex, 1 );
2718
+ // questions.push( question );
2719
+ // for ( let answer of question.answers ) {
2720
+ // if ( answer.showLinked && answer?.linkedQuestion != '' ) {
2721
+ // let linkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
2722
+ // if ( linkedQuestion ) {
2723
+ // processQuestion( linkedQuestion, section, questions, true );
2724
+ // }
2725
+ // }
2726
+ // }
2727
+ // }
2728
+ // if ( !findExists ) {
2729
+ // questions.push( question );
2730
+ // for ( let answer of question.answers ) {
2731
+ // if ( answer.showLinked && answer?.linkedQuestion != '' ) {
2732
+ // let linkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
2733
+ // if ( linkedQuestion ) {
2734
+ // processQuestion( linkedQuestion, section, questions, true );
2735
+ // }
2736
+ // }
2737
+ // }
2738
+ // }
2739
+ // }
2740
+
2673
2741
  for ( let [ index, data ] of getchecklist.entries() ) {
2674
2742
  for ( let [ secIndex, section ] of data.questionAnswers.entries() ) {
2675
2743
  questions = [];
2676
2744
  for ( let question of section.questions ) {
2677
- processQuestion( question, section, questions );
2745
+ let linkedQuestions;
2746
+ if ( !question.linkType ) {
2747
+ question.uniqueNo = parseInt( getOtp() );
2748
+ questions.push( question );
2749
+ linkedQuestions = [];
2750
+ let questionList = new Map( section.questions.map( ( ele ) => [ ele.qno, ele ] ) );
2751
+ question.answers.forEach( ( answer ) => {
2752
+ if ( answer.linkedQuestion ) {
2753
+ let nesedQuestion = [];
2754
+ answer.nestedQuestion.forEach( ( qn, qidx ) => {
2755
+ let getQn = questionList.get( qn );
2756
+ if ( getQn ) {
2757
+ let randomNo = parseInt( getOtp() );
2758
+ getQn = JSON.parse( JSON.stringify( getQn ) );
2759
+ getQn = { ...getQn, uniqueNo: randomNo };
2760
+ nesedQuestion.push( getQn );
2761
+ if ( answer.linkedQuestion == getQn.qno ) {
2762
+ answer.linkedQuestion = randomNo;
2763
+ }
2764
+ answer.nestedQuestion[qidx] = randomNo;
2765
+ }
2766
+ } );
2767
+ nesedQuestion.forEach( ( ele ) => {
2768
+ let nestedLinkqn = [];
2769
+ ele.answers.forEach( ( ans ) => {
2770
+ if ( ans.linkedQuestion ) {
2771
+ ans.nestedQuestion.forEach( ( nested, idx ) => {
2772
+ let findRandom = nesedQuestion.find( ( qn ) => qn.qno == nested && !nestedLinkqn.includes( qn.uniqueNo ) && !qn.updated );
2773
+ if ( findRandom ) {
2774
+ if ( ans.linkedQuestion == findRandom.qno ) {
2775
+ ans.linkedQuestion = findRandom.uniqueNo;
2776
+ }
2777
+ ans.nestedQuestion[idx] = findRandom.uniqueNo;
2778
+ nestedLinkqn.push( findRandom.uniqueNo );
2779
+ }
2780
+ } );
2781
+ }
2782
+ } );
2783
+ ele.updated = true;
2784
+ } );
2785
+ linkedQuestions.push( ...nesedQuestion );
2786
+ }
2787
+ } );
2788
+ questions.push( ...linkedQuestions );
2789
+ }
2790
+ // processQuestion( question, section, questions );
2678
2791
  }
2679
2792
  getchecklist[index].questionAnswers[secIndex].questions = questions;
2680
2793
  }
@@ -3086,10 +3199,12 @@ export async function uploadAnswerImage( req, res ) {
3086
3199
  }
3087
3200
 
3088
3201
  if ( imageUrl != '' ) {
3089
- imageUrl = await signedUrl( { file_path: imageUrl.Key, Bucket: bucket.sop } );
3202
+ // imageUrl = await signedUrl( { file_path: imageUrl.Key, Bucket: bucket.sop } );
3203
+ imageUrl = JSON.parse( process.env.CDNURL )?.TraxAnswerCDN + imageUrl.Key;
3090
3204
 
3091
3205
  return res.sendSuccess( {
3092
3206
  bucketName: bucket.sop,
3207
+ path: imageUrl.Key,
3093
3208
  imageUrl: imageUrl,
3094
3209
  message: 'Image uploaded successfully!',
3095
3210
  } );
@@ -2492,10 +2492,6 @@ export const flagChecklistTableV1 = async ( req, res ) => {
2492
2492
  if ( resultData ) {
2493
2493
  if ( resultData.status_code == '200' ) {
2494
2494
  const exportdata = [];
2495
- console.log( resultData );
2496
- if ( reqestData.ChecklistType==='scrum'||reqestData.ChecklistType==='cleaning' ) {
2497
- reqestData.ChecklistType = 'scrumdetection';
2498
- }
2499
2495
  resultData[reqestData.ChecklistType + 'Data'].forEach( ( element ) => {
2500
2496
  exportdata.push( {
2501
2497
  'Date': element?.date,
@@ -247,14 +247,15 @@ export const create = async ( req, res ) => {
247
247
  section.questions[qIdx].answers[index].nestedQuestion = [];
248
248
  }
249
249
  if ( answer.showLinked ) {
250
+ // section.questions[qIdx].answers[nestedIndex].nestedQuestion.push( answer.linkedQuestion );
250
251
  if ( nestedIndex != -1 ) {
251
- if ( !section.questions[qIdx].answers[nestedIndex].nestedQuestion.includes( answer.linkedQuestion ) ) {
252
- section.questions[qIdx].answers[nestedIndex].nestedQuestion.push( answer.linkedQuestion );
253
- }
252
+ // if ( !section.questions[qIdx].answers[nestedIndex].nestedQuestion.includes( answer.linkedQuestion ) ) {
253
+ section.questions[qIdx].answers[nestedIndex].nestedQuestion.push( answer.linkedQuestion );
254
+ // }
254
255
  } else {
255
- if ( !section.questions[qIdx].answers[index].nestedQuestion.includes( answer.linkedQuestion ) ) {
256
- section.questions[qIdx].answers[index].nestedQuestion.push( answer.linkedQuestion );
257
- }
256
+ // if ( !section.questions[qIdx].answers[index].nestedQuestion.includes( answer.linkedQuestion ) ) {
257
+ section.questions[qIdx].answers[index].nestedQuestion.push( answer.linkedQuestion );
258
+ // }
258
259
  }
259
260
  let nestedLinkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
260
261
  if ( nestedLinkedQuestion ) {
@@ -286,6 +287,7 @@ export const create = async ( req, res ) => {
286
287
  return res.sendSuccess( { checklistId: checkListId, msg: 'CheckList Created Successfully' } );
287
288
  }
288
289
  } ).catch( ( e ) => {
290
+ console.log( e );
289
291
  return res.sendError( e, 500 );
290
292
  } );
291
293
  }
@@ -295,6 +297,7 @@ export const create = async ( req, res ) => {
295
297
  }
296
298
  }
297
299
  } ).catch( async ( e ) => {
300
+ console.log( e );
298
301
  await checklistService.deleteOne( { _id: checkListId } );
299
302
  return res.sendError( e, 500 );
300
303
  } );
@@ -777,13 +780,13 @@ export const update = async ( req, res ) => {
777
780
  }
778
781
  if ( answer.showLinked ) {
779
782
  if ( nestedIndex != -1 ) {
780
- if ( !section.questions[qIdx].answers[nestedIndex].nestedQuestion.includes( answer.linkedQuestion ) ) {
781
- section.questions[qIdx].answers[nestedIndex].nestedQuestion.push( answer.linkedQuestion );
782
- }
783
+ // if ( !section.questions[qIdx].answers[nestedIndex].nestedQuestion.includes( answer.linkedQuestion ) ) {
784
+ section.questions[qIdx].answers[nestedIndex].nestedQuestion.push( answer.linkedQuestion );
785
+ // }
783
786
  } else {
784
- if ( !section.questions[qIdx].answers[index].nestedQuestion.includes( answer.linkedQuestion ) ) {
785
- section.questions[qIdx].answers[index].nestedQuestion.push( answer.linkedQuestion );
786
- }
787
+ // if ( !section.questions[qIdx].answers[index].nestedQuestion.includes( answer.linkedQuestion ) ) {
788
+ section.questions[qIdx].answers[index].nestedQuestion.push( answer.linkedQuestion );
789
+ // }
787
790
  }
788
791
  let nestedLinkedQuestion = section.questions.find( ( item ) => item.qno == answer.linkedQuestion );
789
792
  if ( nestedLinkedQuestion ) {