tango-app-api-trax 3.6.0-sec-7 → 3.6.0-sec-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
|
@@ -295,6 +295,13 @@ export async function PCLconfigCreation( req, res ) {
|
|
|
295
295
|
isdeleted: false,
|
|
296
296
|
},
|
|
297
297
|
} );
|
|
298
|
+
|
|
299
|
+
sectionQuery.push( {
|
|
300
|
+
$sort: {
|
|
301
|
+
sectionNumber: 1,
|
|
302
|
+
},
|
|
303
|
+
} );
|
|
304
|
+
|
|
298
305
|
let getSections = await CLquestions.aggregate( sectionQuery );
|
|
299
306
|
if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection', 'customerunattended', 'staffleftinthemiddle', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'queuealert', 'cleaning', 'scrum', 'suspiciousactivity', 'boxalert', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in' ].includes( getCLconfig.checkListType ) ) {
|
|
300
307
|
if ( getSections.length ) {
|
|
@@ -2462,3 +2469,43 @@ export async function storecheckExists( data ) {
|
|
|
2462
2469
|
logger.error( { error: error, function: 'internalAISendPushNotification' } );
|
|
2463
2470
|
}
|
|
2464
2471
|
}
|
|
2472
|
+
|
|
2473
|
+
export async function insertAINotification( req, res ) {
|
|
2474
|
+
try {
|
|
2475
|
+
let requestData = req.body;
|
|
2476
|
+
let insertData= [];
|
|
2477
|
+
let findAllUser = await userService.find( { clientId: requestData.clientId, isActive: true } );
|
|
2478
|
+
for ( let user of findAllUser ) {
|
|
2479
|
+
let data= {};
|
|
2480
|
+
data.userId = user._id;
|
|
2481
|
+
data.storeId = requestData.storeId;
|
|
2482
|
+
data.storeName = requestData.storeName;
|
|
2483
|
+
data.captureTime = requestData.captureTime;
|
|
2484
|
+
data.clientId = requestData.clientId;
|
|
2485
|
+
data.sourceCheckList_id = requestData.sourceCheckList_id;
|
|
2486
|
+
data.checkListName = requestData.checkListName;
|
|
2487
|
+
data.notificationType = requestData.notificationType;
|
|
2488
|
+
let payload = {
|
|
2489
|
+
userType: user.userType,
|
|
2490
|
+
role: user.role,
|
|
2491
|
+
assignedStores: user.assignedStores,
|
|
2492
|
+
clientId: user.clientId,
|
|
2493
|
+
email: user.email,
|
|
2494
|
+
};
|
|
2495
|
+
let result = await storecheckExists( payload );
|
|
2496
|
+
if ( result ) {
|
|
2497
|
+
insertData.push( data );
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
// console.log( 'insertData =>', insertData );
|
|
2501
|
+
let create = await notificationModel.insertManynotificationModel( insertData );
|
|
2502
|
+
// console.log( 'create =>', create );
|
|
2503
|
+
if ( create ) {
|
|
2504
|
+
return res.sendSuccess( 'updated successfully' );
|
|
2505
|
+
}
|
|
2506
|
+
} catch ( e ) {
|
|
2507
|
+
logger.error( { error: e, function: 'insertAINotification' } );
|
|
2508
|
+
if ( e.name === 'ValidationError' ) res.sendBadRequest( e );
|
|
2509
|
+
else res.sendError( e, 500 );
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
@@ -611,47 +611,47 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
|
|
|
611
611
|
return res.sendError( 'Please Fill all Required Fields', 400 );
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
-
if ( requestData.submittype == 'submit' ) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
614
|
+
// if ( requestData.submittype == 'submit' ) {
|
|
615
|
+
let reqAnswers = requestData.questionAnswers;
|
|
616
|
+
logger.error( { functionName: 'payload', message: reqAnswers } );
|
|
617
|
+
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
618
|
+
logger.error( { functionName: 'CLQAnswers', message: CLQAnswers } );
|
|
619
|
+
let validationCount= 0;
|
|
620
|
+
let errorCount = 0;
|
|
621
|
+
CLQAnswers.forEach( ( section ) => {
|
|
622
|
+
let requestSection = reqAnswers.filter( ( reqSection ) => reqSection.sectionName == section?.sectionOldName || reqSection.sectionName == section?.sectionName );
|
|
623
|
+
if ( requestSection.length ) {
|
|
624
|
+
requestSection.forEach( ( item ) => item.section_id = section.section_id );
|
|
625
|
+
section.questions.forEach( ( question ) => {
|
|
626
|
+
// question.answers.forEach( ( answer ) => {
|
|
627
|
+
let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
|
|
628
|
+
if ( sectionQuestion.length ) {
|
|
629
|
+
if ( question.answerType == 'multiplechoicemultiple' && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
|
|
630
|
+
validationCount++;
|
|
631
|
+
} else {
|
|
632
|
+
if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
|
|
630
633
|
validationCount++;
|
|
631
|
-
} else {
|
|
632
|
-
if ( ![ 'multiplechoicemultiple', 'multipleImage' ].includes( question.answerType ) && ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) ) {
|
|
633
|
-
validationCount++;
|
|
634
|
-
}
|
|
635
634
|
}
|
|
636
|
-
} else {
|
|
637
|
-
errorCount++;
|
|
638
635
|
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
}
|
|
644
|
-
} );
|
|
645
|
-
if ( validationCount ) {
|
|
646
|
-
return res.sendError( 'Please Fill all Required Fields', 400 );
|
|
647
|
-
} else if ( errorCount ) {
|
|
648
|
-
return res.sendError( 'Checklist got edited.please contact admin', 400 );
|
|
636
|
+
} else {
|
|
637
|
+
errorCount++;
|
|
638
|
+
}
|
|
639
|
+
// } );
|
|
640
|
+
} );
|
|
649
641
|
} else {
|
|
650
|
-
|
|
642
|
+
errorCount++;
|
|
651
643
|
}
|
|
644
|
+
} );
|
|
645
|
+
if ( validationCount && requestData.submittype == 'submit' ) {
|
|
646
|
+
return res.sendError( 'Please Fill all Required Fields', 400 );
|
|
647
|
+
} else if ( errorCount && !requestData?.editSubmit ) {
|
|
648
|
+
return res.sendError( 'Checklist got edited.please contact admin', 400 );
|
|
652
649
|
} else {
|
|
653
650
|
next();
|
|
654
651
|
}
|
|
652
|
+
// } else {
|
|
653
|
+
// next();
|
|
654
|
+
// }
|
|
655
655
|
} catch ( e ) {
|
|
656
656
|
logger.error( { function: 'sopMobilechecklistQuestionValidator', error: e, body: req.body } );
|
|
657
657
|
return res.sendError( e, 500 );
|
|
@@ -2969,6 +2969,11 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
|
|
|
2969
2969
|
isdeleted: false,
|
|
2970
2970
|
},
|
|
2971
2971
|
} );
|
|
2972
|
+
sectionQuery.push( {
|
|
2973
|
+
$sort: {
|
|
2974
|
+
sectionNumber: 1,
|
|
2975
|
+
},
|
|
2976
|
+
} );
|
|
2972
2977
|
let getSections = await questionService.aggregate( sectionQuery );
|
|
2973
2978
|
if ( getSections.length || [ 'storeopenandclose', 'mobileusagedetection', 'uniformdetection' ].includes( getCLconfig.checkListType ) ) {
|
|
2974
2979
|
if ( getSections.length ) {
|
|
@@ -3719,7 +3724,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3719
3724
|
await processedchecklist.deleteMany( { date_string: insertdata.date_string,
|
|
3720
3725
|
date_iso: insertdata.date_iso,
|
|
3721
3726
|
client_id: insertdata.client_id,
|
|
3722
|
-
checkListId: updatedchecklist._id, checklistStatus: 'open' } );
|
|
3727
|
+
checkListId: updatedchecklist._id, checklistStatus: 'open', redoStatus: false } );
|
|
3723
3728
|
|
|
3724
3729
|
|
|
3725
3730
|
let actionType = 'deleteOpenUsers';
|
|
@@ -3733,7 +3738,18 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3733
3738
|
date_iso: insertdata.date_iso,
|
|
3734
3739
|
client_id: insertdata.client_id,
|
|
3735
3740
|
checkListId: updatedchecklist._id,
|
|
3736
|
-
checklistStatus: 'inprogress',
|
|
3741
|
+
// checklistStatus: 'inprogress',
|
|
3742
|
+
$or: [
|
|
3743
|
+
{
|
|
3744
|
+
$and: [
|
|
3745
|
+
{ checklistStatus: 'open' },
|
|
3746
|
+
{ redoStatus: true },
|
|
3747
|
+
],
|
|
3748
|
+
},
|
|
3749
|
+
{
|
|
3750
|
+
checklistStatus: 'inprogress',
|
|
3751
|
+
},
|
|
3752
|
+
],
|
|
3737
3753
|
}, { userId: 1, store_id: 1 } );
|
|
3738
3754
|
|
|
3739
3755
|
if ( inprogressData.length ) {
|
|
@@ -3752,7 +3768,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3752
3768
|
}
|
|
3753
3769
|
|
|
3754
3770
|
if ( deletedList.length ) {
|
|
3755
|
-
await processedchecklist.deleteMany( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, _id: { $in: deletedList } } );
|
|
3771
|
+
await processedchecklist.deleteMany( { date_string: insertdata.date_string, date_iso: insertdata.date_iso, client_id: insertdata.client_id, checkListId: updatedchecklist._id, _id: { $in: deletedList }, redoStatus: false } );
|
|
3756
3772
|
}
|
|
3757
3773
|
await processedchecklist.insertMany( assignUserList );
|
|
3758
3774
|
actionType = 'insertAssignUsers';
|
|
@@ -24,6 +24,7 @@ internalTraxRouter
|
|
|
24
24
|
.post( '/sendPushNotification', isAllowedInternalAPIHandler, internalController.internalSendPushNotification )
|
|
25
25
|
.post( '/sendAiPushNotification', isAllowedInternalAPIHandler, internalController.internalAISendPushNotification )
|
|
26
26
|
.post( '/getLiveChecklistClients', isAllowedInternalAPIHandler, internalController.getLiveChecklistClients )
|
|
27
|
-
.post( '/notificationCreate', isAllowedInternalAPIHandler, internalController.notificationCreate )
|
|
27
|
+
.post( '/notificationCreate', isAllowedInternalAPIHandler, internalController.notificationCreate )
|
|
28
|
+
.post( '/insertAINotification', isAllowedInternalAPIHandler, internalController.insertAINotification );
|
|
28
29
|
|
|
29
30
|
|