tango-app-api-trax 3.7.3-runai-3 → 3.7.4-airtelv2-1
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/internalTrax.controller.js +0 -25
- package/src/controllers/mobileTrax.controller.js +2 -7
- package/src/controllers/trax.controller.js +2 -245
- package/src/controllers/traxDashboard.controllers.js +6 -19
- package/src/dtos/validation.dtos.js +0 -28
- package/src/routes/internalTraxApi.router.js +1 -2
- package/src/routes/trax.routes.js +3 -6
- package/src/services/runAIFeatures.services.js +0 -31
- package/src/services/runAIRequest.services.js +0 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.4-airtelv2-1",
|
|
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.20",
|
|
31
31
|
"tango-app-api-middleware": "^3.1.77",
|
|
32
32
|
"url": "^0.11.4",
|
|
33
33
|
"winston": "^3.13.1",
|
|
@@ -2556,28 +2556,3 @@ 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,14 +1334,12 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1334
1334
|
newAnswer.validationType = '';
|
|
1335
1335
|
newAnswer.referenceImage = '';
|
|
1336
1336
|
newAnswer.allowUploadfromGallery = false;
|
|
1337
|
+
newAnswer.runAI = false;
|
|
1337
1338
|
newAnswer.descriptivetype = '';
|
|
1338
1339
|
newAnswer.showLinked = false;
|
|
1339
1340
|
newAnswer.linkedQuestion = 0;
|
|
1340
1341
|
newAnswer.nestedQuestion = [];
|
|
1341
1342
|
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 || '';
|
|
1345
1343
|
mcmi.push( newAnswer );
|
|
1346
1344
|
}
|
|
1347
1345
|
}
|
|
@@ -1402,9 +1400,6 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1402
1400
|
multiReferenceImage: qaAnswers[j].answers[0].multiReferenceImage || [],
|
|
1403
1401
|
showLinked: qaAnswers[j].answers[0].showLinked,
|
|
1404
1402
|
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 || '',
|
|
1408
1403
|
};
|
|
1409
1404
|
if ( qaAnswers[j].answerType == 'date' ) {
|
|
1410
1405
|
ansstructure.dateRangeType = requestSection[i].dateRangeType || false;
|
|
@@ -2933,7 +2928,7 @@ export async function checklistv1( req, res ) {
|
|
|
2933
2928
|
|
|
2934
2929
|
const [ checklistResult, taskResult ] = await Promise.allSettled( [
|
|
2935
2930
|
processedchecklist.aggregate( buildPipeline( [ { checkListType: 'custom' } ], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1 } ) ),
|
|
2936
|
-
processedTask.aggregate( taskBuildPipeline( [], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1 } ) ),
|
|
2931
|
+
processedTask.aggregate( taskBuildPipeline( [], { isPlano: 1, planoId: 1, planoType: 1, floorId: 1, refTaskId: 1 } ) ),
|
|
2937
2932
|
] );
|
|
2938
2933
|
|
|
2939
2934
|
const checklistData = checklistResult.status === 'fulfilled' ? checklistResult.value : [];
|
|
@@ -23,8 +23,6 @@ dayjs.extend( utc );
|
|
|
23
23
|
dayjs.extend( customParseFormat );
|
|
24
24
|
import * as clusterServices from '../services/cluster.service.js';
|
|
25
25
|
import * as teamsServices from '../services/teams.service.js';
|
|
26
|
-
import * as runAIFeatureServices from '../services/runAIFeatures.services.js';
|
|
27
|
-
import * as runAIRequestServices from '../services/runAIRequest.services.js';
|
|
28
26
|
|
|
29
27
|
|
|
30
28
|
export const checklist = async ( req, res ) => {
|
|
@@ -336,36 +334,6 @@ export const create = async ( req, res ) => {
|
|
|
336
334
|
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
337
335
|
}
|
|
338
336
|
|
|
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
|
-
|
|
369
337
|
return res.sendSuccess( { checklistId: checkListId, msg: 'CheckList Created Successfully' } );
|
|
370
338
|
}
|
|
371
339
|
} ).catch( ( e ) => {
|
|
@@ -1096,35 +1064,6 @@ export const update = async ( req, res ) => {
|
|
|
1096
1064
|
};
|
|
1097
1065
|
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).traxActivityLog, logObj );
|
|
1098
1066
|
}
|
|
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
|
-
}
|
|
1128
1067
|
let actionType = 'Checklist Updated';
|
|
1129
1068
|
let teamsMsg;
|
|
1130
1069
|
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
@@ -3912,7 +3851,7 @@ async function updateOpenSearch( user, data ) {
|
|
|
3912
3851
|
export const aiChecklist = async ( req, res ) => {
|
|
3913
3852
|
try {
|
|
3914
3853
|
let storeDetails = await storeService.count( { clientId: req.query.clientId, status: 'active' } );
|
|
3915
|
-
let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in' ];
|
|
3854
|
+
let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking' ];
|
|
3916
3855
|
let checklistDetails = [];
|
|
3917
3856
|
let publishList = [];
|
|
3918
3857
|
let unpublishList = [];
|
|
@@ -4590,6 +4529,7 @@ export async function updateAiConfigure( req, res ) {
|
|
|
4590
4529
|
}
|
|
4591
4530
|
}
|
|
4592
4531
|
|
|
4532
|
+
|
|
4593
4533
|
export async function getAiDetails( req, res ) {
|
|
4594
4534
|
try {
|
|
4595
4535
|
let storeList = [];
|
|
@@ -4647,186 +4587,3 @@ export async function getAiDetails( req, res ) {
|
|
|
4647
4587
|
return res.sendError( e, 500 );
|
|
4648
4588
|
}
|
|
4649
4589
|
}
|
|
4650
|
-
|
|
4651
|
-
export async function getRunAIFeatures( req, res ) {
|
|
4652
|
-
try {
|
|
4653
|
-
console.log( 'req.body =>', req.body );
|
|
4654
|
-
let reqestData = req.body;
|
|
4655
|
-
let getRunAIFeaturesQuery = [
|
|
4656
|
-
{
|
|
4657
|
-
$match: {
|
|
4658
|
-
$or: [ { client_id: reqestData.client_id }, { client_id: { $exists: false } } ],
|
|
4659
|
-
isdeleted: false,
|
|
4660
|
-
},
|
|
4661
|
-
},
|
|
4662
|
-
{ $addFields: { sortOrder: { $cond: [ { $eq: [ '$featureName', 'Others' ] }, 1, 0 ] } } },
|
|
4663
|
-
{ $sort: { sortOrder: 1, _id: 1 } },
|
|
4664
|
-
{ $project: { client_id: 1, featureName: 1, lableName: 1 } },
|
|
4665
|
-
];
|
|
4666
|
-
let response = await runAIFeatureServices.aggregate( getRunAIFeaturesQuery );
|
|
4667
|
-
if ( response && response.length > 0 ) {
|
|
4668
|
-
return res.sendSuccess( response );
|
|
4669
|
-
} else {
|
|
4670
|
-
return res.sendError( 'No Features Available', 204 );
|
|
4671
|
-
}
|
|
4672
|
-
} catch ( e ) {
|
|
4673
|
-
logger.error( { functionName: 'getRunAIFeatures', error: e } );
|
|
4674
|
-
return res.sendError( e, 500 );
|
|
4675
|
-
}
|
|
4676
|
-
}
|
|
4677
|
-
|
|
4678
|
-
export async function updateRunAIRequest( req, res ) {
|
|
4679
|
-
try {
|
|
4680
|
-
let inputBody = req.body;
|
|
4681
|
-
inputBody.createdBy = req.user.email;
|
|
4682
|
-
let checkRunAIRequestQuery = {
|
|
4683
|
-
clientId: inputBody.clientId,
|
|
4684
|
-
checkListId: inputBody.checkListId,
|
|
4685
|
-
sectionNo: inputBody.sectionNo || '',
|
|
4686
|
-
qname: inputBody.qname,
|
|
4687
|
-
answer: inputBody.answer,
|
|
4688
|
-
};
|
|
4689
|
-
let checkRunAIRequest = await runAIRequestServices.findOne( checkRunAIRequestQuery );
|
|
4690
|
-
|
|
4691
|
-
// runAI Features Updated
|
|
4692
|
-
let incomeFeatures = inputBody.runAIFeatures;
|
|
4693
|
-
for ( let i = 0; i < incomeFeatures.length; i++ ) {
|
|
4694
|
-
// const element = array[i];
|
|
4695
|
-
if ( incomeFeatures[i].featureName == 'Others' ) {
|
|
4696
|
-
let insertData = {
|
|
4697
|
-
'client_id': inputBody.clientId,
|
|
4698
|
-
'featureName': incomeFeatures[i].lableName,
|
|
4699
|
-
'lableName': incomeFeatures[i].lableName,
|
|
4700
|
-
};
|
|
4701
|
-
console.log( 'insertData =>', insertData );
|
|
4702
|
-
await runAIFeatureServices.create( insertData );
|
|
4703
|
-
}
|
|
4704
|
-
}
|
|
4705
|
-
if ( checkRunAIRequest ) {
|
|
4706
|
-
let updateRunAIRequest = await runAIRequestServices.updateOne( checkRunAIRequestQuery, inputBody );
|
|
4707
|
-
if ( updateRunAIRequest ) {
|
|
4708
|
-
return res.sendSuccess( updateRunAIRequest );
|
|
4709
|
-
} else {
|
|
4710
|
-
return res.sendError( 'something went wrong please Try again', 500 );
|
|
4711
|
-
}
|
|
4712
|
-
} else {
|
|
4713
|
-
let insertRunAIRequest = await runAIRequestServices.create( inputBody );
|
|
4714
|
-
if ( insertRunAIRequest ) {
|
|
4715
|
-
return res.sendSuccess( insertRunAIRequest );
|
|
4716
|
-
} else {
|
|
4717
|
-
return res.sendError( 'something went wrong please Try again', 500 );
|
|
4718
|
-
}
|
|
4719
|
-
}
|
|
4720
|
-
} catch ( e ) {
|
|
4721
|
-
logger.error( { functionName: 'updateRunAIRequest', error: e } );
|
|
4722
|
-
return res.sendError( e, 500 );
|
|
4723
|
-
}
|
|
4724
|
-
}
|
|
4725
|
-
|
|
4726
|
-
export async function createChecklistName( req, res ) {
|
|
4727
|
-
try {
|
|
4728
|
-
// console.log( 'req.body =>', req.body );
|
|
4729
|
-
let inputBody = req.body;
|
|
4730
|
-
let checklistNameQuery = {
|
|
4731
|
-
client_id: inputBody.clientId,
|
|
4732
|
-
checkListName: inputBody.checkListName,
|
|
4733
|
-
};
|
|
4734
|
-
let checklistExist = await checklistService.findOne( checklistNameQuery );
|
|
4735
|
-
if ( checklistExist ) {
|
|
4736
|
-
return res.sendError( { message: 'checklist name Alrady Exist' }, 400 );
|
|
4737
|
-
}
|
|
4738
|
-
|
|
4739
|
-
let getMaxChecklistNumber = [
|
|
4740
|
-
{ $match: { client_id: inputBody.clientId } },
|
|
4741
|
-
{ $group: { _id: null, maxCheckListNumber: { $max: '$checkListNumber' } } },
|
|
4742
|
-
];
|
|
4743
|
-
let maxChecklistNumber = await checklistService.aggregate( getMaxChecklistNumber );
|
|
4744
|
-
|
|
4745
|
-
let checkListDetails = {
|
|
4746
|
-
type: 'checklist',
|
|
4747
|
-
checkListNumber: parseInt( maxChecklistNumber[0].maxCheckListNumber ) + 1,
|
|
4748
|
-
checkListName: inputBody.checkListName,
|
|
4749
|
-
checkListDescription: inputBody.checklistDescription,
|
|
4750
|
-
createdBy: req.user._id,
|
|
4751
|
-
createdByName: req.user.userName,
|
|
4752
|
-
questionCount: 0,
|
|
4753
|
-
client_id: req.body?.clientId,
|
|
4754
|
-
owner: req.user.userType == 'client' ? [ { name: req.user.userName, value: req.user.email } ] : [],
|
|
4755
|
-
runAIQuestionCount: 0,
|
|
4756
|
-
};
|
|
4757
|
-
let response = await checklistService.create( checkListDetails );
|
|
4758
|
-
if ( response ) {
|
|
4759
|
-
let insertSection = {
|
|
4760
|
-
'question': [
|
|
4761
|
-
{
|
|
4762
|
-
'qno': 1,
|
|
4763
|
-
'qname': 'Q1',
|
|
4764
|
-
'answerType': 'descriptive',
|
|
4765
|
-
'runAI': false,
|
|
4766
|
-
'runAIDescription': '',
|
|
4767
|
-
'allowUploadfromGallery': false,
|
|
4768
|
-
'linkType': false,
|
|
4769
|
-
'multiQuestionReferenceImage': [],
|
|
4770
|
-
'descriptivetype': 'text',
|
|
4771
|
-
'questionReferenceImage': '',
|
|
4772
|
-
'answers': [
|
|
4773
|
-
{
|
|
4774
|
-
'answer': '',
|
|
4775
|
-
'answeroptionNumber': 1,
|
|
4776
|
-
'sopFlag': false,
|
|
4777
|
-
'validation': false,
|
|
4778
|
-
'validationAnswer': '',
|
|
4779
|
-
'validationType': '',
|
|
4780
|
-
'multiReferenceImage': [],
|
|
4781
|
-
'showLinked': false,
|
|
4782
|
-
'linkedQuestion': 0,
|
|
4783
|
-
'referenceImage': '',
|
|
4784
|
-
'nestedQuestion': [],
|
|
4785
|
-
},
|
|
4786
|
-
],
|
|
4787
|
-
},
|
|
4788
|
-
],
|
|
4789
|
-
'section': 'Section 1',
|
|
4790
|
-
'checkList': inputBody.checkListName,
|
|
4791
|
-
'checkListId': new ObjectId( response._id ),
|
|
4792
|
-
'client_id': inputBody.clientId,
|
|
4793
|
-
'isdeleted': false,
|
|
4794
|
-
'sectionNumber': 1,
|
|
4795
|
-
};
|
|
4796
|
-
await questionService.create( insertSection );
|
|
4797
|
-
let resultData = {
|
|
4798
|
-
_id: response._id,
|
|
4799
|
-
};
|
|
4800
|
-
return res.sendSuccess( resultData );
|
|
4801
|
-
} else {
|
|
4802
|
-
return res.sendError( 'Something Went Wrong Please Try Again', 500 );
|
|
4803
|
-
}
|
|
4804
|
-
} catch ( e ) {
|
|
4805
|
-
logger.error( { functionName: 'createChecklistName', error: e } );
|
|
4806
|
-
return res.sendError( e, 500 );
|
|
4807
|
-
}
|
|
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,7 +339,6 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
339
339
|
},
|
|
340
340
|
timeFlag: { $sum: '$timeFlag' },
|
|
341
341
|
questionFlagCount: { $sum: '$questionFlag' },
|
|
342
|
-
runAIFlagCount: { $sum: '$runAIFlag' },
|
|
343
342
|
checkListType: { $last: '$checkListType' },
|
|
344
343
|
redo: { $sum: { $cond: [ { $eq: [ '$redoStatus', true ] }, 1, 0 ] } },
|
|
345
344
|
task: {
|
|
@@ -395,7 +394,7 @@ export const checklistPerformance = async ( req, res ) => {
|
|
|
395
394
|
},
|
|
396
395
|
storeCount: 1,
|
|
397
396
|
submittedChecklist: 1,
|
|
398
|
-
flaggedChecklist: { $add: [ '$timeFlag', '$questionFlagCount'
|
|
397
|
+
flaggedChecklist: { $add: [ '$timeFlag', '$questionFlagCount' ] },
|
|
399
398
|
checkListType: 1,
|
|
400
399
|
redo: 1,
|
|
401
400
|
task: 1,
|
|
@@ -515,7 +514,6 @@ export const storePerformance = async ( req, res ) => {
|
|
|
515
514
|
store_id: 1,
|
|
516
515
|
storeName: 1,
|
|
517
516
|
userEmail: 1,
|
|
518
|
-
runAIFlag: 1,
|
|
519
517
|
},
|
|
520
518
|
} );
|
|
521
519
|
|
|
@@ -537,7 +535,6 @@ export const storePerformance = async ( req, res ) => {
|
|
|
537
535
|
questionFlag: { $sum: { $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, '$questionFlag', 0 ] } },
|
|
538
536
|
questionCount: { $sum: '$questionCount' },
|
|
539
537
|
submitQuestionCount: { $sum: { $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, '$questionCount', 0 ] } },
|
|
540
|
-
runAIFlag: { $sum: { $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, '$runAIFlag', 0 ] } },
|
|
541
538
|
},
|
|
542
539
|
} );
|
|
543
540
|
|
|
@@ -547,7 +544,7 @@ export const storePerformance = async ( req, res ) => {
|
|
|
547
544
|
storeName: 1,
|
|
548
545
|
userEmail: 1,
|
|
549
546
|
checkListCount: { $sum: '$totalChecklist' },
|
|
550
|
-
flaggedCount: { $add: [ '$timeFlag', '$questionFlag'
|
|
547
|
+
flaggedCount: { $add: [ '$timeFlag', '$questionFlag' ] },
|
|
551
548
|
submittedChecklist: 1,
|
|
552
549
|
checkListType: 1,
|
|
553
550
|
questionCount: 1,
|
|
@@ -732,7 +729,6 @@ export const userPerformance = async ( req, res ) => {
|
|
|
732
729
|
userName: 1,
|
|
733
730
|
questionCount: 1,
|
|
734
731
|
redoStatus: 1,
|
|
735
|
-
runAIFlag: 1,
|
|
736
732
|
},
|
|
737
733
|
} );
|
|
738
734
|
|
|
@@ -751,7 +747,6 @@ export const userPerformance = async ( req, res ) => {
|
|
|
751
747
|
$sum: { $cond: [ { $eq: [ '$checklistStatus', 'submit' ] }, '$questionCount', 0 ] },
|
|
752
748
|
},
|
|
753
749
|
redo: { $sum: { $cond: [ { $eq: [ '$redoStatus', true ] }, 1, 0 ] } },
|
|
754
|
-
runAIFlag: { $sum: '$runAIFlag' },
|
|
755
750
|
},
|
|
756
751
|
} );
|
|
757
752
|
|
|
@@ -759,7 +754,7 @@ export const userPerformance = async ( req, res ) => {
|
|
|
759
754
|
findQuery.push( {
|
|
760
755
|
$addFields: {
|
|
761
756
|
userName: '$_id',
|
|
762
|
-
flaggedCount: { $add: [ '$timeFlag', '$questionFlag'
|
|
757
|
+
flaggedCount: { $add: [ '$timeFlag', '$questionFlag' ] },
|
|
763
758
|
correctAnswers: { $subtract: [ '$submittedChecklistQuestionCount', '$questionFlag' ] },
|
|
764
759
|
completion: {
|
|
765
760
|
$round: [
|
|
@@ -1604,7 +1599,6 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1604
1599
|
approvalByEmail: 1,
|
|
1605
1600
|
approvalTime_string: 1,
|
|
1606
1601
|
_id: 1,
|
|
1607
|
-
runAIFlag: 1,
|
|
1608
1602
|
},
|
|
1609
1603
|
} );
|
|
1610
1604
|
|
|
@@ -1641,7 +1635,7 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1641
1635
|
storeName: 1,
|
|
1642
1636
|
checkListType: 1,
|
|
1643
1637
|
scheduleRepeatedType: 1,
|
|
1644
|
-
flaggedChecklist: { $add: [ '$timeFlag', '$questionFlag'
|
|
1638
|
+
flaggedChecklist: { $add: [ '$timeFlag', '$questionFlag' ] },
|
|
1645
1639
|
timeFlag: 1,
|
|
1646
1640
|
questionFlag: 1,
|
|
1647
1641
|
date_iso: 1,
|
|
@@ -1656,7 +1650,6 @@ export const checklistInfo = async ( req, res ) => {
|
|
|
1656
1650
|
approvalByEmail: 1,
|
|
1657
1651
|
approvalTime_string: 1,
|
|
1658
1652
|
_id: 1,
|
|
1659
|
-
runAIFlag: 1,
|
|
1660
1653
|
},
|
|
1661
1654
|
} );
|
|
1662
1655
|
|
|
@@ -2613,7 +2606,6 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
2613
2606
|
totalQuestionCount: { $sum: '$questionCount' },
|
|
2614
2607
|
totalQuestionFlagCount: { $sum: '$questionFlag' },
|
|
2615
2608
|
totalTimeFlag: { $sum: '$timeFlag' },
|
|
2616
|
-
totalRunAIFlag: { $sum: '$runAIFlag' },
|
|
2617
2609
|
},
|
|
2618
2610
|
} );
|
|
2619
2611
|
findQuery.push( {
|
|
@@ -2632,7 +2624,6 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
2632
2624
|
questionCountSum: { $sum: '$totalQuestionCount' },
|
|
2633
2625
|
questionFlagCountSum: { $sum: '$totalQuestionFlagCount' },
|
|
2634
2626
|
timeFlagSum: { $sum: '$totalTimeFlag' },
|
|
2635
|
-
runAIFlagSum: { $sum: '$totalRunAIFlag' },
|
|
2636
2627
|
},
|
|
2637
2628
|
} );
|
|
2638
2629
|
findQuery.push( {
|
|
@@ -2651,7 +2642,6 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
2651
2642
|
statusCounts: 1,
|
|
2652
2643
|
submittedChecklistQuestionCount: 1,
|
|
2653
2644
|
submittedChecklistFlagQuestionCount: 1,
|
|
2654
|
-
runAIFlagSum: 1,
|
|
2655
2645
|
},
|
|
2656
2646
|
} );
|
|
2657
2647
|
findQuery.push( {
|
|
@@ -2661,7 +2651,7 @@ export const overallCardsV1 = async ( req, res ) => {
|
|
|
2661
2651
|
openChecklist: { $ifNull: [ '$statusCounts.open', 0 ] },
|
|
2662
2652
|
inprogressChecklist: { $ifNull: [ '$statusCounts.inprogress', 0 ] },
|
|
2663
2653
|
submittedChecklist: { $ifNull: [ '$statusCounts.submit', 0 ] },
|
|
2664
|
-
flaggedChecklist: { $add: [ { $ifNull: [ '$timeFlagSum', 0 ] }, { $ifNull: [ '$questionFlagCountSum', 0 ] }
|
|
2654
|
+
flaggedChecklist: { $add: [ { $ifNull: [ '$timeFlagSum', 0 ] }, { $ifNull: [ '$questionFlagCountSum', 0 ] } ] },
|
|
2665
2655
|
completionScore: { $round: [ { $multiply: [ { $divide: [ { $ifNull: [ '$statusCounts.submit', 0 ] }, { $ifNull: [ '$totalChecklist', 0 ] } ] }, 100 ] }, 0 ] },
|
|
2666
2656
|
// completionScore: { $multiply: [ { $divide: [ '$statusCounts.submit', '$totalChecklist' ] }, 100 ] },
|
|
2667
2657
|
questionFlagCount: { $ifNull: [ '$questionFlagCountSum', 0 ] },
|
|
@@ -2867,7 +2857,6 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
|
|
|
2867
2857
|
totalQuestionCount: { $sum: '$questionCount' },
|
|
2868
2858
|
totalQuestionFlagCount: { $sum: '$questionFlag' },
|
|
2869
2859
|
totalTimeFlag: { $sum: '$timeFlag' },
|
|
2870
|
-
totalRunAIFlag: { $sum: '$runAIFlag' },
|
|
2871
2860
|
},
|
|
2872
2861
|
},
|
|
2873
2862
|
{
|
|
@@ -2886,7 +2875,6 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
|
|
|
2886
2875
|
questionCountSum: { $sum: '$totalQuestionCount' },
|
|
2887
2876
|
questionFlagCountSum: { $sum: '$totalQuestionFlagCount' },
|
|
2888
2877
|
timeFlagSum: { $sum: '$totalTimeFlag' },
|
|
2889
|
-
runAIFlagSum: { $sum: '$totalRunAIFlag' },
|
|
2890
2878
|
},
|
|
2891
2879
|
},
|
|
2892
2880
|
{
|
|
@@ -2905,7 +2893,6 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
|
|
|
2905
2893
|
statusCounts: 1,
|
|
2906
2894
|
submittedChecklistQuestionCount: 1,
|
|
2907
2895
|
submittedChecklistFlagQuestionCount: 1,
|
|
2908
|
-
runAIFlagSum: 1,
|
|
2909
2896
|
},
|
|
2910
2897
|
},
|
|
2911
2898
|
{
|
|
@@ -2915,7 +2902,7 @@ export const overallComparisonCardsV1 = async ( req, res ) => {
|
|
|
2915
2902
|
openChecklist: { $ifNull: [ '$statusCounts.open', 0 ] },
|
|
2916
2903
|
inprogressChecklist: { $ifNull: [ '$statusCounts.inprogress', 0 ] },
|
|
2917
2904
|
submittedChecklist: { $ifNull: [ '$statusCounts.submit', 0 ] },
|
|
2918
|
-
flaggedChecklist: { $add: [ { $ifNull: [ '$timeFlagSum', 0 ] }, { $ifNull: [ '$questionFlagCountSum', 0 ] }
|
|
2905
|
+
flaggedChecklist: { $add: [ { $ifNull: [ '$timeFlagSum', 0 ] }, { $ifNull: [ '$questionFlagCountSum', 0 ] } ] },
|
|
2919
2906
|
completionScore: { $round: [ { $multiply: [ { $divide: [ { $ifNull: [ '$statusCounts.submit', 0 ] }, { $ifNull: [ '$totalChecklist', 0 ] } ] }, 100 ] }, 0 ] },
|
|
2920
2907
|
// completionScore: { $multiply: [ { $divide: [ '$statusCounts.submit', '$totalChecklist' ] }, 100 ] },
|
|
2921
2908
|
questionFlagCount: { $ifNull: [ '$questionFlagCountSum', 0 ] },
|
|
@@ -157,32 +157,4 @@ export const selectAssign = {
|
|
|
157
157
|
body: selectAssignSchema,
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
-
export const createChecklistNameSchema = joi.object( {
|
|
161
|
-
clientId: joi.string().required(),
|
|
162
|
-
checkListName: joi.string().required(),
|
|
163
|
-
checklistDescription: joi.string().optional(),
|
|
164
|
-
} );
|
|
165
|
-
|
|
166
|
-
export const createChecklistNameValidation = {
|
|
167
|
-
body: createChecklistNameSchema,
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
export const runAIRequestSchema = joi.object( {
|
|
171
|
-
clientId: joi.string().required(),
|
|
172
|
-
checkListId: joi.string().required(),
|
|
173
|
-
checkListName: joi.string().optional().allow( '' ),
|
|
174
|
-
sectionNo: joi.number().required(),
|
|
175
|
-
sectionName: joi.string().optional().allow( '' ),
|
|
176
|
-
qname: joi.string().required(),
|
|
177
|
-
answerType: joi.string().optional().allow( '' ),
|
|
178
|
-
answer: joi.string().optional().allow( '' ),
|
|
179
|
-
runAI: joi.boolean().required(),
|
|
180
|
-
runAIFeatures: joi.array().optional().allow( '' ),
|
|
181
|
-
referenceImages: joi.array().items( joi.any() ).min( 0 ),
|
|
182
|
-
} );
|
|
183
|
-
|
|
184
|
-
export const runAIRequestValidation = {
|
|
185
|
-
body: runAIRequestSchema,
|
|
186
|
-
};
|
|
187
|
-
|
|
188
160
|
|
|
@@ -26,7 +26,6 @@ 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 )
|
|
30
|
-
.post( '/countUpdateRunAI', isAllowedInternalAPIHandler, internalController.countUpdateRunAI );
|
|
29
|
+
.post( '/updateRunAI', isAllowedInternalAPIHandler, internalController.updateRunAI );
|
|
31
30
|
|
|
32
31
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { isAllowedSessionHandler, validate, accessVerification, isAllowedClient } from 'tango-app-api-middleware';
|
|
3
|
-
import { checklistValidation, checklistDetailsValidation, runaiValidation, checklistPageSchema, duplicateValidation, updateChecklistValidation, uploadUserValidation, aichecklistValidation, publishValidation, selectAssign
|
|
3
|
+
import { checklistValidation, checklistDetailsValidation, runaiValidation, checklistPageSchema, duplicateValidation, updateChecklistValidation, uploadUserValidation, aichecklistValidation, publishValidation, selectAssign } from '../dtos/validation.dtos.js';
|
|
4
4
|
import * as traxController from '../controllers/trax.controller.js';
|
|
5
5
|
|
|
6
6
|
export const traxRouter = express.Router();
|
|
@@ -30,10 +30,7 @@ traxRouter
|
|
|
30
30
|
// .post( '/assignUpload', isAllowedSessionHandler, traxController.assignChecklistUser )
|
|
31
31
|
.post( '/updateAssign', isAllowedSessionHandler, traxController.updateAssign )
|
|
32
32
|
.post( '/updateAiConfigure', isAllowedSessionHandler, traxController.updateAiConfigure )
|
|
33
|
-
.get( '/getAiDetails', isAllowedSessionHandler, traxController.getAiDetails )
|
|
34
|
-
|
|
35
|
-
.post( '/updateRunAIFeatures', isAllowedSessionHandler, traxController.updateRunAIFeatures )
|
|
36
|
-
.post( '/updateRunAIRequest', isAllowedSessionHandler, validate( runAIRequestValidation ), traxController.updateRunAIRequest )
|
|
37
|
-
.post( '/createChecklistName', isAllowedSessionHandler, validate( createChecklistNameValidation ), traxController.createChecklistName );
|
|
33
|
+
.get( '/getAiDetails', isAllowedSessionHandler, traxController.getAiDetails );
|
|
34
|
+
;
|
|
38
35
|
|
|
39
36
|
// isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'checklist', permissions: [ ] } ] } ),
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import model from 'tango-api-schema';
|
|
2
|
-
|
|
3
|
-
export const findOne = async ( query={}, field={} ) => {
|
|
4
|
-
return model.runAIFeaturesModel.findOne( query, field );
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const find = async ( query={}, field={} ) => {
|
|
8
|
-
return model.runAIFeaturesModel.find( query, field );
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const create = async ( document = {} ) => {
|
|
12
|
-
return model.runAIFeaturesModel.create( document );
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const deleteOne = async ( query = {} ) => {
|
|
16
|
-
return model.runAIFeaturesModel.deleteOne( query );
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const updateOne = async ( query = {}, record={} ) => {
|
|
20
|
-
return model.runAIFeaturesModel.updateOne( query, { $set: record }, { upsert: true } );
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const aggregate = async ( query = {} ) => {
|
|
24
|
-
return model.runAIFeaturesModel.aggregate( query );
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const count = async ( query = {} ) => {
|
|
28
|
-
return model.runAIFeaturesModel.countDocuments( query );
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import model from 'tango-api-schema';
|
|
2
|
-
|
|
3
|
-
export const findOne = async ( query={}, field={} ) => {
|
|
4
|
-
return model.runAIRequestModel.findOne( query, field );
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const find = async ( query={}, field={} ) => {
|
|
8
|
-
return model.runAIRequestModel.find( query, field );
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const create = async ( document = {} ) => {
|
|
12
|
-
return model.runAIRequestModel.create( document );
|
|
13
|
-
};
|
|
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
|
-
|
|
23
|
-
export const deleteOne = async ( query = {} ) => {
|
|
24
|
-
return model.runAIRequestModel.deleteOne( query );
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const updateOne = async ( query = {}, record={} ) => {
|
|
28
|
-
return model.runAIRequestModel.updateOne( query, { $set: record } );
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const aggregate = async ( query = {} ) => {
|
|
32
|
-
return model.runAIRequestModel.aggregate( query );
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const count = async ( query = {} ) => {
|
|
36
|
-
return model.runAIRequestModel.countDocuments( query );
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
|