tango-app-api-trax 3.7.13-qid-halfshutter-7 → 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
|
+
}
|
|
@@ -19,23 +19,13 @@ 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
|
|
23
|
-
import { join, dirname } from 'path';
|
|
22
|
+
import { join } from 'path';
|
|
24
23
|
import handlebars from 'handlebars';
|
|
25
24
|
dayjs.extend( customParseFormat );
|
|
26
25
|
dayjs.extend( timeZone );
|
|
27
26
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore.js';
|
|
28
27
|
import * as cameraService from '../services/camera.service.js';
|
|
29
28
|
dayjs.extend( isSameOrBefore );
|
|
30
|
-
import { fileURLToPath } from 'url';
|
|
31
|
-
const fsp = fs.promises;
|
|
32
|
-
|
|
33
|
-
const __filename = fileURLToPath( import.meta.url );
|
|
34
|
-
const __dirname = dirname( __filename );
|
|
35
|
-
const UPLOAD_DIR = join( __dirname, '/uploads' );
|
|
36
|
-
if ( !fs.existsSync( UPLOAD_DIR ) ) {
|
|
37
|
-
fs.mkdirSync( UPLOAD_DIR, { recursive: true } );
|
|
38
|
-
}
|
|
39
29
|
|
|
40
30
|
export async function storeList( req, res ) {
|
|
41
31
|
try {
|
|
@@ -3781,7 +3771,7 @@ export async function uploadAnswerImage( req, res ) {
|
|
|
3781
3771
|
let imageUrl;
|
|
3782
3772
|
let filePath = `${folder}/${req.user.clientId}/${date}/${input.checklistId}/${input.sectionName.replace( ' ', '' )}/${input.questionNo}/`;
|
|
3783
3773
|
let params = {
|
|
3784
|
-
fileName: `${Date.now()}-${Math.floor( 1000 + Math.random() * 9000 )}
|
|
3774
|
+
fileName: `${Date.now()}-${Math.floor( 1000 + Math.random() * 9000 )}-${req.files.answerImage.name}`,
|
|
3785
3775
|
Key: filePath,
|
|
3786
3776
|
Bucket: bucket.sop,
|
|
3787
3777
|
body: req.files.answerImage.data,
|
|
@@ -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
|
|