tango-app-api-trax 3.7.47 → 3.7.49
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-trax",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.49",
|
|
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.5.
|
|
30
|
+
"tango-api-schema": "^2.5.57",
|
|
31
31
|
"tango-app-api-middleware": "^3.5.2",
|
|
32
32
|
"url": "^0.11.4",
|
|
33
33
|
"winston": "^3.13.1",
|
|
@@ -620,7 +620,7 @@ export const flagCardsV1 = async ( req, res ) => {
|
|
|
620
620
|
const detectionPayload = { fromDate, toDate, storeId, clientId };
|
|
621
621
|
const lambdaURL = 'https://f65azvtljclaxp6l7rnx65cdmm0lcgvp.lambda-url.ap-south-1.on.aws/';
|
|
622
622
|
const resultData = await LamdaServiceCall( lambdaURL, detectionPayload );
|
|
623
|
-
|
|
623
|
+
|
|
624
624
|
|
|
625
625
|
const published = publishedAiChecklists.map( ( val ) => val?.checkListType );
|
|
626
626
|
|
|
@@ -2022,7 +2022,7 @@ export const flagChecklistCardsV1 = async ( req, res ) => {
|
|
|
2022
2022
|
client_id: reqestData.clientId,
|
|
2023
2023
|
sourceCheckList_id: new mongoose.Types.ObjectId( reqestData.sourceCheckList_id ),
|
|
2024
2024
|
// store_id: { $in: reqestData.storeId },
|
|
2025
|
-
$or: [ { store_id: { $in: reqestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: reqestData.userEmailes } } ],
|
|
2025
|
+
$or: [ { store_id: { $in: reqestData.storeId } }, { aiStoreList: { $in: reqestData.storeId } }, { store_id: { $eq: '' }, userEmail: { $in: reqestData.userEmailes } } ],
|
|
2026
2026
|
},
|
|
2027
2027
|
},
|
|
2028
2028
|
{
|
|
@@ -2038,9 +2038,11 @@ export const flagChecklistCardsV1 = async ( req, res ) => {
|
|
|
2038
2038
|
},
|
|
2039
2039
|
];
|
|
2040
2040
|
const checklist = await aggregate( pipeline );
|
|
2041
|
+
console.log( '🚀 ~ flagChecklistCardsV1 ~ checklist:', checklist );
|
|
2041
2042
|
reqestData.storeCount = checklist[0]?.storeCount | 0;
|
|
2042
2043
|
let LamdaURL = 'https://k462fpztd3zaucty5ruoks6z540qqgqj.lambda-url.ap-south-1.on.aws/';
|
|
2043
2044
|
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
2045
|
+
console.log( '🚀 ~ flagChecklistCardsV1 ~ resultData:', resultData );
|
|
2044
2046
|
if ( resultData ) {
|
|
2045
2047
|
if ( resultData.status_code == '200' ) {
|
|
2046
2048
|
if ( resultData.customerunattendedCards && resultData.customerunattendedCards.timeTakentoAssistsec && resultData.customerunattendedCards.timeTakentoAssistsec.secs ) {
|
|
@@ -180,7 +180,7 @@ export const create = async ( req, res ) => {
|
|
|
180
180
|
{ $match: { client_id: req.body.clientId, type: 'checklist' } },
|
|
181
181
|
{ $group: { _id: null, maxCheckListNumber: { $max: '$checkListNumber' } } },
|
|
182
182
|
] );
|
|
183
|
-
checkNumber = result.length > 0 ? result[0].maxCheckListNumber+1 : 0;
|
|
183
|
+
checkNumber = result.length > 0 ? result[0].maxCheckListNumber + 1 : 0;
|
|
184
184
|
|
|
185
185
|
let runAIQuestionCount = 0;
|
|
186
186
|
|
|
@@ -192,7 +192,7 @@ export const create = async ( req, res ) => {
|
|
|
192
192
|
questionCount = questionCount + element?.questions?.length;
|
|
193
193
|
}
|
|
194
194
|
let runAiQuestions = element?.questions.filter( ( qn ) => qn.runAI );
|
|
195
|
-
runAIQuestionCount +=runAiQuestions.length;
|
|
195
|
+
runAIQuestionCount += runAiQuestions.length;
|
|
196
196
|
} );
|
|
197
197
|
|
|
198
198
|
let checkListDetails = {
|
|
@@ -268,12 +268,12 @@ export const create = async ( req, res ) => {
|
|
|
268
268
|
|
|
269
269
|
let maxQID = 0;
|
|
270
270
|
if ( section.questions && section.questions.length > 0 ) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
271
|
+
// let qids = section.questions
|
|
272
|
+
// .filter( ( q ) => q.uniqueqno != null )
|
|
273
|
+
// .map( ( q ) => Number( q.uniqueqno ) );
|
|
274
|
+
// console.log( 'Extracted QIDs =>', qids );
|
|
275
|
+
// let maxQID = Math.max( 0, ...qids );
|
|
276
|
+
// console.log( 'maxQID =>', maxQID );
|
|
277
277
|
|
|
278
278
|
for ( let [ index1, questions ] of section.questions.entries() ) {
|
|
279
279
|
if ( !questions.uniqueqno ) {
|
|
@@ -290,7 +290,7 @@ export const create = async ( req, res ) => {
|
|
|
290
290
|
await processNested( index, question );
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
async function processNested( qIdx, question, nestedIndex
|
|
293
|
+
async function processNested( qIdx, question, nestedIndex = -1 ) {
|
|
294
294
|
if ( question?.answers?.length ) {
|
|
295
295
|
for ( let [ index, answer ] of question?.answers?.entries() ) {
|
|
296
296
|
if ( !section.questions[qIdx].answers[index]?.nestedQuestion && nestedIndex == -1 ) {
|
|
@@ -339,7 +339,7 @@ export const create = async ( req, res ) => {
|
|
|
339
339
|
let teamsMsg;
|
|
340
340
|
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
341
341
|
actionType = 'Create';
|
|
342
|
-
teamsMsg = 'ClientId: '+ req.body.clientId + ', Action: '+ actionType + ', ChecklistId: '+ checkListId + ', Checklist Name: '+ inputBody.checklistName + ', UpDatedBy: '+ req.user.email;
|
|
342
|
+
teamsMsg = 'ClientId: ' + req.body.clientId + ', Action: ' + actionType + ', ChecklistId: ' + checkListId + ', Checklist Name: ' + inputBody.checklistName + ', UpDatedBy: ' + req.user.email;
|
|
343
343
|
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
344
344
|
|
|
345
345
|
let logObj = {
|
|
@@ -541,7 +541,7 @@ export const getConfigDetails = async ( req, res ) => {
|
|
|
541
541
|
return { id: item.assignId, type: 'cluster' };
|
|
542
542
|
} );
|
|
543
543
|
} else {
|
|
544
|
-
singleAssign = assignList.filter( ( item ) => typeof item?.userEmail != 'undefined' && item?.userEmail !='' ).map( ( item ) => {
|
|
544
|
+
singleAssign = assignList.filter( ( item ) => typeof item?.userEmail != 'undefined' && item?.userEmail != '' ).map( ( item ) => {
|
|
545
545
|
return { id: item.assignId, type: 'user' };
|
|
546
546
|
} );
|
|
547
547
|
groupAssign = assignList.filter( ( item ) => typeof item?.teamName != 'undefined' && item?.teamName != '' ).map( ( item ) => {
|
|
@@ -597,9 +597,14 @@ export const zoneList = async ( req, res ) => {
|
|
|
597
597
|
'Store Half Shutter Detection',
|
|
598
598
|
'Mobile usage detection',
|
|
599
599
|
'Store TV Compliance',
|
|
600
|
+
'Queue Wait Time Breach',
|
|
601
|
+
];
|
|
602
|
+
const allowedChecklistsStreams = [
|
|
603
|
+
'Camera Angle Change Compliance',
|
|
600
604
|
];
|
|
601
605
|
|
|
602
606
|
if ( inputBody.checkListName && allowedChecklists.includes( inputBody.checkListName ) ) {
|
|
607
|
+
console.log( '==================' );
|
|
603
608
|
let query = [
|
|
604
609
|
{
|
|
605
610
|
$match: {
|
|
@@ -627,6 +632,8 @@ export const zoneList = async ( req, res ) => {
|
|
|
627
632
|
}
|
|
628
633
|
|
|
629
634
|
return res.sendSuccess( zoneList );
|
|
635
|
+
} else if ( inputBody.checkListName && allowedChecklistsStreams.includes( inputBody.checkListName ) ) {
|
|
636
|
+
return res.sendSuccess( [ { zone: 'Camera Angle Change Compliance' } ] );
|
|
630
637
|
} else {
|
|
631
638
|
let query = [
|
|
632
639
|
{
|
|
@@ -803,7 +810,7 @@ export const deleteChecklist = async ( req, res ) => {
|
|
|
803
810
|
let actionType = 'Deleted';
|
|
804
811
|
let teamsMsg;
|
|
805
812
|
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
806
|
-
teamsMsg = 'ClientId: '+ checklistDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ req.params.checklistId + ', Checklist Name: '+ checklistDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
813
|
+
teamsMsg = 'ClientId: ' + checklistDetails.client_id + ', Action: ' + actionType + ', ChecklistId: ' + req.params.checklistId + ', Checklist Name: ' + checklistDetails.checkListName + ', UpDatedBy: ' + req.user.email;
|
|
807
814
|
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
808
815
|
|
|
809
816
|
let logObj = {
|
|
@@ -851,7 +858,7 @@ export const duplicateChecklist = async ( req, res ) => {
|
|
|
851
858
|
let checkListNameDetails = await checklistService.find( { checkListName: { $regex: name }, client_id: req.query.clientId, type: 'checklist' } );
|
|
852
859
|
if ( checkListNameDetails.length ) {
|
|
853
860
|
let nameLength = checkListNameDetails.length + 1;
|
|
854
|
-
dupDetails.checkListName = dupDetails.checkListName.split( '(' )[0] + '(' + nameLength +')';
|
|
861
|
+
dupDetails.checkListName = dupDetails.checkListName.split( '(' )[0] + '(' + nameLength + ')';
|
|
855
862
|
} else {
|
|
856
863
|
dupDetails.checkListName = dupDetails.checkListName + '(1)';
|
|
857
864
|
}
|
|
@@ -859,7 +866,7 @@ export const duplicateChecklist = async ( req, res ) => {
|
|
|
859
866
|
dupDetails.createdAt = new Date();
|
|
860
867
|
dupDetails.updatedAt = new Date();
|
|
861
868
|
dupDetails.publishDate = '';
|
|
862
|
-
dupDetails.checkListNumber = dupDetails.checkListNumber+1;
|
|
869
|
+
dupDetails.checkListNumber = dupDetails.checkListNumber + 1;
|
|
863
870
|
dupDetails.rawImageUpload = false;
|
|
864
871
|
dupDetails.rawVideoUpload = false;
|
|
865
872
|
dupDetails.videoUploadTimeLimit = 0;
|
|
@@ -890,7 +897,7 @@ export const duplicateChecklist = async ( req, res ) => {
|
|
|
890
897
|
}
|
|
891
898
|
let sectionList = await questionService.findSort( { checkListId: checkDetails._id, client_id: req.query.clientId, isdeleted: false }, {}, { sectionNumber: 1 } );
|
|
892
899
|
if ( sectionList.length ) {
|
|
893
|
-
let sections= [];
|
|
900
|
+
let sections = [];
|
|
894
901
|
for ( let i = 0; i < sectionList.length; i++ ) {
|
|
895
902
|
let sectionDetails = { ...sectionList[i]._doc };
|
|
896
903
|
sectionDetails.checkListId = data._id;
|
|
@@ -915,8 +922,8 @@ export const duplicateChecklist = async ( req, res ) => {
|
|
|
915
922
|
let actionType = 'Duplicated';
|
|
916
923
|
let teamsMsg;
|
|
917
924
|
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
918
|
-
if ( teamsAlertUrls && teamsAlertUrls !='' ) {
|
|
919
|
-
teamsMsg = 'ClientId: '+ checkDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ data._id + ', Checklist Name: '+ checkDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
925
|
+
if ( teamsAlertUrls && teamsAlertUrls != '' ) {
|
|
926
|
+
teamsMsg = 'ClientId: ' + checkDetails.client_id + ', Action: ' + actionType + ', ChecklistId: ' + data._id + ', Checklist Name: ' + checkDetails.checkListName + ', UpDatedBy: ' + req.user.email;
|
|
920
927
|
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
921
928
|
}
|
|
922
929
|
|
|
@@ -984,7 +991,7 @@ export const update = async ( req, res ) => {
|
|
|
984
991
|
questionCount = questionCount + element.questions.length;
|
|
985
992
|
}
|
|
986
993
|
let runAiQuestions = element?.questions.filter( ( qn ) => qn.runAI );
|
|
987
|
-
runAIQuestionCount +=runAiQuestions.length;
|
|
994
|
+
runAIQuestionCount += runAiQuestions.length;
|
|
988
995
|
} );
|
|
989
996
|
|
|
990
997
|
|
|
@@ -1008,7 +1015,7 @@ export const update = async ( req, res ) => {
|
|
|
1008
1015
|
// createdByEmail: req.user.email,
|
|
1009
1016
|
// };
|
|
1010
1017
|
// await checklistLogs.create( logInsertData );
|
|
1011
|
-
let sectionList =[];
|
|
1018
|
+
let sectionList = [];
|
|
1012
1019
|
if ( inputBody.sections.length ) {
|
|
1013
1020
|
for ( let i = 0; i < inputBody?.sections?.length; i++ ) {
|
|
1014
1021
|
let section = inputBody.sections[i];
|
|
@@ -1063,7 +1070,7 @@ export const update = async ( req, res ) => {
|
|
|
1063
1070
|
await processNested( index, question );
|
|
1064
1071
|
}
|
|
1065
1072
|
|
|
1066
|
-
async function processNested( qIdx, question, nestedIndex
|
|
1073
|
+
async function processNested( qIdx, question, nestedIndex = -1 ) {
|
|
1067
1074
|
if ( question?.answers?.length ) {
|
|
1068
1075
|
for ( let [ index, answer ] of question?.answers?.entries() ) {
|
|
1069
1076
|
if ( !section.questions[qIdx].answers[index]?.nestedQuestion && nestedIndex == -1 ) {
|
|
@@ -1207,14 +1214,18 @@ export const update = async ( req, res ) => {
|
|
|
1207
1214
|
createdBy: req.user.userName,
|
|
1208
1215
|
coverage: checkListDetails.coverage,
|
|
1209
1216
|
logDetails: {
|
|
1210
|
-
...( inputBody.checklistName.toLowerCase() == checkListDetails.checkListName.toLowerCase() ) ? { updatedChecklistName: {} } :
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1217
|
+
...( inputBody.checklistName.toLowerCase() == checkListDetails.checkListName.toLowerCase() ) ? { updatedChecklistName: {} } : {
|
|
1218
|
+
updatedChecklistName: {
|
|
1219
|
+
previous: checkListDetails.checkListName,
|
|
1220
|
+
new: inputBody.checklistName,
|
|
1221
|
+
},
|
|
1222
|
+
},
|
|
1223
|
+
...( inputBody.checklistDescription.toLowerCase() == checkListDetails.checkListDescription.toLowerCase() ) ? { updatedChecklistDescription: {} } : {
|
|
1224
|
+
updatedChecklistDescription: {
|
|
1225
|
+
previous: checkListDetails.checkListDescription,
|
|
1226
|
+
new: inputBody.checklistDescription,
|
|
1227
|
+
},
|
|
1228
|
+
},
|
|
1218
1229
|
updatedSectionName: updateSection,
|
|
1219
1230
|
questionAdd: questionList.questionAdd,
|
|
1220
1231
|
questionEdit: questionList.questionEdit,
|
|
@@ -1227,7 +1238,7 @@ export const update = async ( req, res ) => {
|
|
|
1227
1238
|
// / Teams Alert
|
|
1228
1239
|
let teamsMsg;
|
|
1229
1240
|
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
1230
|
-
teamsMsg = 'ClientId: '+ insertLogData.client_id + ', Type: Checklist, Action: Checklist Question Edited, ChecklistId: '+ insertLogData.sourceCheckList_id + ', Checklist Name: '+ insertLogData.checkListName +', UpDatedBy: '+ req.user.email;
|
|
1241
|
+
teamsMsg = 'ClientId: ' + insertLogData.client_id + ', Type: Checklist, Action: Checklist Question Edited, ChecklistId: ' + insertLogData.sourceCheckList_id + ', Checklist Name: ' + insertLogData.checkListName + ', UpDatedBy: ' + req.user.email;
|
|
1231
1242
|
if ( teamsAlertUrls && teamsAlertUrls.questionEditAlert ) {
|
|
1232
1243
|
sendTeamsNotification( teamsAlertUrls.questionEditAlert, teamsMsg );
|
|
1233
1244
|
}
|
|
@@ -1285,7 +1296,7 @@ export const update = async ( req, res ) => {
|
|
|
1285
1296
|
let actionType = 'Checklist Updated';
|
|
1286
1297
|
let teamsMsg;
|
|
1287
1298
|
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
1288
|
-
teamsMsg = 'ClientId: '+ req.body.clientId + ', Action: '+ actionType + ', ChecklistId: '+ checkListId + ', Checklist Name: '+ inputBody.checklistName + ', UpDatedBy: '+ req.user.email;
|
|
1299
|
+
teamsMsg = 'ClientId: ' + req.body.clientId + ', Action: ' + actionType + ', ChecklistId: ' + checkListId + ', Checklist Name: ' + inputBody.checklistName + ', UpDatedBy: ' + req.user.email;
|
|
1289
1300
|
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
1290
1301
|
return res.sendSuccess( { message: 'CheckList Updated Successfully', checklistId: req.params.checklistId } );
|
|
1291
1302
|
} catch ( e ) {
|
|
@@ -1579,7 +1590,7 @@ export const runAIInsert = async ( req, res ) => {
|
|
|
1579
1590
|
}
|
|
1580
1591
|
};
|
|
1581
1592
|
|
|
1582
|
-
export const updateConfigure =async ( req, res ) => {
|
|
1593
|
+
export const updateConfigure = async ( req, res ) => {
|
|
1583
1594
|
try {
|
|
1584
1595
|
let inputBody = req.body;
|
|
1585
1596
|
let storeCount = 0;
|
|
@@ -1724,7 +1735,7 @@ export const updateConfigure =async ( req, res ) => {
|
|
|
1724
1735
|
let name = checklistDetails.checkListName.split( '(' )[0];
|
|
1725
1736
|
let checkListNameDetails = await checklistService.find( { checkListName: { $regex: name }, client_id: req.body.clientId, type: 'checklist', isdeleted: false } );
|
|
1726
1737
|
if ( checkListNameDetails.length ) {
|
|
1727
|
-
let nameLength = ( checkListNameDetails.length-1 ) + 1;
|
|
1738
|
+
let nameLength = ( checkListNameDetails.length - 1 ) + 1;
|
|
1728
1739
|
checklistDetails.checkListName = checklistDetails.checkListName.split( '(' )[0] + '(' + nameLength + ')';
|
|
1729
1740
|
} else {
|
|
1730
1741
|
checklistDetails.checkListName = checklistDetails.checkListName;
|
|
@@ -1737,15 +1748,15 @@ export const updateConfigure =async ( req, res ) => {
|
|
|
1737
1748
|
} else {
|
|
1738
1749
|
configDetails.checkListNumber = 1;
|
|
1739
1750
|
}
|
|
1740
|
-
configDetails.createdBy= req.user._id;
|
|
1741
|
-
configDetails.createdByName=req.user.userName;
|
|
1751
|
+
configDetails.createdBy = req.user._id;
|
|
1752
|
+
configDetails.createdByName = req.user.userName;
|
|
1742
1753
|
delete inputBody.checkListDetails['_id'];
|
|
1743
1754
|
if ( [ 'storeopenandclose', 'uniformdetection' ].includes( checklistDetails.checkListType ) ) {
|
|
1744
1755
|
let query = { client_id: req.body.clientId, type: 'checklist', isdeleted: false };
|
|
1745
1756
|
if ( checklistDetails.checkListType == 'storeopenandclose' ) {
|
|
1746
|
-
query.checkListType= 'storeopenandclose';
|
|
1757
|
+
query.checkListType = 'storeopenandclose';
|
|
1747
1758
|
} else {
|
|
1748
|
-
query.checkListType= 'uniformdetection';
|
|
1759
|
+
query.checkListType = 'uniformdetection';
|
|
1749
1760
|
}
|
|
1750
1761
|
let storeChecklisDetails = await checklistService.findOne( query );
|
|
1751
1762
|
if ( storeChecklisDetails ) {
|
|
@@ -1779,7 +1790,7 @@ export const updateConfigure =async ( req, res ) => {
|
|
|
1779
1790
|
let storeDetails = await assignedService.find( { checkListId: id, checkFlag: true }, { _id: 0, store_id: 1, userEmail: 1 } );
|
|
1780
1791
|
let storeList = storeDetails.map( ( store ) => store.store_id );
|
|
1781
1792
|
let emailList = storeDetails.map( ( user ) => user.userEmail );
|
|
1782
|
-
let userChunk =await chunkArray( emailList, 10 );
|
|
1793
|
+
let userChunk = await chunkArray( emailList, 10 );
|
|
1783
1794
|
|
|
1784
1795
|
await Promise.all( userChunk.map( async ( chunk ) => {
|
|
1785
1796
|
updateUserStore( chunk );
|
|
@@ -1869,7 +1880,7 @@ export const updateConfigure =async ( req, res ) => {
|
|
|
1869
1880
|
}
|
|
1870
1881
|
};
|
|
1871
1882
|
|
|
1872
|
-
export const updateConfigurev1 =async ( req, res ) => {
|
|
1883
|
+
export const updateConfigurev1 = async ( req, res ) => {
|
|
1873
1884
|
try {
|
|
1874
1885
|
console.log( '123' );
|
|
1875
1886
|
let inputBody = req.body;
|
|
@@ -1999,7 +2010,7 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
1999
2010
|
let name = checklistDetails.checkListName.split( '(' )[0];
|
|
2000
2011
|
let checkListNameDetails = await checklistService.find( { checkListName: { $regex: name }, client_id: req.body.clientId, type: 'checklist', isdeleted: false } );
|
|
2001
2012
|
if ( checkListNameDetails.length ) {
|
|
2002
|
-
let nameLength = ( checkListNameDetails.length-1 ) + 1;
|
|
2013
|
+
let nameLength = ( checkListNameDetails.length - 1 ) + 1;
|
|
2003
2014
|
checklistDetails.checkListName = checklistDetails.checkListName.split( '(' )[0] + '(' + nameLength + ')';
|
|
2004
2015
|
} else {
|
|
2005
2016
|
checklistDetails.checkListName = checklistDetails.checkListName;
|
|
@@ -2012,15 +2023,15 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
2012
2023
|
} else {
|
|
2013
2024
|
configDetails.checkListNumber = 1;
|
|
2014
2025
|
}
|
|
2015
|
-
configDetails.createdBy= req.user._id;
|
|
2016
|
-
configDetails.createdByName=req.user.userName;
|
|
2026
|
+
configDetails.createdBy = req.user._id;
|
|
2027
|
+
configDetails.createdByName = req.user.userName;
|
|
2017
2028
|
delete inputBody.checkListDetails['_id'];
|
|
2018
2029
|
if ( [ 'storeopenandclose', 'uniformdetection' ].includes( checklistDetails.checkListType ) ) {
|
|
2019
2030
|
let query = { client_id: req.body.clientId, type: 'checklist', isdeleted: false };
|
|
2020
2031
|
if ( checklistDetails.checkListType == 'storeopenandclose' ) {
|
|
2021
|
-
query.checkListType= 'storeopenandclose';
|
|
2032
|
+
query.checkListType = 'storeopenandclose';
|
|
2022
2033
|
} else {
|
|
2023
|
-
query.checkListType= 'uniformdetection';
|
|
2034
|
+
query.checkListType = 'uniformdetection';
|
|
2024
2035
|
}
|
|
2025
2036
|
let storeChecklisDetails = await checklistService.findOne( query );
|
|
2026
2037
|
if ( storeChecklisDetails ) {
|
|
@@ -2110,26 +2121,26 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
2110
2121
|
logDetails: {
|
|
2111
2122
|
schedule: {
|
|
2112
2123
|
previous: {
|
|
2113
|
-
...( showSchedule && checklistDetails.schedule == 'onetime' ) ? { scheduleDateString: dayjs( checklistDetails?.scheduleDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
|
|
2124
|
+
...( showSchedule && checklistDetails.schedule == 'onetime' ) ? { scheduleDateString: dayjs( checklistDetails?.scheduleDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
|
|
2114
2125
|
schedule: showSchedule ? checklistDetails.schedule : '',
|
|
2115
2126
|
time: ( ( showSchedule ) && ( checklistDetails.scheduleStartTime != '' || checklistDetails.scheduleEndTime != '' ) ) ? checklistDetails.scheduleStartTime + ' to ' + checklistDetails.scheduleEndTime : '',
|
|
2116
2127
|
scheduleRepeatedDay: showSchedule ? checklistDetails?.scheduleRepeatedDay : '',
|
|
2117
2128
|
scheduleRepeatedType: showSchedule ? checklistDetails?.scheduleRepeatedType : '',
|
|
2118
|
-
...( showSchedule && checklistDetails?.configStartDate ) ? { configStartDate: dayjs( checklistDetails?.configStartDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
|
|
2119
|
-
...( showSchedule && checklistDetails?.configEndDate ) ? { configEndDate: dayjs( checklistDetails?.configEndDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
|
|
2129
|
+
...( showSchedule && checklistDetails?.configStartDate ) ? { configStartDate: dayjs( checklistDetails?.configStartDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
|
|
2130
|
+
...( showSchedule && checklistDetails?.configEndDate ) ? { configEndDate: dayjs( checklistDetails?.configEndDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
|
|
2120
2131
|
scheduleWeekDays: showSchedule ? checklistDetails?.scheduleWeekDays : [],
|
|
2121
2132
|
scheduleRepeatedMonthWeek: showSchedule ? checklistDetails?.scheduleRepeatedMonthWeek : '',
|
|
2122
2133
|
specificDate: showSchedule ? checklistDetails?.specificDate : [],
|
|
2123
2134
|
|
|
2124
2135
|
},
|
|
2125
2136
|
new: {
|
|
2126
|
-
...( showSchedule && configDetails.schedule == 'onetime' ) ? { scheduleDateString: dayjs( configDetails?.scheduleDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
|
|
2137
|
+
...( showSchedule && configDetails.schedule == 'onetime' ) ? { scheduleDateString: dayjs( configDetails?.scheduleDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
|
|
2127
2138
|
schedule: showSchedule ? configDetails.schedule : '',
|
|
2128
2139
|
time: ( ( showSchedule ) && ( configDetails.scheduleStartTime != '' || configDetails.scheduleEndTime != '' ) ) ? configDetails.scheduleStartTime + ' to ' + configDetails.scheduleEndTime : '',
|
|
2129
2140
|
scheduleRepeatedDay: showSchedule ? configDetails?.scheduleRepeatedDay : '',
|
|
2130
2141
|
scheduleRepeatedType: showSchedule ? configDetails?.scheduleRepeatedType : '',
|
|
2131
|
-
...( showSchedule && configDetails?.configStartDate ) ? { configStartDate: dayjs( configDetails?.configStartDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
|
|
2132
|
-
...( showSchedule && configDetails?.configEndDate ) ? { configEndDate: dayjs( configDetails?.configEndDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } :{},
|
|
2142
|
+
...( showSchedule && configDetails?.configStartDate ) ? { configStartDate: dayjs( configDetails?.configStartDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
|
|
2143
|
+
...( showSchedule && configDetails?.configEndDate ) ? { configEndDate: dayjs( configDetails?.configEndDate, 'YYYY-MM-DD' ).format( 'DD MMM, YYYY' ) } : {},
|
|
2133
2144
|
scheduleWeekDays: showSchedule ? configDetails?.scheduleWeekDays : [],
|
|
2134
2145
|
scheduleRepeatedMonthWeek: showSchedule ? configDetails?.scheduleRepeatedMonthWeek : '',
|
|
2135
2146
|
specificDate: showSchedule ? configDetails?.specificDate : [],
|
|
@@ -2138,29 +2149,35 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
2138
2149
|
response: {
|
|
2139
2150
|
previous: [
|
|
2140
2151
|
...( differences?.allowedStoreLocation && checklistDetails.allowedStoreLocation ? [ 'Geo fencing' ] : [] ),
|
|
2141
|
-
...( differences?.allowedMultiSubmit && checklistDetails.allowedMultiSubmit? [ 'Allow multiple responses' ] : [] ),
|
|
2152
|
+
...( differences?.allowedMultiSubmit && checklistDetails.allowedMultiSubmit ? [ 'Allow multiple responses' ] : [] ),
|
|
2142
2153
|
...( differences?.allowedOverTime && checklistDetails.allowedOverTime ? [ 'Fill response after configure time.' ] : [] ),
|
|
2143
2154
|
...( differences?.allowOnce && checklistDetails.allowOnce ? [ 'Only one time' ] : [] ),
|
|
2144
2155
|
],
|
|
2145
2156
|
new: [
|
|
2146
2157
|
...( differences?.allowedStoreLocation && configDetails.allowedStoreLocation ? [ 'Geo fencing' ] : [] ),
|
|
2147
|
-
...( differences?.allowedMultiSubmit && configDetails.allowedMultiSubmit? [ 'Allow multiple responses' ] : [] ),
|
|
2158
|
+
...( differences?.allowedMultiSubmit && configDetails.allowedMultiSubmit ? [ 'Allow multiple responses' ] : [] ),
|
|
2148
2159
|
...( differences?.allowedOverTime && configDetails.allowedOverTime ? [ 'Fill response after configure time' ] : [] ),
|
|
2149
2160
|
...( differences?.allowOnce && configDetails.allowOnce ? [ 'Only one time' ] : [] ),
|
|
2150
2161
|
],
|
|
2151
2162
|
},
|
|
2152
|
-
...( differences?.approver ) ? {
|
|
2153
|
-
|
|
2154
|
-
|
|
2163
|
+
...( differences?.approver ) ? {
|
|
2164
|
+
approver:
|
|
2165
|
+
{
|
|
2166
|
+
previous: checklistDetails?.approver.map( ( item ) => item.name ).toString(),
|
|
2167
|
+
new: configDetails?.approver.map( ( item ) => item.name ).toString(),
|
|
2168
|
+
},
|
|
2155
2169
|
} : { approver: {} },
|
|
2156
|
-
...( differences?.owner ) ? {
|
|
2157
|
-
|
|
2158
|
-
|
|
2170
|
+
...( differences?.owner ) ? {
|
|
2171
|
+
owner:
|
|
2172
|
+
{
|
|
2173
|
+
previous: checklistDetails?.owner.map( ( item ) => item.name ).toString(),
|
|
2174
|
+
new: configDetails?.owner.map( ( item ) => item.name ).toString(),
|
|
2175
|
+
},
|
|
2159
2176
|
} : { owner: {} },
|
|
2160
|
-
...( req.body.checkListDetails.coverage == 'store' ) ? { storeAdded: req.body.added } :{ storeAdded: [] },
|
|
2161
|
-
...( req.body.removed.store.length ) ? { storeRemoved: req.body.removed.store } :{ storeRemoved: [] },
|
|
2162
|
-
...( req.body.checkListDetails.coverage == 'user' ) ? { userAdded: req.body.added } :{ userAdded: [] },
|
|
2163
|
-
...( req.body.removed.user.length ) ? { userRemoved: req.body.removed.user } :{ userRemoved: [] },
|
|
2177
|
+
...( req.body.checkListDetails.coverage == 'store' ) ? { storeAdded: req.body.added } : { storeAdded: [] },
|
|
2178
|
+
...( req.body.removed.store.length ) ? { storeRemoved: req.body.removed.store } : { storeRemoved: [] },
|
|
2179
|
+
...( req.body.checkListDetails.coverage == 'user' ) ? { userAdded: req.body.added } : { userAdded: [] },
|
|
2180
|
+
...( req.body.removed.user.length ) ? { userRemoved: req.body.removed.user } : { userRemoved: [] },
|
|
2164
2181
|
},
|
|
2165
2182
|
userType: req.user.userType,
|
|
2166
2183
|
};
|
|
@@ -2190,7 +2207,7 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
2190
2207
|
let teamsMsg;
|
|
2191
2208
|
actionType = inputBody.checkListDetails.publish ? 'configPublish' : 'configDraft';
|
|
2192
2209
|
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
2193
|
-
teamsMsg = 'ClientId: '+ checklistDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ checklistDetails._id + ', Checklist Name: '+ checklistDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
2210
|
+
teamsMsg = 'ClientId: ' + checklistDetails.client_id + ', Action: ' + actionType + ', ChecklistId: ' + checklistDetails._id + ', Checklist Name: ' + checklistDetails.checkListName + ', UpDatedBy: ' + req.user.email;
|
|
2194
2211
|
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
2195
2212
|
if ( response?.modifiedCount || response?.matchedCount || response?.upsertedCount ) {
|
|
2196
2213
|
return res.sendSuccess( { id, message: 'Configured Updated Successfully' } );
|
|
@@ -2395,7 +2412,7 @@ export const updatePublish = async ( req, res ) => {
|
|
|
2395
2412
|
let teamsMsg;
|
|
2396
2413
|
actionType = req.body.publish ? 'publish' : 'unpublish';
|
|
2397
2414
|
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
2398
|
-
teamsMsg = 'ClientId: '+ getCheckDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ getCheckDetails._id + ', Checklist Name: '+ getCheckDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
2415
|
+
teamsMsg = 'ClientId: ' + getCheckDetails.client_id + ', Action: ' + actionType + ', ChecklistId: ' + getCheckDetails._id + ', Checklist Name: ' + getCheckDetails.checkListName + ', UpDatedBy: ' + req.user.email;
|
|
2399
2416
|
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
2400
2417
|
return res.sendSuccess( { checklistName: getCheckDetails.checkListName, message: 'Updated Successfully' } );
|
|
2401
2418
|
} catch ( e ) {
|
|
@@ -3017,7 +3034,7 @@ async function uploadUser( req, res ) {
|
|
|
3017
3034
|
}
|
|
3018
3035
|
}
|
|
3019
3036
|
|
|
3020
|
-
export async function insertSingleProcessData( checklistId, processId = 0, oldData = false, editSubmit = false, showEdit=false ) {
|
|
3037
|
+
export async function insertSingleProcessData( checklistId, processId = 0, oldData = false, editSubmit = false, showEdit = false ) {
|
|
3021
3038
|
try {
|
|
3022
3039
|
let currentdate = new Date();
|
|
3023
3040
|
let date = dayjs( currentdate ).format( 'YYYY-MM-DD' );
|
|
@@ -3037,7 +3054,7 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
|
|
|
3037
3054
|
newDate = dayjs( checkExists.date_string );
|
|
3038
3055
|
}
|
|
3039
3056
|
let diff = parseInt( dayjs.utc( date ).diff( newDate, 'day' ) );
|
|
3040
|
-
diff = diff < 9 ? '0'+ diff : diff;
|
|
3057
|
+
diff = diff < 9 ? '0' + diff : diff;
|
|
3041
3058
|
if ( diff == parseInt( getCLconfig.scheduleRepeatedDay[0] ) ) {
|
|
3042
3059
|
validation = true;
|
|
3043
3060
|
}
|
|
@@ -3058,7 +3075,7 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
|
|
|
3058
3075
|
let startWeek = dayjs.utc( newDate ).startOf( 'week' );
|
|
3059
3076
|
let endWeek = dayjs.utc( newDate ).clone().endOf( 'week' );
|
|
3060
3077
|
let diff = parseInt( dayjs( date ).diff( startWeek, 'week' ) );
|
|
3061
|
-
diff = diff < 9 ? '0'+diff : diff;
|
|
3078
|
+
diff = diff < 9 ? '0' + diff : diff;
|
|
3062
3079
|
if ( diff == getCLconfig.scheduleRepeatedDay[0] || ( startWeek.format( 'YYYY-MM-DD' ) <= date && endWeek.format( 'YYYY-MM-DD' ) >= date ) ) {
|
|
3063
3080
|
validation = true;
|
|
3064
3081
|
}
|
|
@@ -3086,11 +3103,11 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
|
|
|
3086
3103
|
}
|
|
3087
3104
|
|
|
3088
3105
|
if ( getCLconfig.scheduleRepeatedMonthWeek.split( ' ' )[0] == 5 ) {
|
|
3089
|
-
if ( days[days.length -1] == date ) {
|
|
3106
|
+
if ( days[days.length - 1] == date ) {
|
|
3090
3107
|
validation = true;
|
|
3091
3108
|
}
|
|
3092
3109
|
} else {
|
|
3093
|
-
if ( days[parseInt( getCLconfig.scheduleRepeatedMonthWeek.split( ' ' )[0] )-1] == date ) {
|
|
3110
|
+
if ( days[parseInt( getCLconfig.scheduleRepeatedMonthWeek.split( ' ' )[0] ) - 1] == date ) {
|
|
3094
3111
|
validation = true;
|
|
3095
3112
|
}
|
|
3096
3113
|
}
|
|
@@ -3113,7 +3130,7 @@ export async function insertSingleProcessData( checklistId, processId = 0, oldDa
|
|
|
3113
3130
|
let startMonth = newDate.startOf( 'month' );
|
|
3114
3131
|
let endMonth = newDate.clone().endOf( 'month' );
|
|
3115
3132
|
let diff = parseInt( dayjs.utc( date ).diff( startMonth, 'month' ) );
|
|
3116
|
-
diff = diff < 9 ? '0'+diff : diff;
|
|
3133
|
+
diff = diff < 9 ? '0' + diff : diff;
|
|
3117
3134
|
|
|
3118
3135
|
if ( diff == parseInt( getCLconfig.scheduleRepeatedDay[0] ) || ( startMonth.format( 'YYYY-MM-DD' ) <= date && endMonth.format( 'YYYY-MM-DD' ) >= date ) ) {
|
|
3119
3136
|
validation = true;
|
|
@@ -3731,7 +3748,8 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3731
3748
|
$and: [ {
|
|
3732
3749
|
date_iso: {
|
|
3733
3750
|
$gte: new Date( startDate.format( 'YYYY-MM-DD' ) ),
|
|
3734
|
-
$lte: new Date( endDate.format( 'YYYY-MM-DD' ) )
|
|
3751
|
+
$lte: new Date( endDate.format( 'YYYY-MM-DD' ) ),
|
|
3752
|
+
},
|
|
3735
3753
|
} ],
|
|
3736
3754
|
};
|
|
3737
3755
|
} else {
|
|
@@ -3955,16 +3973,18 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3955
3973
|
} else {
|
|
3956
3974
|
let deletedList = [];
|
|
3957
3975
|
|
|
3958
|
-
await processedchecklist.deleteMany( {
|
|
3976
|
+
await processedchecklist.deleteMany( {
|
|
3977
|
+
date_string: insertdata.date_string,
|
|
3959
3978
|
date_iso: insertdata.date_iso,
|
|
3960
3979
|
client_id: insertdata.client_id,
|
|
3961
|
-
checkListId: updatedchecklist._id, checklistStatus: 'open'
|
|
3980
|
+
checkListId: updatedchecklist._id, checklistStatus: 'open',
|
|
3981
|
+
} );
|
|
3962
3982
|
|
|
3963
3983
|
|
|
3964
3984
|
let actionType = 'deleteOpenUsers';
|
|
3965
3985
|
let teamsMsg;
|
|
3966
3986
|
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
3967
|
-
teamsMsg = 'ClientId: '+ insertdata.client_id + ', Action: '+ actionType + ', ChecklistId: '+ getCLconfig._id + ', Checklist Name: '+ getCLconfig.checkListName;
|
|
3987
|
+
teamsMsg = 'ClientId: ' + insertdata.client_id + ', Action: ' + actionType + ', ChecklistId: ' + getCLconfig._id + ', Checklist Name: ' + getCLconfig.checkListName;
|
|
3968
3988
|
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
3969
3989
|
|
|
3970
3990
|
let inprogressData = await processedchecklist.find( {
|
|
@@ -3997,7 +4017,7 @@ async function insertPCBulkV4( getCLconfig, checklistId, currentdate, updatedche
|
|
|
3997
4017
|
actionType = 'insertAssignUsers';
|
|
3998
4018
|
teamsMsg;
|
|
3999
4019
|
teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
4000
|
-
teamsMsg = 'ClientId: '+ insertdata.client_id + ', Action: '+ actionType + ', ChecklistId: '+ getCLconfig._id + ', Checklist Name: '+ getCLconfig.checkListName + ', assignedUserCount:'+ assignUserList.length+', inprogressSubmitCount:' + submittedDetails?.length;
|
|
4020
|
+
teamsMsg = 'ClientId: ' + insertdata.client_id + ', Action: ' + actionType + ', ChecklistId: ' + getCLconfig._id + ', Checklist Name: ' + getCLconfig.checkListName + ', assignedUserCount:' + assignUserList.length + ', inprogressSubmitCount:' + submittedDetails?.length;
|
|
4001
4021
|
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
4002
4022
|
}
|
|
4003
4023
|
|
|
@@ -4082,7 +4102,7 @@ export const aiChecklist = async ( req, res ) => {
|
|
|
4082
4102
|
let existList = publishList.map( ( item ) => item.checkListType );
|
|
4083
4103
|
aiList = aiList.filter( ( item ) => !existList.includes( item ) );
|
|
4084
4104
|
}
|
|
4085
|
-
unpublishList= await checklistService.find( { client_id: { $exists: false }, checkListType: { $in: aiList } }, { publish: 1, checkListName: 1, checkListType: 1, checkListDescription: 1 } );
|
|
4105
|
+
unpublishList = await checklistService.find( { client_id: { $exists: false }, checkListType: { $in: aiList } }, { publish: 1, checkListName: 1, checkListType: 1, checkListDescription: 1 } );
|
|
4086
4106
|
checklistDetails = [ ...publishList, ...unpublishList ];
|
|
4087
4107
|
|
|
4088
4108
|
checklistDetails.forEach( ( item ) => {
|
|
@@ -4410,11 +4430,11 @@ export async function checklistAssign( req, res ) {
|
|
|
4410
4430
|
return acc;
|
|
4411
4431
|
}, {} );
|
|
4412
4432
|
|
|
4413
|
-
uniqueArr= Object.values( uniqueArr );
|
|
4433
|
+
uniqueArr = Object.values( uniqueArr );
|
|
4414
4434
|
} else {
|
|
4415
4435
|
uniqueArr = uniqueArr.reduce( ( acc, obj ) => {
|
|
4416
4436
|
if ( acc[obj.userEmail] ) {
|
|
4417
|
-
acc[obj.userEmail].teamName += ','+ obj.teamName;
|
|
4437
|
+
acc[obj.userEmail].teamName += ',' + obj.teamName;
|
|
4418
4438
|
acc[obj.userEmail].id.push( ...obj.id );
|
|
4419
4439
|
} else {
|
|
4420
4440
|
acc[obj.userEmail] = { ...obj };
|
|
@@ -4467,7 +4487,7 @@ export async function updateAssign( req, res ) {
|
|
|
4467
4487
|
let storeClusterDetails = getAssignedDetails.filter( ( ele ) => ele?.storeName || ele?.clusterName );
|
|
4468
4488
|
let userTeamDetails = getAssignedDetails.filter( ( ele ) => !ele?.storeName && ( ele?.userName || ele?.teamName ) );
|
|
4469
4489
|
storeClusterDetails = [ ...new Set( storeClusterDetails.map( ( ele ) => ele?.storeName || ele?.clusterName ) ) ];
|
|
4470
|
-
userTeamDetails= [ ...new Set( userTeamDetails.map( ( ele ) => ele?.userName || ele?.teamName ) ) ];
|
|
4490
|
+
userTeamDetails = [ ...new Set( userTeamDetails.map( ( ele ) => ele?.userName || ele?.teamName ) ) ];
|
|
4471
4491
|
getAssignedDetails = [ ...storeClusterDetails, ...userTeamDetails ];
|
|
4472
4492
|
}
|
|
4473
4493
|
let assignedAllList = [ ...req.body.assignedList, ...groupList ];
|
|
@@ -4630,7 +4650,7 @@ export async function updateAiConfigure( req, res ) {
|
|
|
4630
4650
|
type: 'checklist',
|
|
4631
4651
|
checkListType: aiChecklistDetails.checkListType,
|
|
4632
4652
|
schedule: 'daily',
|
|
4633
|
-
...( req.body.publish ) ? { publishDate: new Date() } :{},
|
|
4653
|
+
...( req.body.publish ) ? { publishDate: new Date() } : {},
|
|
4634
4654
|
approver: req.body?.approver || [],
|
|
4635
4655
|
scheduleRepeatedDay: [ '01' ],
|
|
4636
4656
|
scheduleStartTime: '06:00 AM',
|
|
@@ -4668,7 +4688,7 @@ export async function updateAiConfigure( req, res ) {
|
|
|
4668
4688
|
req.body.storeList.forEach( ( ele ) => {
|
|
4669
4689
|
let eventTime = [];
|
|
4670
4690
|
Object.keys( ele ).forEach( ( key ) => {
|
|
4671
|
-
let keyValue ={};
|
|
4691
|
+
let keyValue = {};
|
|
4672
4692
|
if ( req.body.aiConfig?.assignConfig && req.body.aiConfig?.assignConfig == 'store' && key.includes( 'startTime' ) ) {
|
|
4673
4693
|
let num = key.slice( -1 );
|
|
4674
4694
|
if ( ele[key] && ele[`configTime${num}`] ) {
|
|
@@ -4722,7 +4742,7 @@ export async function updateAiConfigure( req, res ) {
|
|
|
4722
4742
|
locationCount: 1,
|
|
4723
4743
|
checkListType: aiChecklistDetails.checkListType,
|
|
4724
4744
|
scheduleRepeatedType: 'daily',
|
|
4725
|
-
aiStoreList: storeData.length? storeData.map( ( store ) => {
|
|
4745
|
+
aiStoreList: storeData.length ? storeData.map( ( store ) => {
|
|
4726
4746
|
return { storeName: store.storeName, events: store.events, storeId: store.store_id };
|
|
4727
4747
|
} ) : [],
|
|
4728
4748
|
aiConfig: req.body.aiConfig,
|
|
@@ -4794,8 +4814,8 @@ export async function getAiDetails( req, res ) {
|
|
|
4794
4814
|
}
|
|
4795
4815
|
if ( [ 'cleaning', 'scrum' ].includes( checklistDetails.checkListType ) && checklistDetails?.aiConfig?.assignConfig == 'store' ) {
|
|
4796
4816
|
ele.events.forEach( ( event, index ) => {
|
|
4797
|
-
element[`startTime${index+1}`] = event.time;
|
|
4798
|
-
element[`configTime${index+1}`] = event.duration;
|
|
4817
|
+
element[`startTime${index + 1}`] = event.time;
|
|
4818
|
+
element[`configTime${index + 1}`] = event.duration;
|
|
4799
4819
|
} );
|
|
4800
4820
|
}
|
|
4801
4821
|
data.push( element );
|
|
@@ -4811,7 +4831,7 @@ export async function getAiDetails( req, res ) {
|
|
|
4811
4831
|
storeList: storeList,
|
|
4812
4832
|
approver: checklistDetails?.approver,
|
|
4813
4833
|
storeCount: checklistDetails?.storeCount,
|
|
4814
|
-
...( checklistDetails?.client_id ) ? { clientId: checklistDetails?.client_id } :{},
|
|
4834
|
+
...( checklistDetails?.client_id ) ? { clientId: checklistDetails?.client_id } : {},
|
|
4815
4835
|
enableNewDeployedStore: checklistDetails?.enableNewDeployedStore,
|
|
4816
4836
|
product: clientDetails?.planDetails?.product.map( ( product ) => product.productName ),
|
|
4817
4837
|
};
|
|
@@ -5017,7 +5037,7 @@ export async function updateOSProcessedData( req, res ) {
|
|
|
5017
5037
|
],
|
|
5018
5038
|
},
|
|
5019
5039
|
} ];
|
|
5020
|
-
if ( requestData.type && requestData.type=='checklist' ) {
|
|
5040
|
+
if ( requestData.type && requestData.type == 'checklist' ) {
|
|
5021
5041
|
let getchecklist = await processedchecklist.aggregate( findQuery );
|
|
5022
5042
|
if ( getchecklist && getchecklist.length > 0 ) {
|
|
5023
5043
|
const requestOptions = {
|
|
@@ -5033,7 +5053,7 @@ export async function updateOSProcessedData( req, res ) {
|
|
|
5033
5053
|
} else {
|
|
5034
5054
|
return res.sendError( { message: 'invalid _id' }, 400 );
|
|
5035
5055
|
}
|
|
5036
|
-
} else if ( requestData.type && requestData.type=='task' ) {
|
|
5056
|
+
} else if ( requestData.type && requestData.type == 'task' ) {
|
|
5037
5057
|
let gettask = await processedTaskService.aggregate( findQuery );
|
|
5038
5058
|
if ( gettask && gettask.length > 0 ) {
|
|
5039
5059
|
const requestOptions = {
|