tango-app-api-trax 3.7.13-qid-halfshutter-8 → 3.7.13-qid-halfshutter-9
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
|
@@ -2623,3 +2623,47 @@ export async function getRunAIQuestions( req, res ) {
|
|
|
2623
2623
|
return res.sendError( e, 500 );
|
|
2624
2624
|
}
|
|
2625
2625
|
}
|
|
2626
|
+
|
|
2627
|
+
export async function getRunAIList( req, res ) {
|
|
2628
|
+
try {
|
|
2629
|
+
let getChecklistDetails = await CLconfig.find( { publish: true } );
|
|
2630
|
+
if ( !getChecklistDetails.length ) {
|
|
2631
|
+
return res.sendError( 'No data found', 204 );
|
|
2632
|
+
}
|
|
2633
|
+
let runAIList=new Set();
|
|
2634
|
+
await Promise.all( getChecklistDetails.map( async ( check ) => {
|
|
2635
|
+
let getQuestionList = await CLquestions.find( { checkListId: check._id } );
|
|
2636
|
+
if ( getQuestionList.length ) {
|
|
2637
|
+
getQuestionList.forEach( ( sec ) => {
|
|
2638
|
+
sec.question.forEach( ( qn ) => {
|
|
2639
|
+
if ( qn.answers.some( ( ele ) => ele.runAI ) ) {
|
|
2640
|
+
runAIList.add( check._id );
|
|
2641
|
+
}
|
|
2642
|
+
} );
|
|
2643
|
+
} );
|
|
2644
|
+
}
|
|
2645
|
+
} ) );
|
|
2646
|
+
return res.sendSuccess( Array.from( runAIList ) );
|
|
2647
|
+
} catch ( e ) {
|
|
2648
|
+
logger.error( { functionName: 'getRunAIList', error: e } );
|
|
2649
|
+
return res.sendError( e, 500 );
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
export async function updateChecklistConfig( req, res ) {
|
|
2654
|
+
try {
|
|
2655
|
+
let checklistDetails = await CLconfig.findOne( { _id: req.body.id } );
|
|
2656
|
+
if ( !checklistDetails ) {
|
|
2657
|
+
return res.sendError( 'No data found', 204 );
|
|
2658
|
+
}
|
|
2659
|
+
await CLconfig.updateOne( { _id: req.body.id }, req.body.data );
|
|
2660
|
+
|
|
2661
|
+
if ( req.body?.updateStore ) {
|
|
2662
|
+
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 );
|
|
2663
|
+
}
|
|
2664
|
+
return res.sendSuccess( 'updated successfully' );
|
|
2665
|
+
} catch ( e ) {
|
|
2666
|
+
logger.error( { functionName: 'updateChecklist', error: e } );
|
|
2667
|
+
return res.sendError( e, 500 );
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
@@ -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
|
|