tango-app-api-trax 3.7.13-qid-halfshutter-13 → 3.7.13-qid-halfshutter-15
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-
|
|
3
|
+
"version": "3.7.13-qid-halfshutter-15",
|
|
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.
|
|
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",
|
|
@@ -2624,3 +2624,64 @@ export async function getRunAIQuestions( req, res ) {
|
|
|
2624
2624
|
return res.sendError( e, 500 );
|
|
2625
2625
|
}
|
|
2626
2626
|
}
|
|
2627
|
+
|
|
2628
|
+
export async function getRunAIList( req, res ) {
|
|
2629
|
+
try {
|
|
2630
|
+
let getChecklistDetails = await CLconfig.find( { publish: true, ...( req.query.clientId && { client_id: req.query.clientId } ) } );
|
|
2631
|
+
if ( !getChecklistDetails.length ) {
|
|
2632
|
+
return res.sendError( 'No data found', 204 );
|
|
2633
|
+
}
|
|
2634
|
+
let runAIList=[];
|
|
2635
|
+
await Promise.all( getChecklistDetails.map( async ( check ) => {
|
|
2636
|
+
let getQuestionList = await CLquestions.find( { checkListId: check._id } );
|
|
2637
|
+
if ( getQuestionList.length ) {
|
|
2638
|
+
getQuestionList.forEach( ( sec ) => {
|
|
2639
|
+
sec.question.forEach( ( qn ) => {
|
|
2640
|
+
if ( qn.answers.some( ( ele ) => ele.runAI ) ) {
|
|
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
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
} );
|
|
2649
|
+
} );
|
|
2650
|
+
}
|
|
2651
|
+
} ) );
|
|
2652
|
+
return res.sendSuccess( Array.from( runAIList ) );
|
|
2653
|
+
} catch ( e ) {
|
|
2654
|
+
logger.error( { functionName: 'getRunAIList', error: e } );
|
|
2655
|
+
return res.sendError( e, 500 );
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
export async function updateChecklistConfig( req, res ) {
|
|
2660
|
+
try {
|
|
2661
|
+
if ( req.body.type == 'checklist' ) {
|
|
2662
|
+
let checklistDetails = await CLconfig.findOne( { _id: req.body.id } );
|
|
2663
|
+
if ( !checklistDetails ) {
|
|
2664
|
+
return res.sendError( 'No data found', 204 );
|
|
2665
|
+
}
|
|
2666
|
+
await CLconfig.updateOne( { _id: req.body.id }, req.body.data );
|
|
2667
|
+
|
|
2668
|
+
if ( req.body?.updateStore ) {
|
|
2669
|
+
await processedchecklist.updateMany( { date_string: dayjs().format( 'YYYY-MM-DD' ), sourceCheckList_id: req.body.id, ...( req.body.store?.length && { storeName: { $in: req.body.store } } ) }, req.body.data );
|
|
2670
|
+
}
|
|
2671
|
+
} else {
|
|
2672
|
+
let taskDetails = await taskService.findOne( { _id: req.body.id } );
|
|
2673
|
+
if ( !taskDetails ) {
|
|
2674
|
+
return res.sendError( 'No data found', 204 );
|
|
2675
|
+
}
|
|
2676
|
+
await taskService.updateOne( { _id: req.body.id }, req.body.data );
|
|
2677
|
+
|
|
2678
|
+
if ( req.body?.updateStore ) {
|
|
2679
|
+
await processedTaskService.updateMany( { date_string: dayjs().format( 'YYYY-MM-DD' ), sourceCheckList_id: req.body.id, ...( req.body.store?.length && { storeName: { $in: req.body.store } } ) }, req.body.data );
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
return res.sendSuccess( 'updated successfully' );
|
|
2683
|
+
} catch ( e ) {
|
|
2684
|
+
logger.error( { functionName: 'updateChecklist', error: e } );
|
|
2685
|
+
return res.sendError( e, 500 );
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
@@ -4389,3 +4389,57 @@ export async function questionListV1( req, res ) {
|
|
|
4389
4389
|
}
|
|
4390
4390
|
}
|
|
4391
4391
|
|
|
4392
|
+
export async function chunkUpload( req, res ) {
|
|
4393
|
+
try {
|
|
4394
|
+
const { chunkIndex, totalChunks } = req.body;
|
|
4395
|
+
if ( chunkIndex === undefined || !totalChunks || !req.files || !req.files.answerImage ) {
|
|
4396
|
+
return res.status( 400 ).json( { error: 'Missing required params or file.' } );
|
|
4397
|
+
}
|
|
4398
|
+
const chunkNum = Number( chunkIndex );
|
|
4399
|
+
const chunkTotal = Number( totalChunks );
|
|
4400
|
+
const chunkFile = req.files.answerImage;
|
|
4401
|
+
const chunkKey = `traxVideoChunks/${req.user._id}/${chunkNum}`;
|
|
4402
|
+
let bucket;
|
|
4403
|
+
try {
|
|
4404
|
+
bucket = JSON.parse( process.env.BUCKET )?.sop;
|
|
4405
|
+
} catch {
|
|
4406
|
+
return res.sendError( 'Bucket config error', 500 );
|
|
4407
|
+
}
|
|
4408
|
+
await fileUpload( {
|
|
4409
|
+
fileName: '',
|
|
4410
|
+
Key: chunkKey,
|
|
4411
|
+
Bucket: bucket,
|
|
4412
|
+
ContentType: chunkFile.mimetype,
|
|
4413
|
+
body: chunkFile.data,
|
|
4414
|
+
} );
|
|
4415
|
+
if ( chunkNum < chunkTotal ) {
|
|
4416
|
+
return res.sendSuccess( { message: 'Chunk uploaded to S3', chunkIndex: chunkNum } );
|
|
4417
|
+
}
|
|
4418
|
+
const prefix = `traxVideoChunks/${req.user._id}/`;
|
|
4419
|
+
const s3FilesResp = await listFileByPath( { Bucket: bucket, file_path: prefix, MaxKeys: chunkTotal } );
|
|
4420
|
+
const chunkObjs = s3FilesResp?.data || [];
|
|
4421
|
+
chunkObjs.sort( ( a, b ) => {
|
|
4422
|
+
const ai = Number( a.Key.split( '/' ).pop() );
|
|
4423
|
+
const bi = Number( b.Key.split( '/' ).pop() );
|
|
4424
|
+
return ai - bi;
|
|
4425
|
+
} );
|
|
4426
|
+
const buffers = [];
|
|
4427
|
+
for ( const obj of chunkObjs ) {
|
|
4428
|
+
const s3Obj = await getObject( { Bucket: bucket, Key: obj.Key } );
|
|
4429
|
+
buffers.push( Buffer.from( s3Obj.Body ) );
|
|
4430
|
+
}
|
|
4431
|
+
const finalBuffer = Buffer.concat( buffers );
|
|
4432
|
+
try {
|
|
4433
|
+
await deleteFiles( bucket, prefix );
|
|
4434
|
+
} catch ( e ) {}
|
|
4435
|
+
req.files.answerImage = {
|
|
4436
|
+
data: finalBuffer,
|
|
4437
|
+
name: chunkFile.name,
|
|
4438
|
+
mimetype: chunkFile.mimetype,
|
|
4439
|
+
};
|
|
4440
|
+
return uploadAnswerImage( req, res );
|
|
4441
|
+
} catch ( e ) {
|
|
4442
|
+
logger.error( { functionName: 'chunkUpload', error: e } );
|
|
4443
|
+
return res.sendError( e, 500 );
|
|
4444
|
+
}
|
|
4445
|
+
}
|
|
@@ -28,6 +28,8 @@ internalTraxRouter
|
|
|
28
28
|
.post( '/insertAINotification', isAllowedInternalAPIHandler, internalController.insertAINotification )
|
|
29
29
|
.post( '/updateRunAI', isAllowedInternalAPIHandler, internalController.updateRunAI )
|
|
30
30
|
.post( '/countUpdateRunAI', isAllowedInternalAPIHandler, internalController.countUpdateRunAI )
|
|
31
|
-
.post( '/getRunAIQuestions', isAllowedInternalAPIHandler, internalController.getRunAIQuestions )
|
|
31
|
+
.post( '/getRunAIQuestions', isAllowedInternalAPIHandler, internalController.getRunAIQuestions )
|
|
32
|
+
.get( '/getRunAIList', isAllowedInternalAPIHandler, internalController.getRunAIList )
|
|
33
|
+
.post( '/updateChecklistConfig', isAllowedInternalAPIHandler, internalController.updateChecklistConfig );
|
|
32
34
|
|
|
33
35
|
|
|
@@ -29,5 +29,6 @@ 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 )
|
|
32
|
+
.post( '/updatePlanoStatus', isAllowedSessionHandler, mobileController.updatePlanoStatus )
|
|
33
|
+
.post( '/chunkUpload', isAllowedSessionHandler, mobileController.chunkUpload );
|
|
33
34
|
|