tango-app-api-trax 3.7.13-qid-halfshutter-13 → 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-13",
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.11",
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
+ }
@@ -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