tango-app-api-trax 3.7.3-runai-2 → 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 +2 -2
- package/src/controllers/mobileTrax.controller.js +2 -0
- package/src/controllers/teaxFlag.controller.js +20 -3
- package/src/controllers/trax.controller.js +83 -0
- package/src/dtos/validation.dtos.js +1 -0
- package/src/routes/trax.routes.js +1 -1
- package/src/services/runAIFeatures.services.js +1 -1
- package/src/services/runAIRequest.services.js +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
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.3.
|
|
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",
|
|
@@ -1341,6 +1341,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1341
1341
|
newAnswer.index = s;
|
|
1342
1342
|
newAnswer.runAI = qaAnswers[j].answers[0]?.runAI || false;
|
|
1343
1343
|
newAnswer.runAIFeatures = qaAnswers[j].answers[0]?.runAIFeatures || [];
|
|
1344
|
+
newAnswer.runAIDescription = qaAnswers[j].answers[0]?.runAIDescription || '';
|
|
1344
1345
|
mcmi.push( newAnswer );
|
|
1345
1346
|
}
|
|
1346
1347
|
}
|
|
@@ -1403,6 +1404,7 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1403
1404
|
linkedQuestion: qaAnswers[j].answers[0].linkedQuestion,
|
|
1404
1405
|
runAI: qaAnswers[j].answers[0]?.runAI || false,
|
|
1405
1406
|
runAIFeatures: qaAnswers[j]?.answers[0]?.runAIFeatures || [],
|
|
1407
|
+
runAIDescription: qaAnswers[j].answers[0]?.runAIDescription || '',
|
|
1406
1408
|
};
|
|
1407
1409
|
if ( qaAnswers[j].answerType == 'date' ) {
|
|
1408
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 ) : '';
|
|
@@ -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
|
+
}
|
|
@@ -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 = {
|
|
@@ -32,7 +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.
|
|
35
|
+
.post( '/updateRunAIFeatures', isAllowedSessionHandler, traxController.updateRunAIFeatures )
|
|
36
36
|
.post( '/updateRunAIRequest', isAllowedSessionHandler, validate( runAIRequestValidation ), traxController.updateRunAIRequest )
|
|
37
37
|
.post( '/createChecklistName', isAllowedSessionHandler, validate( createChecklistNameValidation ), traxController.createChecklistName );
|
|
38
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
|
};
|