tango-app-api-trax 3.7.13-qid-halfshutter-12 → 3.7.13-qid-halfshutter-14

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.13-qid-halfshutter-12",
3
+ "version": "3.7.13-qid-halfshutter-14",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "mongodb": "^6.8.0",
28
28
  "nodemon": "^3.1.4",
29
29
  "path": "^0.12.7",
30
- "tango-api-schema": "^2.4.15",
30
+ "tango-api-schema": "^2.4.20",
31
31
  "tango-app-api-middleware": "^3.5.2",
32
32
  "url": "^0.11.4",
33
33
  "winston": "^3.13.1",
@@ -290,6 +290,7 @@ export async function PCLconfigCreation( req, res ) {
290
290
  insertdata.rawImageUpload = getCLconfig.rawImageUpload || false;
291
291
  insertdata.rawVideoUpload = getCLconfig.rawVideoUpload || false;
292
292
  insertdata.videoUploadTimeLimit = getCLconfig.videoUploadTimeLimit || 0;
293
+ insertdata.coverage = getCLconfig?.coverage ?? 'store';
293
294
  let collectSections = [];
294
295
  let sectionQuery = [];
295
296
  sectionQuery.push( {
@@ -2626,18 +2627,23 @@ export async function getRunAIQuestions( req, res ) {
2626
2627
 
2627
2628
  export async function getRunAIList( req, res ) {
2628
2629
  try {
2629
- let getChecklistDetails = await CLconfig.find( { publish: true } );
2630
+ let getChecklistDetails = await CLconfig.find( { publish: true, ...( req.query.clientId && { client_id: req.query.clientId } ) } );
2630
2631
  if ( !getChecklistDetails.length ) {
2631
2632
  return res.sendError( 'No data found', 204 );
2632
2633
  }
2633
- let runAIList=new Set();
2634
+ let runAIList=[];
2634
2635
  await Promise.all( getChecklistDetails.map( async ( check ) => {
2635
2636
  let getQuestionList = await CLquestions.find( { checkListId: check._id } );
2636
2637
  if ( getQuestionList.length ) {
2637
2638
  getQuestionList.forEach( ( sec ) => {
2638
2639
  sec.question.forEach( ( qn ) => {
2639
2640
  if ( qn.answers.some( ( ele ) => ele.runAI ) ) {
2640
- runAIList.add( check._id );
2641
+ let checkList = runAIList.findIndex( ( run ) => run.checklist.toString() == check._id.toString() );
2642
+ if ( checkList == -1 ) {
2643
+ runAIList.push( { checklist: check._id, questions: [ qn.uniqueqid ] } );
2644
+ } else {
2645
+ runAIList[checkList].questions.push( qn.uniqueqid );
2646
+ }
2641
2647
  }
2642
2648
  } );
2643
2649
  } );
@@ -1,4 +1,4 @@
1
- import { logger, signedUrl, fileUpload, getOtp, sendEmailWithSES, getUuid, insertOpenSearchData, listFileByPath, getObject, deleteFiles } from 'tango-app-api-middleware';
1
+ import { logger, signedUrl, fileUpload, getOtp, sendEmailWithSES, getUuid, insertOpenSearchData } from 'tango-app-api-middleware';
2
2
  import * as processedchecklist from '../services/processedchecklist.services.js';
3
3
  import * as processedtask from '../services/processedTaskList.service.js';
4
4
  import * as PCLconfig from '../services/processedchecklistconfig.services.js';
@@ -19,6 +19,7 @@ import timeZone from 'dayjs/plugin/timezone.js';
19
19
  import { findOTP, updateOneOTP } from '../services/otp.service.js';
20
20
  import * as clientService from '../services/clients.services.js';
21
21
  import { create } from '../services/authentication.service.js';
22
+ import { readFileSync } from 'fs';
22
23
  import { join } from 'path';
23
24
  import handlebars from 'handlebars';
24
25
  dayjs.extend( customParseFormat );
@@ -3570,9 +3571,6 @@ export async function taskQuestionList( req, res ) {
3570
3571
  userEmail: { $ifNull: [ '$userEmail', '' ] },
3571
3572
  storeName: { $ifNull: [ '$storeName', '' ] },
3572
3573
  redoStatus: { $ifNull: [ '$redoStatus', false ] },
3573
- rawImageUpload: { $ifNull: [ '$rawImageUpload', false ] },
3574
- rawVideoUpload: { $ifNull: [ '$rawVideoUpload', false ] },
3575
- videoUploadTimeLimit: { $ifNull: [ '$videoUploadTimeLimit', 0 ] },
3576
3574
  },
3577
3575
  } );
3578
3576
 
@@ -3774,7 +3772,7 @@ export async function uploadAnswerImage( req, res ) {
3774
3772
  let imageUrl;
3775
3773
  let filePath = `${folder}/${req.user.clientId}/${date}/${input.checklistId}/${input.sectionName.replace( ' ', '' )}/${input.questionNo}/`;
3776
3774
  let params = {
3777
- fileName: `${Date.now()}-${Math.floor( 1000 + Math.random() * 9000 )}-${req.files.answerImage.name}`,
3775
+ fileName: `${Date.now()}-${Math.floor( 1000 + Math.random() * 9000 )}.${req.files.answerImage.name.split( '.' )[1]}`,
3778
3776
  Key: filePath,
3779
3777
  Bucket: bucket.sop,
3780
3778
  body: req.files.answerImage.data,
@@ -4391,58 +4389,3 @@ export async function questionListV1( req, res ) {
4391
4389
  }
4392
4390
  }
4393
4391
 
4394
-
4395
- export async function chunkUpload( req, res ) {
4396
- try {
4397
- const { chunkIndex, totalChunks } = req.body;
4398
- if ( chunkIndex === undefined || !totalChunks || !req.files || !req.files.answerImage ) {
4399
- return res.status( 400 ).json( { error: 'Missing required params or file.' } );
4400
- }
4401
- const chunkNum = Number( chunkIndex );
4402
- const chunkTotal = Number( totalChunks );
4403
- const chunkFile = req.files.answerImage;
4404
- const chunkKey = `traxVideoChunks/${req.user._id}/${chunkNum}`;
4405
- let bucket;
4406
- try {
4407
- bucket = JSON.parse( process.env.BUCKET )?.sop;
4408
- } catch {
4409
- return res.sendError( 'Bucket config error', 500 );
4410
- }
4411
- await fileUpload( {
4412
- fileName: '',
4413
- Key: chunkKey,
4414
- Bucket: bucket,
4415
- ContentType: chunkFile.mimetype,
4416
- body: chunkFile.data,
4417
- } );
4418
- if ( chunkNum < chunkTotal ) {
4419
- return res.sendSuccess( { message: 'Chunk uploaded to S3', chunkIndex: chunkNum } );
4420
- }
4421
- const prefix = `traxVideoChunks/${req.user._id}/`;
4422
- const s3FilesResp = await listFileByPath( { Bucket: bucket, file_path: prefix, MaxKeys: chunkTotal } );
4423
- const chunkObjs = s3FilesResp?.data || [];
4424
- chunkObjs.sort( ( a, b ) => {
4425
- const ai = Number( a.Key.split( '/' ).pop() );
4426
- const bi = Number( b.Key.split( '/' ).pop() );
4427
- return ai - bi;
4428
- } );
4429
- const buffers = [];
4430
- for ( const obj of chunkObjs ) {
4431
- const s3Obj = await getObject( { Bucket: bucket, Key: obj.Key } );
4432
- buffers.push( Buffer.from( s3Obj.Body ) );
4433
- }
4434
- const finalBuffer = Buffer.concat( buffers );
4435
- try {
4436
- await deleteFiles( bucket, prefix );
4437
- } catch ( e ) {}
4438
- req.files.answerImage = {
4439
- data: finalBuffer,
4440
- name: chunkFile.name,
4441
- mimetype: chunkFile.mimetype,
4442
- };
4443
- return uploadAnswerImage( req, res );
4444
- } catch ( e ) {
4445
- logger.error( { functionName: 'chunkUpload', error: e } );
4446
- return res.sendError( e, 500 );
4447
- }
4448
- }
@@ -29,6 +29,5 @@ mobileRouter
29
29
  .post( '/checkUpdateVersion', mobileController.checkVersion )
30
30
  .post( '/checkUpdateVersionv1', mobileController.checkVersionV1 )
31
31
  .post( '/checkClientConfig', isAllowedSessionHandler, mobileController.clientConfig )
32
- .post( '/updatePlanoStatus', isAllowedSessionHandler, mobileController.updatePlanoStatus )
33
- .post( '/chunkUpload', isAllowedSessionHandler, mobileController.chunkUpload );
32
+ .post( '/updatePlanoStatus', isAllowedSessionHandler, mobileController.updatePlanoStatus );
34
33