tango-app-api-trax 3.7.3-runai-1 → 3.7.3-runai-3
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 +4 -4
- package/src/controllers/internalTrax.controller.js +25 -0
- package/src/controllers/mobileTrax.controller.js +6 -1
- package/src/controllers/teaxFlag.controller.js +20 -3
- package/src/controllers/trax.controller.js +85 -2
- package/src/controllers/traxDashboard.controllers.js +19 -6
- package/src/dtos/validation.dtos.js +1 -0
- package/src/routes/internalTraxApi.router.js +2 -1
- package/src/routes/trax.routes.js +1 -0
- package/src/services/runAIFeatures.services.js +1 -1
- package/src/services/runAIRequest.services.js +8 -0
- package/app.js +0 -56
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.7.3-runai-
|
|
3
|
+
"version": "3.7.3-runai-3",
|
|
4
4
|
"description": "Trax",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"start": "nodemon --exec \"eslint --fix . && node
|
|
8
|
+
"start": "nodemon --exec \"eslint --fix . && node index.js\""
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=18.10.0"
|
|
@@ -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.
|
|
30
|
+
"tango-api-schema": "^2.3.14",
|
|
31
31
|
"tango-app-api-middleware": "^3.1.77",
|
|
32
32
|
"url": "^0.11.4",
|
|
33
33
|
"winston": "^3.13.1",
|
|
@@ -2556,3 +2556,28 @@ export async function updateRunAI( req, res ) {
|
|
|
2556
2556
|
return res.sendError( e, 500 );
|
|
2557
2557
|
}
|
|
2558
2558
|
}
|
|
2559
|
+
|
|
2560
|
+
export async function countUpdateRunAI( req, res ) {
|
|
2561
|
+
try {
|
|
2562
|
+
if ( !req.body.id ) {
|
|
2563
|
+
return res.sendError( 'Checklist id is required', 400 );
|
|
2564
|
+
}
|
|
2565
|
+
if ( !req.body.runAICount ) {
|
|
2566
|
+
return res.sendError( 'runAICount is required', 400 );
|
|
2567
|
+
}
|
|
2568
|
+
let getDetails = await processedchecklist.findOne( { _id: req.body.id } );
|
|
2569
|
+
if ( !getDetails ) {
|
|
2570
|
+
return res.sendError( 'No data found', 204 );
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
let updateData = {
|
|
2574
|
+
runAIFlag: req.body.runAICount,
|
|
2575
|
+
};
|
|
2576
|
+
|
|
2577
|
+
await processedchecklist.updateOne( { _id: req.body.id }, updateData );
|
|
2578
|
+
return res.sendSuccess( 'RunAI Count updated successfully' );
|
|
2579
|
+
} catch ( e ) {
|
|
2580
|
+
logger.error( { functionName: 'updateRunAI', error: e } );
|
|
2581
|
+
return res.sendError( e, 500 );
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
@@ -1334,12 +1334,14 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1334
1334
|
newAnswer.validationType = '';
|
|
1335
1335
|
newAnswer.referenceImage = '';
|
|
1336
1336
|
newAnswer.allowUploadfromGallery = false;
|
|
1337
|
-
newAnswer.runAI = false;
|
|
1338
1337
|
newAnswer.descriptivetype = '';
|
|
1339
1338
|
newAnswer.showLinked = false;
|
|
1340
1339
|
newAnswer.linkedQuestion = 0;
|
|
1341
1340
|
newAnswer.nestedQuestion = [];
|
|
1342
1341
|
newAnswer.index = s;
|
|
1342
|
+
newAnswer.runAI = qaAnswers[j].answers[0]?.runAI || false;
|
|
1343
|
+
newAnswer.runAIFeatures = qaAnswers[j].answers[0]?.runAIFeatures || [];
|
|
1344
|
+
newAnswer.runAIDescription = qaAnswers[j].answers[0]?.runAIDescription || '';
|
|
1343
1345
|
mcmi.push( newAnswer );
|
|
1344
1346
|
}
|
|
1345
1347
|
}
|
|
@@ -1400,6 +1402,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1400
1402
|
multiReferenceImage: qaAnswers[j].answers[0].multiReferenceImage || [],
|
|
1401
1403
|
showLinked: qaAnswers[j].answers[0].showLinked,
|
|
1402
1404
|
linkedQuestion: qaAnswers[j].answers[0].linkedQuestion,
|
|
1405
|
+
runAI: qaAnswers[j].answers[0]?.runAI || false,
|
|
1406
|
+
runAIFeatures: qaAnswers[j]?.answers[0]?.runAIFeatures || [],
|
|
1407
|
+
runAIDescription: qaAnswers[j].answers[0]?.runAIDescription || '',
|
|
1403
1408
|
};
|
|
1404
1409
|
if ( qaAnswers[j].answerType == 'date' ) {
|
|
1405
1410
|
ansstructure.dateRangeType = requestSection[i].dateRangeType || false;
|
|
@@ -3006,7 +3006,9 @@ export const flagTablesV2 = async ( req, res ) => {
|
|
|
3006
3006
|
} else if ( requestData?.filter === 'detection' ) {
|
|
3007
3007
|
findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum' ] } } );
|
|
3008
3008
|
} else if ( requestData?.filter === 'runAI' ) {
|
|
3009
|
-
|
|
3009
|
+
if ( req.body.runAIChecklistName ) {
|
|
3010
|
+
findAndQuery.push( { checkListName: { $in: req.body.runAIChecklistName } } );
|
|
3011
|
+
}
|
|
3010
3012
|
}
|
|
3011
3013
|
|
|
3012
3014
|
findQuery.push( { $match: { $and: findAndQuery } } );
|
|
@@ -3186,7 +3188,7 @@ export const flagTablesV2 = async ( req, res ) => {
|
|
|
3186
3188
|
getChecklistPerformanceData[index].flaggedStores = getChecklistPerformanceData[index].flaggedStores + findCheckList.flagCount;
|
|
3187
3189
|
} else {
|
|
3188
3190
|
getChecklistPerformanceData[index].flagCount = findCheckList.flagCount;
|
|
3189
|
-
getChecklistPerformanceData[index].flaggedStores = findCheckList.
|
|
3191
|
+
getChecklistPerformanceData[index].flaggedStores = findCheckList.flagStoreCount;
|
|
3190
3192
|
}
|
|
3191
3193
|
} else {
|
|
3192
3194
|
if ( requestData?.filter == 'all' ) {
|
|
@@ -3222,22 +3224,28 @@ export const flagTablesV2 = async ( req, res ) => {
|
|
|
3222
3224
|
const data = {
|
|
3223
3225
|
'Checklist Name': element.checkListName,
|
|
3224
3226
|
'Coverage': element?.coverage,
|
|
3227
|
+
'No of Questions': element?.runAIQuestionCount,
|
|
3225
3228
|
'Assigned Stores': element?.checkListType === 'custom' ? element?.assignedStores : element?.assignedStoresAi,
|
|
3226
3229
|
'Flagged Stores': element?.flaggedStores,
|
|
3227
3230
|
'Question Flags': element?.customQuestionFlagCount,
|
|
3228
3231
|
...( element.runAIFlag ? { 'Run AI Flag': element.runAIFlag } : {} ),
|
|
3229
3232
|
'Not Submitted Flags': element?.customTimeFlagCount,
|
|
3230
3233
|
'Detection Flags': element?.flagCount,
|
|
3234
|
+
'Flags': element?.flagCount,
|
|
3231
3235
|
'Compliance': element?.complianceRate,
|
|
3232
3236
|
// 'Flag Type': element?.checkListType === 'custom' ? 'Question' : 'Detection',
|
|
3233
3237
|
};
|
|
3234
|
-
if ( requestData?.filter === '
|
|
3238
|
+
if ( requestData?.filter === 'all' ) {
|
|
3239
|
+
delete data['No of Questions'];
|
|
3240
|
+
delete data['Flags'];
|
|
3241
|
+
} else if ( requestData?.filter === 'question' ) {
|
|
3235
3242
|
data['Flags'] = data['Question Flags'];
|
|
3236
3243
|
delete data['Question Flags'];
|
|
3237
3244
|
delete data['Flagged Count'];
|
|
3238
3245
|
delete data['Not Submitted Flags'];
|
|
3239
3246
|
delete data['Detection Flags'];
|
|
3240
3247
|
delete data['Run AI Flag'];
|
|
3248
|
+
delete data['No of Questions'];
|
|
3241
3249
|
} else if ( requestData?.filter === 'time' ) {
|
|
3242
3250
|
data['Flags'] = data['Not Submitted Flags'];
|
|
3243
3251
|
delete data['Question Flags'];
|
|
@@ -3245,7 +3253,16 @@ export const flagTablesV2 = async ( req, res ) => {
|
|
|
3245
3253
|
delete data['Not Submitted Flags'];
|
|
3246
3254
|
delete data['Detection Flags'];
|
|
3247
3255
|
delete data['Run AI Flag'];
|
|
3256
|
+
delete data['No of Questions'];
|
|
3248
3257
|
} else if ( requestData?.filter === 'detection' ) {
|
|
3258
|
+
data['Flags'] = data['Detection Flags'];
|
|
3259
|
+
delete data['Question Flags'];
|
|
3260
|
+
delete data['Flagged Count'];
|
|
3261
|
+
delete data['Not Submitted Flags'];
|
|
3262
|
+
delete data['Run AI Flag'];
|
|
3263
|
+
delete data['Flags'];
|
|
3264
|
+
delete data['No of Questions'];
|
|
3265
|
+
} else if ( requestData?.filter === 'runAI' ) {
|
|
3249
3266
|
data['Flags'] = data['Detection Flags'];
|
|
3250
3267
|
delete data['Question Flags'];
|
|
3251
3268
|
delete data['Flagged Count'];
|
|
@@ -336,6 +336,36 @@ export const create = async ( req, res ) => {
|
|
|
336
336
|
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
+
let runAIData = [];
|
|
340
|
+
inputBody.sections.forEach( ( element, secIdx ) => {
|
|
341
|
+
if ( element.questions.length ) {
|
|
342
|
+
element.questions.forEach( ( question ) => {
|
|
343
|
+
question.answers.forEach( ( ans ) => {
|
|
344
|
+
if ( ans.runAI ) {
|
|
345
|
+
runAIData.push( {
|
|
346
|
+
clientId: inputBody.clientId,
|
|
347
|
+
checkListId: checkListId,
|
|
348
|
+
checkListName: inputBody.checklistName,
|
|
349
|
+
sectionNo: secIdx + 1,
|
|
350
|
+
sectionName: element.name,
|
|
351
|
+
answer: ans.answer,
|
|
352
|
+
answerType: question.answerType,
|
|
353
|
+
qname: question.qname,
|
|
354
|
+
runAI: true,
|
|
355
|
+
runAIFeatures: ans.runAIFeatures,
|
|
356
|
+
multiReferenceImage: ans.multiReferenceImage,
|
|
357
|
+
runAIDescription: ans.runAIDescription,
|
|
358
|
+
} );
|
|
359
|
+
}
|
|
360
|
+
} );
|
|
361
|
+
} );
|
|
362
|
+
}
|
|
363
|
+
} );
|
|
364
|
+
await runAIRequestServices.deleteMany( { checkListId: req.params.checklistId } );
|
|
365
|
+
if ( runAIData.length ) {
|
|
366
|
+
await runAIRequestServices.insertMany( runAIData );
|
|
367
|
+
}
|
|
368
|
+
|
|
339
369
|
return res.sendSuccess( { checklistId: checkListId, msg: 'CheckList Created Successfully' } );
|
|
340
370
|
}
|
|
341
371
|
} ).catch( ( e ) => {
|
|
@@ -1066,6 +1096,35 @@ export const update = async ( req, res ) => {
|
|
|
1066
1096
|
};
|
|
1067
1097
|
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
1068
1098
|
}
|
|
1099
|
+
let runAIData = [];
|
|
1100
|
+
inputBody.sections.forEach( ( element, secIdx ) => {
|
|
1101
|
+
if ( element.questions.length ) {
|
|
1102
|
+
element.questions.forEach( ( question ) => {
|
|
1103
|
+
question.answers.forEach( ( ans ) => {
|
|
1104
|
+
if ( ans.runAI ) {
|
|
1105
|
+
runAIData.push( {
|
|
1106
|
+
clientId: inputBody.clientId,
|
|
1107
|
+
checkListId: req.params.checklistId,
|
|
1108
|
+
checkListName: inputBody.checklistName,
|
|
1109
|
+
sectionNo: secIdx + 1,
|
|
1110
|
+
sectionName: element.name,
|
|
1111
|
+
answer: ans.answer,
|
|
1112
|
+
answerType: question.answerType,
|
|
1113
|
+
qname: question.qname,
|
|
1114
|
+
runAI: true,
|
|
1115
|
+
runAIFeatures: ans.runAIFeatures,
|
|
1116
|
+
multiReferenceImage: ans.multiReferenceImage,
|
|
1117
|
+
runAIDescription: ans.runAIDescription,
|
|
1118
|
+
} );
|
|
1119
|
+
}
|
|
1120
|
+
} );
|
|
1121
|
+
} );
|
|
1122
|
+
}
|
|
1123
|
+
} );
|
|
1124
|
+
await runAIRequestServices.deleteMany( { checkListId: req.params.checklistId } );
|
|
1125
|
+
if ( runAIData.length ) {
|
|
1126
|
+
await runAIRequestServices.insertMany( runAIData );
|
|
1127
|
+
}
|
|
1069
1128
|
let actionType = 'Checklist Updated';
|
|
1070
1129
|
let teamsMsg;
|
|
1071
1130
|
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
@@ -4623,7 +4682,7 @@ export async function updateRunAIRequest( req, res ) {
|
|
|
4623
4682
|
let checkRunAIRequestQuery = {
|
|
4624
4683
|
clientId: inputBody.clientId,
|
|
4625
4684
|
checkListId: inputBody.checkListId,
|
|
4626
|
-
sectionNo: inputBody.sectionNo,
|
|
4685
|
+
sectionNo: inputBody.sectionNo || '',
|
|
4627
4686
|
qname: inputBody.qname,
|
|
4628
4687
|
answer: inputBody.answer,
|
|
4629
4688
|
};
|
|
@@ -4701,7 +4760,7 @@ export async function createChecklistName( req, res ) {
|
|
|
4701
4760
|
'question': [
|
|
4702
4761
|
{
|
|
4703
4762
|
'qno': 1,
|
|
4704
|
-
'qname': '',
|
|
4763
|
+
'qname': 'Q1',
|
|
4705
4764
|
'answerType': 'descriptive',
|
|
4706
4765
|
'runAI': false,
|
|
4707
4766
|
'runAIDescription': '',
|
|
@@ -4747,3 +4806,27 @@ export async function createChecklistName( req, res ) {
|
|
|
4747
4806
|
return res.sendError( e, 500 );
|
|
4748
4807
|
}
|
|
4749
4808
|
}
|
|
4809
|
+
|
|
4810
|
+
export async function updateRunAIFeatures( req, res ) {
|
|
4811
|
+
try {
|
|
4812
|
+
let inputBody = req.body;
|
|
4813
|
+
let incomeFeatures = inputBody.runAIFeatures;
|
|
4814
|
+
for ( let i = 0; i < incomeFeatures.length; i++ ) {
|
|
4815
|
+
// const element = array[i];
|
|
4816
|
+
if ( incomeFeatures[i].featureName == 'Others' ) {
|
|
4817
|
+
let insertData = {
|
|
4818
|
+
'clientId': inputBody.clientId,
|
|
4819
|
+
'featureName': incomeFeatures[i].lableName,
|
|
4820
|
+
'lableName': incomeFeatures[i].lableName,
|
|
4821
|
+
};
|
|
4822
|
+
// console.log( 'insertData =>', insertData );
|
|
4823
|
+
await runAIFeatureServices.updateOne( { clientId: insertData.clientId, featureName: insertData.featureName }, insertData );
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
|
|
4827
|
+
return res.sendSuccess( 'Feature created successfully' );
|
|
4828
|
+
} catch ( e ) {
|
|
4829
|
+
logger.error( { functionName: 'updateRunAIFeatures', error: e } );
|
|
4830
|
+
return res.sendError( error, 500 );
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
@@ -339,6 +339,7 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
339
339
|
},
|
|
340
340
|
timeFlag: { $sum: '$timeFlag' },
|
|
341
341
|
questionFlagCount: { $sum: '$questionFlag' },
|
|
342
|
+
runAIFlagCount: { $sum: '$runAIFlag' },
|
|
342
343
|
checkListType: { $last: '$checkListType' },
|
|
343
344
|
redo: { $sum: { $cond: [ { $eq: [ '$redoStatus', true ] }, 1, 0 ] } },
|
|
344
345
|
task: {
|
|
@@ -394,7 +395,7 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
394
395
|
},
|
|
395
396
|
storeCount: 1,
|
|
396
397
|
submittedChecklist: 1,
|
|
397
|
-
flaggedChecklist: { $add: [ '$timeFlag', '$questionFlagCount' ] },
|
|
398
|
+
flaggedChecklist: { $add: [ '$timeFlag', '$questionFlagCount', '$runAIFlagCount' ] },
|
|
398
399
|
checkListType: 1,
|
|
399
400
|
redo: 1,
|
|
400
401
|
task: 1,
|
|
@@ -514,6 +515,7 @@ export const storePerformance = async ( req, res ) => {
|
|
|
514
515
|
store_id: 1,
|
|
515
516
|
storeName: 1,
|
|
516
517
|
userEmail: 1,
|
|
518
|
+
runAIFlag: 1,
|
|
517
519
|
},
|
|
518
520
|
} );
|
|
519
521
|
|
|
@@ -535,6 +537,7 @@ export const storePerformance = async ( req, res ) => {
|
|
|
535
537
|
questionFlag: { $sum: { $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, '$questionFlag', 0 ] } },
|
|
536
538
|
questionCount: { $sum: '$questionCount' },
|
|
537
539
|
submitQuestionCount: { $sum: { $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, '$questionCount', 0 ] } },
|
|
540
|
+
runAIFlag: { $sum: { $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, '$runAIFlag', 0 ] } },
|
|
538
541
|
},
|
|
539
542
|
} );
|
|
540
543
|
|
|
@@ -544,7 +547,7 @@ export const storePerformance = async ( req, res ) => {
|
|
|
544
547
|
storeName: 1,
|
|
545
548
|
userEmail: 1,
|
|
546
549
|
checkListCount: { $sum: '$totalChecklist' },
|
|
547
|
-
flaggedCount: { $add: [ '$timeFlag', '$questionFlag' ] },
|
|
550
|
+
flaggedCount: { $add: [ '$timeFlag', '$questionFlag', '$runAIFlag' ] },
|
|
548
551
|
submittedChecklist: 1,
|
|
549
552
|
checkListType: 1,
|
|
550
553
|
questionCount: 1,
|
|
@@ -729,6 +732,7 @@ export const userPerformance = async ( req, res ) => {
|
|
|
729
732
|
userName: 1,
|
|
730
733
|
questionCount: 1,
|
|
731
734
|
redoStatus: 1,
|
|
735
|
+
runAIFlag: 1,
|
|
732
736
|
},
|
|
733
737
|
} );
|
|
734
738
|
|
|
@@ -747,6 +751,7 @@ export const userPerformance = async ( req, res ) => {
|
|
|
747
751
|
$sum: { $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, '$questionCount', 0 ] },
|
|
748
752
|
},
|
|
749
753
|
redo: { $sum: { $cond: [ { $eq: [ '$redoStatus', true ] }, 1, 0 ] } },
|
|
754
|
+
runAIFlag: { $sum: '$runAIFlag' },
|
|
750
755
|
},
|
|
751
756
|
} );
|
|
752
757
|
|
|
@@ -754,7 +759,7 @@ export const userPerformance = async ( req, res ) => {
|
|
|
754
759
|
findQuery.push( {
|
|
755
760
|
$addFields: {
|
|
756
761
|
userName: '$_id',
|
|
757
|
-
flaggedCount: { $add: [ '$timeFlag', '$questionFlag' ] },
|
|
762
|
+
flaggedCount: { $add: [ '$timeFlag', '$questionFlag', '$runAIFlag' ] },
|
|
758
763
|
correctAnswers: { $subtract: [ '$submittedChecklistQuestionCount', '$questionFlag' ] },
|
|
759
764
|
completion: {
|
|
760
765
|
$round: [
|
|
@@ -1599,6 +1604,7 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1599
1604
|
approvalByEmail: 1,
|
|
1600
1605
|
approvalTime_string: 1,
|
|
1601
1606
|
_id: 1,
|
|
1607
|
+
runAIFlag: 1,
|
|
1602
1608
|
},
|
|
1603
1609
|
} );
|
|
1604
1610
|
|
|
@@ -1635,7 +1641,7 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1635
1641
|
storeName: 1,
|
|
1636
1642
|
checkListType: 1,
|
|
1637
1643
|
scheduleRepeatedType: 1,
|
|
1638
|
-
flaggedChecklist: { $add: [ '$timeFlag', '$questionFlag' ] },
|
|
1644
|
+
flaggedChecklist: { $add: [ '$timeFlag', '$questionFlag', '$runAIFlag' ] },
|
|
1639
1645
|
timeFlag: 1,
|
|
1640
1646
|
questionFlag: 1,
|
|
1641
1647
|
date_iso: 1,
|
|
@@ -1650,6 +1656,7 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1650
1656
|
approvalByEmail: 1,
|
|
1651
1657
|
approvalTime_string: 1,
|
|
1652
1658
|
_id: 1,
|
|
1659
|
+
runAIFlag: 1,
|
|
1653
1660
|
},
|
|
1654
1661
|
} );
|
|
1655
1662
|
|
|
@@ -2606,6 +2613,7 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
2606
2613
|
totalQuestionCount: { $sum: '$questionCount' },
|
|
2607
2614
|
totalQuestionFlagCount: { $sum: '$questionFlag' },
|
|
2608
2615
|
totalTimeFlag: { $sum: '$timeFlag' },
|
|
2616
|
+
totalRunAIFlag: { $sum: '$runAIFlag' },
|
|
2609
2617
|
},
|
|
2610
2618
|
} );
|
|
2611
2619
|
findQuery.push( {
|
|
@@ -2624,6 +2632,7 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
2624
2632
|
questionCountSum: { $sum: '$totalQuestionCount' },
|
|
2625
2633
|
questionFlagCountSum: { $sum: '$totalQuestionFlagCount' },
|
|
2626
2634
|
timeFlagSum: { $sum: '$totalTimeFlag' },
|
|
2635
|
+
runAIFlagSum: { $sum: '$totalRunAIFlag' },
|
|
2627
2636
|
},
|
|
2628
2637
|
} );
|
|
2629
2638
|
findQuery.push( {
|
|
@@ -2642,6 +2651,7 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
2642
2651
|
statusCounts: 1,
|
|
2643
2652
|
submittedChecklistQuestionCount: 1,
|
|
2644
2653
|
submittedChecklistFlagQuestionCount: 1,
|
|
2654
|
+
runAIFlagSum: 1,
|
|
2645
2655
|
},
|
|
2646
2656
|
} );
|
|
2647
2657
|
findQuery.push( {
|
|
@@ -2651,7 +2661,7 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
2651
2661
|
openChecklist: { $ifNull: [ '$statusCounts.open', 0 ] },
|
|
2652
2662
|
inprogressChecklist: { $ifNull: [ '$statusCounts.inprogress', 0 ] },
|
|
2653
2663
|
submittedChecklist: { $ifNull: [ '$statusCounts.submit', 0 ] },
|
|
2654
|
-
flaggedChecklist: { $add: [ { $ifNull: [ '$timeFlagSum', 0 ] }, { $ifNull: [ '$questionFlagCountSum', 0 ] } ] },
|
|
2664
|
+
flaggedChecklist: { $add: [ { $ifNull: [ '$timeFlagSum', 0 ] }, { $ifNull: [ '$questionFlagCountSum', 0 ] }, { $ifNull: [ '$runAIFlagSum', 0 ] } ] },
|
|
2655
2665
|
completionScore: { $round: [ { $multiply: [ { $divide: [ { $ifNull: [ '$statusCounts.submit', 0 ] }, { $ifNull: [ '$totalChecklist', 0 ] } ] }, 100 ] }, 0 ] },
|
|
2656
2666
|
// completionScore: { $multiply: [ { $divide: [ '$statusCounts.submit', '$totalChecklist' ] }, 100 ] },
|
|
2657
2667
|
questionFlagCount: { $ifNull: [ '$questionFlagCountSum', 0 ] },
|
|
@@ -2857,6 +2867,7 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
|
|
|
2857
2867
|
totalQuestionCount: { $sum: '$questionCount' },
|
|
2858
2868
|
totalQuestionFlagCount: { $sum: '$questionFlag' },
|
|
2859
2869
|
totalTimeFlag: { $sum: '$timeFlag' },
|
|
2870
|
+
totalRunAIFlag: { $sum: '$runAIFlag' },
|
|
2860
2871
|
},
|
|
2861
2872
|
},
|
|
2862
2873
|
{
|
|
@@ -2875,6 +2886,7 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
|
|
|
2875
2886
|
questionCountSum: { $sum: '$totalQuestionCount' },
|
|
2876
2887
|
questionFlagCountSum: { $sum: '$totalQuestionFlagCount' },
|
|
2877
2888
|
timeFlagSum: { $sum: '$totalTimeFlag' },
|
|
2889
|
+
runAIFlagSum: { $sum: '$totalRunAIFlag' },
|
|
2878
2890
|
},
|
|
2879
2891
|
},
|
|
2880
2892
|
{
|
|
@@ -2893,6 +2905,7 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
|
|
|
2893
2905
|
statusCounts: 1,
|
|
2894
2906
|
submittedChecklistQuestionCount: 1,
|
|
2895
2907
|
submittedChecklistFlagQuestionCount: 1,
|
|
2908
|
+
runAIFlagSum: 1,
|
|
2896
2909
|
},
|
|
2897
2910
|
},
|
|
2898
2911
|
{
|
|
@@ -2902,7 +2915,7 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
|
|
|
2902
2915
|
openChecklist: { $ifNull: [ '$statusCounts.open', 0 ] },
|
|
2903
2916
|
inprogressChecklist: { $ifNull: [ '$statusCounts.inprogress', 0 ] },
|
|
2904
2917
|
submittedChecklist: { $ifNull: [ '$statusCounts.submit', 0 ] },
|
|
2905
|
-
flaggedChecklist: { $add: [ { $ifNull: [ '$timeFlagSum', 0 ] }, { $ifNull: [ '$questionFlagCountSum', 0 ] } ] },
|
|
2918
|
+
flaggedChecklist: { $add: [ { $ifNull: [ '$timeFlagSum', 0 ] }, { $ifNull: [ '$questionFlagCountSum', 0 ] }, { $ifNull: [ '$runAIFlagSum', 0 ] } ] },
|
|
2906
2919
|
completionScore: { $round: [ { $multiply: [ { $divide: [ { $ifNull: [ '$statusCounts.submit', 0 ] }, { $ifNull: [ '$totalChecklist', 0 ] } ] }, 100 ] }, 0 ] },
|
|
2907
2920
|
// completionScore: { $multiply: [ { $divide: [ '$statusCounts.submit', '$totalChecklist' ] }, 100 ] },
|
|
2908
2921
|
questionFlagCount: { $ifNull: [ '$questionFlagCountSum', 0 ] },
|
|
@@ -178,6 +178,7 @@ export const runAIRequestSchema = joi.object( {
|
|
|
178
178
|
answer: joi.string().optional().allow( '' ),
|
|
179
179
|
runAI: joi.boolean().required(),
|
|
180
180
|
runAIFeatures: joi.array().optional().allow( '' ),
|
|
181
|
+
referenceImages: joi.array().items( joi.any() ).min( 0 ),
|
|
181
182
|
} );
|
|
182
183
|
|
|
183
184
|
export const runAIRequestValidation = {
|
|
@@ -26,6 +26,7 @@ internalTraxRouter
|
|
|
26
26
|
.post( '/getLiveChecklistClients', isAllowedInternalAPIHandler, internalController.getLiveChecklistClients )
|
|
27
27
|
.post( '/notificationCreate', isAllowedInternalAPIHandler, internalController.notificationCreate )
|
|
28
28
|
.post( '/insertAINotification', isAllowedInternalAPIHandler, internalController.insertAINotification )
|
|
29
|
-
.post( '/updateRunAI', isAllowedInternalAPIHandler, internalController.updateRunAI )
|
|
29
|
+
.post( '/updateRunAI', isAllowedInternalAPIHandler, internalController.updateRunAI )
|
|
30
|
+
.post( '/countUpdateRunAI', isAllowedInternalAPIHandler, internalController.countUpdateRunAI );
|
|
30
31
|
|
|
31
32
|
|
|
@@ -32,6 +32,7 @@ traxRouter
|
|
|
32
32
|
.post( '/updateAiConfigure', isAllowedSessionHandler, traxController.updateAiConfigure )
|
|
33
33
|
.get( '/getAiDetails', isAllowedSessionHandler, traxController.getAiDetails )
|
|
34
34
|
.post( '/getRunAIFeatures', isAllowedSessionHandler, traxController.getRunAIFeatures )
|
|
35
|
+
.post( '/updateRunAIFeatures', isAllowedSessionHandler, traxController.updateRunAIFeatures )
|
|
35
36
|
.post( '/updateRunAIRequest', isAllowedSessionHandler, validate( runAIRequestValidation ), traxController.updateRunAIRequest )
|
|
36
37
|
.post( '/createChecklistName', isAllowedSessionHandler, validate( createChecklistNameValidation ), traxController.createChecklistName );
|
|
37
38
|
|
|
@@ -17,7 +17,7 @@ export const deleteOne = async ( query = {} ) => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const updateOne = async ( query = {}, record={} ) => {
|
|
20
|
-
return model.runAIFeaturesModel.updateOne( query, { $set: record } );
|
|
20
|
+
return model.runAIFeaturesModel.updateOne( query, { $set: record }, { upsert: true } );
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export const aggregate = async ( query = {} ) => {
|
|
@@ -12,6 +12,14 @@ export const create = async ( document = {} ) => {
|
|
|
12
12
|
return model.runAIRequestModel.create( document );
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
export const insertMany = async ( document = {} ) => {
|
|
16
|
+
return model.runAIRequestModel.insertMany( document );
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const deleteMany = async ( query = {} ) => {
|
|
20
|
+
return model.runAIRequestModel.deleteMany( query );
|
|
21
|
+
};
|
|
22
|
+
|
|
15
23
|
export const deleteOne = async ( query = {} ) => {
|
|
16
24
|
return model.runAIRequestModel.deleteOne( query );
|
|
17
25
|
};
|
package/app.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import { traxDashboardRouter, traxFlagRouter, traxRouter, downloadRouter, mobileRouter, locusOrderRouter, internalTraxRouter, traxActivityLogRouter, galleryRouter } from './index.js';
|
|
3
|
-
import dotenv from 'dotenv';
|
|
4
|
-
import pkg from 'body-parser';
|
|
5
|
-
const { json, urlencoded } = pkg;
|
|
6
|
-
import { logger } from 'tango-app-api-middleware';
|
|
7
|
-
import { connectdb } from './config/database/database.js';
|
|
8
|
-
import responseMiddleware from './config/response/response.js';
|
|
9
|
-
import errorMiddleware from './config/response/error.js';
|
|
10
|
-
import cors from 'cors';
|
|
11
|
-
import admin from 'firebase-admin';
|
|
12
|
-
import fileupload from 'express-fileupload';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const serviceAccountPath = JSON.parse( process.env.FIREBASE );
|
|
16
|
-
admin.initializeApp( {
|
|
17
|
-
credential: admin.credential.cert( serviceAccountPath ),
|
|
18
|
-
} );
|
|
19
|
-
|
|
20
|
-
const env=dotenv.config();
|
|
21
|
-
|
|
22
|
-
const app = express();
|
|
23
|
-
const PORT = process.env.PORT || 3000;
|
|
24
|
-
app.use( cors() );
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if ( env.error ) {
|
|
28
|
-
logger.error( '.env not found' );
|
|
29
|
-
process.exit( 1 );
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
app.use( json( { limit: '500mb' } ) );
|
|
33
|
-
app.use( fileupload() );
|
|
34
|
-
app.use(
|
|
35
|
-
urlencoded( {
|
|
36
|
-
extended: true,
|
|
37
|
-
} ),
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
app.use( responseMiddleware );
|
|
41
|
-
app.use( errorMiddleware );
|
|
42
|
-
|
|
43
|
-
app.use( '/trax/dashboard', traxDashboardRouter );
|
|
44
|
-
app.use( '/trax', traxRouter );
|
|
45
|
-
app.use( '/trax/flag', traxFlagRouter );
|
|
46
|
-
app.use( '/trax/downloads', downloadRouter );
|
|
47
|
-
app.use( '/trax/mobileAPI', mobileRouter );
|
|
48
|
-
app.use( '/trax/locusorder', locusOrderRouter );
|
|
49
|
-
app.use( '/trax/internalAPI', internalTraxRouter );
|
|
50
|
-
app.use( '/trax/activityLog', traxActivityLogRouter );
|
|
51
|
-
app.use( '/trax/gallery', galleryRouter );
|
|
52
|
-
|
|
53
|
-
app.listen( PORT, () => {
|
|
54
|
-
console.log( `server is running on port= ${PORT} ` );
|
|
55
|
-
connectdb();
|
|
56
|
-
} );
|