tango-app-api-trax 3.8.23 → 3.8.24-nike
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/download.controller.js +19 -19
- package/src/controllers/gallery.controller.js +92 -28
- package/src/controllers/handlebar-helper.js +1 -0
- package/src/controllers/internalTrax.controller.js +651 -198
- package/src/controllers/mobileTrax.controller.js +254 -171
- package/src/controllers/teaxFlag.controller.js +5 -5
- package/src/controllers/trax.controller.js +6 -2
- package/src/hbs/recurringFlag.hbs +18 -16
- package/src/hbs/template.hbs +12 -5
- package/src/hbs/visit-checklist.hbs +82 -38
- package/src/routes/internalTraxApi.router.js +1 -0
- package/src/services/recurringFlagTracker.service.js +33 -33
- package/src/utils/visitChecklistPdf.utils.js +6 -5
|
@@ -118,7 +118,7 @@ export async function startChecklist( req, res ) {
|
|
|
118
118
|
$and: [
|
|
119
119
|
{ _id: new ObjectId( requestData.processedcheckListId ) },
|
|
120
120
|
{ userId: req.user._id },
|
|
121
|
-
{ date_string: requestData.date },
|
|
121
|
+
{ $or: [ { date_string: requestData.date }, { redoStatus: true } ] },
|
|
122
122
|
],
|
|
123
123
|
},
|
|
124
124
|
} );
|
|
@@ -137,7 +137,9 @@ export async function startChecklist( req, res ) {
|
|
|
137
137
|
let updateQuery = {};
|
|
138
138
|
updateQuery._id = new ObjectId( requestData.processedcheckListId );
|
|
139
139
|
updateQuery.userId = req.user._id;
|
|
140
|
-
|
|
140
|
+
if ( getBeforeChecklist?.[0]?.date_string == dayjs().format( 'YYYY-MM-DD' ) ) {
|
|
141
|
+
updateQuery.date_string = requestData.date;
|
|
142
|
+
}
|
|
141
143
|
|
|
142
144
|
if ( PCLQusestion && PCLQusestion?.questionAnswers && PCLQusestion?.questionAnswers.length > 0 ) {
|
|
143
145
|
await PCLQusestion.questionAnswers.forEach( ( section ) => {
|
|
@@ -317,7 +319,7 @@ export async function startChecklist( req, res ) {
|
|
|
317
319
|
return res.sendError( 'something went wrong please try again', 500 );
|
|
318
320
|
}
|
|
319
321
|
} catch ( e ) {
|
|
320
|
-
|
|
322
|
+
console.log( 'e =>', e );
|
|
321
323
|
logger.error( { function: 'startChecklist', error: e, body: req.body } );
|
|
322
324
|
return res.sendError( e, 500 );
|
|
323
325
|
}
|
|
@@ -467,7 +469,7 @@ export async function startTask( req, res ) {
|
|
|
467
469
|
} );
|
|
468
470
|
const getUpdatedTask = await processedTask.aggregate( findQuery );
|
|
469
471
|
|
|
470
|
-
|
|
472
|
+
let cdnurl = JSON.parse( process.env.CDNURL );
|
|
471
473
|
if ( !( task.checkListFrom && task.checkListFrom == 'api' ) ) {
|
|
472
474
|
// const bucket = JSON.parse( process.env.BUCKET );
|
|
473
475
|
await Promise.all(
|
|
@@ -661,12 +663,12 @@ export async function sopMobilechecklistQuestionValidatorv1( req, res, next ) {
|
|
|
661
663
|
let sectionQuestion = requestSection.filter( ( secQuestion ) => secQuestion.qname == question.oldQname || secQuestion.qname == question.qname );
|
|
662
664
|
if ( sectionQuestion.length ) {
|
|
663
665
|
if ( requestData.submittype == 'submit' ) {
|
|
664
|
-
if ( ( [ 'multipleImage', 'multiplechoicemultiple' ].includes( question.answerType ) || ( question.answerType =='dropdown' && question.allowMultiple ) ) ) {
|
|
666
|
+
if ( ( [ 'multipleImage', 'multiplechoicemultiple', 'image/video' ].includes( question.answerType ) || ( question.answerType =='dropdown' && question.allowMultiple ) ) ) {
|
|
665
667
|
if ( ( !sectionQuestion[0].linkType || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled ) ) && ( sectionQuestion[0].Multianswer == null || sectionQuestion[0].Multianswer == '' || !sectionQuestion[0].Multianswer.length ) ) {
|
|
666
668
|
validationCount++;
|
|
667
669
|
}
|
|
668
670
|
} else {
|
|
669
|
-
if ( ( !
|
|
671
|
+
if ( ( !sectionQuestion[0].linkType && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) || ( sectionQuestion[0].linkType && sectionQuestion[0].linkquestionenabled && ( sectionQuestion[0].answer == null || sectionQuestion[0].answer == '' ) ) ) {
|
|
670
672
|
validationCount++;
|
|
671
673
|
}
|
|
672
674
|
}
|
|
@@ -1082,12 +1084,15 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1082
1084
|
try {
|
|
1083
1085
|
let requestData = req.body;
|
|
1084
1086
|
requestData.questionAnswers = typeof requestData.questionAnswers == 'string' ? JSON.parse( requestData.questionAnswers ) : requestData.questionAnswers;
|
|
1085
|
-
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1 } );
|
|
1087
|
+
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1, redoEdit: 1 } );
|
|
1086
1088
|
let reqAnswers = requestData.questionAnswers;
|
|
1087
1089
|
logger.error( { functionName: 'updatedPayload', message: reqAnswers } );
|
|
1088
1090
|
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
1089
1091
|
|
|
1090
1092
|
if ( requestData.submittype == 'submit' ) {
|
|
1093
|
+
if ( getChecklistQA?.redoEdit ) {
|
|
1094
|
+
requestData.submittype = 'draft';
|
|
1095
|
+
}
|
|
1091
1096
|
reqAnswers.forEach( ( reqA ) => {
|
|
1092
1097
|
if ( ![ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( reqA?.answerType ) && ( reqA.answerType == 'dropDown' && !reqA.allowMultiple ) ) {
|
|
1093
1098
|
if ( ( !reqA.linkType && ( reqA.answer == null || reqA.answer == '' ) ) || ( reqA.linkType && reqA.linkquestionenabled && ( reqA.answer == null || reqA.answer == '' ) ) ) {
|
|
@@ -1172,26 +1177,31 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1172
1177
|
for ( let j = 0; j < qaAnswers.length; j++ ) {
|
|
1173
1178
|
if ( requestSection[i].qname == qaAnswers[j].oldQname || requestSection[i].qname == qaAnswers[j].qname ) {
|
|
1174
1179
|
if ( qaAnswers[j].answerType == 'yes/no' ) {
|
|
1175
|
-
let qaans = qaAnswers[j].answers;
|
|
1180
|
+
let qaans = JSON.parse( JSON.stringify( qaAnswers[j].answers ) );
|
|
1176
1181
|
let yn = [];
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
if (
|
|
1180
|
-
if (
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
splitImgUrl.
|
|
1186
|
-
|
|
1182
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1183
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1184
|
+
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1185
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1186
|
+
if ( requestSection[i].validationAnswer ) {
|
|
1187
|
+
let validateAns = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
|
|
1188
|
+
if ( validateAns.length ) {
|
|
1189
|
+
let splitImgUrl = validateAns.split( '/' );
|
|
1190
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1191
|
+
splitImgUrl.splice( 0, 3 );
|
|
1192
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1193
|
+
}
|
|
1187
1194
|
}
|
|
1188
1195
|
}
|
|
1196
|
+
} else {
|
|
1197
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1198
|
+
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1189
1199
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1200
|
+
if ( requestSection[i]?.runAIData && requestSection[i]?.runAIData?.length ) {
|
|
1201
|
+
qaans[k].runAIData = requestSection[i].runAIData;
|
|
1202
|
+
}
|
|
1203
|
+
yn.push( qaans[k] );
|
|
1193
1204
|
}
|
|
1194
|
-
yn.push( qaans[k] );
|
|
1195
1205
|
}
|
|
1196
1206
|
}
|
|
1197
1207
|
let structure = {};
|
|
@@ -1203,7 +1213,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1203
1213
|
structure.runAI = qaAnswers[j].runAI;
|
|
1204
1214
|
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1205
1215
|
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1206
|
-
|
|
1216
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1217
|
+
structure.remarks = requestSection[i].remarks;
|
|
1218
|
+
}
|
|
1207
1219
|
structure.answers = qaAnswers[j].answers;
|
|
1208
1220
|
structure.userAnswer = yn;
|
|
1209
1221
|
structure.linkType = qaAnswers[j].linkType;
|
|
@@ -1229,41 +1241,46 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1229
1241
|
};
|
|
1230
1242
|
newArray.push( structure );
|
|
1231
1243
|
} else if ( qaAnswers[j].answerType == 'multiplechoicesingle' || ( qaAnswers[j].answerType == 'dropdown' && !qaAnswers[j].allowMultiple ) ) {
|
|
1232
|
-
let qaans = qaAnswers[j].answers;
|
|
1244
|
+
let qaans = JSON.parse( JSON.stringify( qaAnswers[j].answers ) ); ;
|
|
1233
1245
|
let ms = [];
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
if (
|
|
1237
|
-
if (
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
splitImgUrl.
|
|
1243
|
-
|
|
1246
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1247
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1248
|
+
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1249
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1250
|
+
if ( requestSection[i].validationAnswer ) {
|
|
1251
|
+
let validationAnswer = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
|
|
1252
|
+
if ( validationAnswer.length ) {
|
|
1253
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1254
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1255
|
+
splitImgUrl.splice( 0, 3 );
|
|
1256
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1257
|
+
}
|
|
1244
1258
|
}
|
|
1245
1259
|
}
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
+
} else {
|
|
1261
|
+
if ( qaans[k].validationType == 'Capture Multiple Image with description' ) {
|
|
1262
|
+
qaans[k]['validationImage']=[];
|
|
1263
|
+
if ( requestSection[i].validationImage.length ) {
|
|
1264
|
+
for ( let image of requestSection[i].validationImage ) {
|
|
1265
|
+
let validationAnswer = decodeURIComponent( image.split( '?' )[0] );
|
|
1266
|
+
if ( validationAnswer.length ) {
|
|
1267
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1268
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1269
|
+
splitImgUrl.splice( 0, 3 );
|
|
1270
|
+
qaans[k].validationImage.push( splitImgUrl.join( '/' ) || '' );
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1260
1274
|
}
|
|
1261
1275
|
}
|
|
1276
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1277
|
+
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1262
1278
|
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1279
|
+
if ( requestSection[i]?.runAIData && requestSection[i]?.runAIData?.length ) {
|
|
1280
|
+
qaans[k].runAIData = requestSection[i].runAIData;
|
|
1281
|
+
}
|
|
1282
|
+
ms.push( qaans[k] );
|
|
1265
1283
|
}
|
|
1266
|
-
ms.push( qaans[k] );
|
|
1267
1284
|
}
|
|
1268
1285
|
}
|
|
1269
1286
|
let structure = {};
|
|
@@ -1275,7 +1292,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1275
1292
|
structure.runAI = qaAnswers[j].runAI;
|
|
1276
1293
|
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1277
1294
|
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1278
|
-
|
|
1295
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1296
|
+
structure.remarks = requestSection[i].remarks;
|
|
1297
|
+
}
|
|
1279
1298
|
structure.answers = qaAnswers[j].answers;
|
|
1280
1299
|
structure.userAnswer = ms;
|
|
1281
1300
|
structure.linkType = qaAnswers[j].linkType;
|
|
@@ -1302,32 +1321,44 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1302
1321
|
};
|
|
1303
1322
|
newArray.push( structure );
|
|
1304
1323
|
} else if ( qaAnswers[j].answerType == 'multiplechoicemultiple' || ( qaAnswers[j].answerType == 'dropdown' && qaAnswers[j].allowMultiple ) ) {
|
|
1305
|
-
let qaans = qaAnswers[j].answers;
|
|
1324
|
+
let qaans = JSON.parse( JSON.stringify( qaAnswers[j].answers ) );
|
|
1306
1325
|
let mcmo = [];
|
|
1307
|
-
|
|
1308
|
-
let
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
if (
|
|
1312
|
-
if ( separatedArray[s].
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1326
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1327
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1328
|
+
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1329
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1330
|
+
if ( ( separatedArray[s].answer == qaans[k].answer ) ) {
|
|
1331
|
+
if ( ( getChecklistQA?.redoEdit && qaans[k].redo == separatedArray[s].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1332
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1333
|
+
if ( separatedArray[s].validationAnswer ) {
|
|
1334
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].validationAnswer.split( '?' )[0] );
|
|
1335
|
+
if ( validationAnswer.length ) {
|
|
1336
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1337
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1338
|
+
splitImgUrl.splice( 0, 3 );
|
|
1339
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1319
1342
|
}
|
|
1343
|
+
} else {
|
|
1344
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1345
|
+
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1346
|
+
}
|
|
1347
|
+
if ( separatedArray[s]?.runAIData && separatedArray[s]?.runAIData?.length ) {
|
|
1348
|
+
qaans[k].runAIData = separatedArray[s].runAIData;
|
|
1320
1349
|
}
|
|
1321
1350
|
}
|
|
1322
|
-
|
|
1323
|
-
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1324
|
-
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1351
|
+
mcmo.push( qaans[k] );
|
|
1325
1352
|
}
|
|
1326
|
-
|
|
1327
|
-
mcmo.push( qaans[k] );
|
|
1328
1353
|
}
|
|
1329
1354
|
}
|
|
1330
1355
|
}
|
|
1356
|
+
qaAnswers[j].answers.forEach( ( ele ) => {
|
|
1357
|
+
if ( typeof ele?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1358
|
+
ele.redo = false;
|
|
1359
|
+
}
|
|
1360
|
+
} );
|
|
1361
|
+
|
|
1331
1362
|
let structure = {};
|
|
1332
1363
|
structure.qno = qaAnswers[j].qno;
|
|
1333
1364
|
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
@@ -1337,7 +1368,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1337
1368
|
structure.runAI = qaAnswers[j].runAI;
|
|
1338
1369
|
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1339
1370
|
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1340
|
-
|
|
1371
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1372
|
+
structure.remarks = requestSection[i].remarks;
|
|
1373
|
+
}
|
|
1341
1374
|
structure.answers = qaAnswers[j].answers;
|
|
1342
1375
|
structure.userAnswer = mcmo;
|
|
1343
1376
|
structure.linkType = qaAnswers[j].linkType;
|
|
@@ -1366,37 +1399,42 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1366
1399
|
} else if ( [ 'image/video', 'multipleImage' ].includes( qaAnswers[j].answerType ) ) {
|
|
1367
1400
|
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1368
1401
|
let mcmi = [];
|
|
1402
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1369
1403
|
// for (let k = 0; k < qaans.length; k++) {
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1404
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1405
|
+
if ( separatedArray[s].answer && separatedArray[s].answer !='' ) {
|
|
1406
|
+
let newAnswer = {};
|
|
1407
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].answer.split( '?' )[0] );
|
|
1408
|
+
if ( validationAnswer.length ) {
|
|
1409
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1410
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1411
|
+
splitImgUrl.splice( 0, 3 );
|
|
1412
|
+
newAnswer.answer = splitImgUrl.join( '/' ) || '';
|
|
1413
|
+
}
|
|
1379
1414
|
}
|
|
1380
|
-
}
|
|
1381
1415
|
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1416
|
+
newAnswer.answeroptionNumber = 0;
|
|
1417
|
+
newAnswer.sopFlag = false;
|
|
1418
|
+
newAnswer.validation = false;
|
|
1419
|
+
newAnswer.validationType = '';
|
|
1420
|
+
newAnswer.referenceImage = '';
|
|
1421
|
+
newAnswer.allowUploadfromGallery = false;
|
|
1422
|
+
newAnswer.descriptivetype = '';
|
|
1423
|
+
newAnswer.showLinked = false;
|
|
1424
|
+
newAnswer.linkedQuestion = 0;
|
|
1425
|
+
newAnswer.nestedQuestion = [];
|
|
1426
|
+
newAnswer.index = s;
|
|
1427
|
+
newAnswer.runAI = qaAnswers[j].answers[0]?.runAI || false;
|
|
1428
|
+
newAnswer.runAIFeatures = qaAnswers[j].answers[0]?.runAIFeatures || [];
|
|
1429
|
+
newAnswer.runAIDescription = qaAnswers[j].answers[0]?.runAIDescription || '';
|
|
1430
|
+
if ( qaAnswers[j].answerType == 'image/video' ) {
|
|
1431
|
+
newAnswer.answerType = separatedArray[s].answerType;
|
|
1432
|
+
}
|
|
1433
|
+
if ( separatedArray[s]?.runAIData && separatedArray[s]?.runAIData?.length ) {
|
|
1434
|
+
newAnswer.runAIData = separatedArray[s].runAIData;
|
|
1435
|
+
}
|
|
1436
|
+
mcmi.push( newAnswer );
|
|
1398
1437
|
}
|
|
1399
|
-
mcmi.push( newAnswer );
|
|
1400
1438
|
}
|
|
1401
1439
|
}
|
|
1402
1440
|
// }
|
|
@@ -1409,7 +1447,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1409
1447
|
structure.runAI = qaAnswers[j].runAI;
|
|
1410
1448
|
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1411
1449
|
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1412
|
-
|
|
1450
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1451
|
+
structure.remarks = requestSection[i].remarks;
|
|
1452
|
+
}
|
|
1413
1453
|
structure.answers = qaAnswers[j].answers;
|
|
1414
1454
|
structure.userAnswer = mcmi;
|
|
1415
1455
|
structure.linkType = qaAnswers[j].linkType;
|
|
@@ -1436,71 +1476,76 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1436
1476
|
newArray.push( structure );
|
|
1437
1477
|
} else {
|
|
1438
1478
|
let des = [];
|
|
1439
|
-
if (
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
if ( validationAnswer.length ) {
|
|
1445
|
-
let splitImgUrl = validationAnswer.split( '/' );
|
|
1446
|
-
if ( splitImgUrl.length > 1 ) {
|
|
1447
|
-
splitImgUrl.splice( 0, 3 );
|
|
1448
|
-
requestSection[i].answer = splitImgUrl.join( '/' );
|
|
1479
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1480
|
+
if ( requestSection[i].answer != 'null' && requestSection[i].answer != '' && requestSection[i].answer != null ) {
|
|
1481
|
+
let validationAnswer = '';
|
|
1482
|
+
if ( requestSection[i].answer.split( '?' ).length > 1 || requestSection[i].answer.includes( 'https://' ) ) {
|
|
1483
|
+
validationAnswer = decodeURIComponent( requestSection[i].answer.split( '?' )[0] );
|
|
1449
1484
|
}
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1485
|
+
if ( validationAnswer.length ) {
|
|
1486
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1487
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1488
|
+
splitImgUrl.splice( 0, 3 );
|
|
1489
|
+
requestSection[i].answer = splitImgUrl.join( '/' );
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
let ansstructure = {
|
|
1493
|
+
answer: requestSection[i].answer,
|
|
1494
|
+
answeroptionNumber: 1,
|
|
1495
|
+
sopFlag: false,
|
|
1496
|
+
validation: false,
|
|
1497
|
+
validationType: '',
|
|
1498
|
+
validationAnswer: '',
|
|
1499
|
+
referenceImage: qaAnswers[j].answers[0].referenceImage || '',
|
|
1500
|
+
multiReferenceImage: qaAnswers[j].answers[0].multiReferenceImage || [],
|
|
1501
|
+
showLinked: qaAnswers[j].answers[0].showLinked,
|
|
1502
|
+
linkedQuestion: qaAnswers[j].answers[0].linkedQuestion,
|
|
1503
|
+
runAI: qaAnswers[j].answers[0]?.runAI || false,
|
|
1504
|
+
runAIFeatures: qaAnswers[j]?.answers[0]?.runAIFeatures || [],
|
|
1505
|
+
runAIDescription: qaAnswers[j].answers[0]?.runAIDescription || '',
|
|
1506
|
+
};
|
|
1507
|
+
if ( qaAnswers[j].answerType == 'date' ) {
|
|
1508
|
+
ansstructure.dateRangeType = requestSection[i].dateRangeType || false;
|
|
1469
1509
|
if ( qaAnswers[j].compliance ) {
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1510
|
+
if ( qaAnswers[j].compliance ) {
|
|
1511
|
+
let ansArray = requestSection[i].answer.split( ',' );
|
|
1512
|
+
if ( ansArray.includes( '-' ) ) {
|
|
1513
|
+
ansArray = requestSection[i].answer.split( '-' );
|
|
1514
|
+
}
|
|
1515
|
+
if ( ansArray.length > 1 && ansArray.some( ( date ) => dayjs( date, 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate && dayjs( date, 'DD MMM YYYY' ) <= qaAnswers[j]?.answers[0]?.endDate ) ) {
|
|
1516
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1517
|
+
} else if ( ansArray.length > 1 && ( dayjs( ansArray?.[0], 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate && dayjs( ansArray?.[1], 'DD MMM YYYY' ).format( 'DD-MM-YYYY' ) <= qaAnswers[j]?.answers[0]?.endDate ) ) {
|
|
1518
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1519
|
+
} else if ( dayjs( requestSection[i].answer, 'DD MMM YYYY' ) >= qaAnswers[j]?.answers[0]?.startDate && dayjs( requestSection[i].answer, 'DD MMM YYYY' ) <= qaAnswers[j]?.answers[0]?.endDate ) {
|
|
1520
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1521
|
+
} else {
|
|
1522
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1523
|
+
}
|
|
1473
1524
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
if ( qaAnswers[j].answerType == 'linearscale' ) {
|
|
1528
|
+
if ( qaAnswers[j].compliance ) {
|
|
1529
|
+
let linearAnswer = requestSection[i].answer.split( 'to' );
|
|
1530
|
+
if ( parseInt( linearAnswer?.[0] ) >= qaAnswers[j]?.answers[0]?.minValue && parseInt( linearAnswer?.[1] ) <= qaAnswers[j]?.answers[0]?.maxValue ) {
|
|
1479
1531
|
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1480
1532
|
} else {
|
|
1481
1533
|
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1482
1534
|
}
|
|
1483
1535
|
}
|
|
1536
|
+
ansstructure.linearType = qaAnswers[j]?.answers[0]?.linearType;
|
|
1537
|
+
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1538
|
+
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1484
1539
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
let linearAnswer = requestSection[i].answer.split( 'to' );
|
|
1489
|
-
if ( parseInt( linearAnswer?.[0] ) >= qaAnswers[j]?.answers[0]?.minValue && parseInt( linearAnswer?.[1] ) <= qaAnswers[j]?.answers[0]?.maxValue ) {
|
|
1490
|
-
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1491
|
-
} else {
|
|
1492
|
-
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1493
|
-
}
|
|
1540
|
+
if ( qaAnswers[j].answerType == 'image' ) {
|
|
1541
|
+
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1542
|
+
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1494
1543
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
if ( qaAnswers[j].answerType == 'image' ) {
|
|
1500
|
-
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1501
|
-
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1544
|
+
if ( requestSection[i]?.runAIData && requestSection[i]?.runAIData?.length ) {
|
|
1545
|
+
ansstructure.runAIData = requestSection[i].runAIData;
|
|
1546
|
+
}
|
|
1547
|
+
des.push( ansstructure );
|
|
1502
1548
|
}
|
|
1503
|
-
des.push( ansstructure );
|
|
1504
1549
|
}
|
|
1505
1550
|
let structure = {};
|
|
1506
1551
|
structure.qno = qaAnswers[j].qno;
|
|
@@ -1511,7 +1556,9 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1511
1556
|
structure.runAI = qaAnswers[j].runAI;
|
|
1512
1557
|
structure.runAIDescription = qaAnswers[j].runAIDescription;
|
|
1513
1558
|
structure.allowUploadfromGallery = qaAnswers[j].allowUploadfromGallery;
|
|
1514
|
-
|
|
1559
|
+
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1560
|
+
structure.remarks = requestSection[i].remarks;
|
|
1561
|
+
}
|
|
1515
1562
|
structure.answers = qaAnswers[j].answers;
|
|
1516
1563
|
structure.userAnswer = des;
|
|
1517
1564
|
structure.linkType = qaAnswers[j].linkType;
|
|
@@ -1552,6 +1599,18 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1552
1599
|
|
|
1553
1600
|
requestData.questionAnswers = sectionFormat;
|
|
1554
1601
|
logger.error( { message: requestData.questionAnswers, error: 'QuestionanswersPayload' } );
|
|
1602
|
+
|
|
1603
|
+
if ( requestData.submittype == 'submit' ) {
|
|
1604
|
+
for ( let section of sectionFormat ) {
|
|
1605
|
+
for ( let question of section.questions ) {
|
|
1606
|
+
let mustValidate = !question.linkType || ( question.linkType && question.linkquestionenabled );
|
|
1607
|
+
if ( mustValidate && ( !question.userAnswer || !question.userAnswer.length ) ) {
|
|
1608
|
+
return res.sendError( 'Please Fill All Fields', 400 );
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1555
1614
|
next();
|
|
1556
1615
|
} catch ( error ) {
|
|
1557
1616
|
logger.error( { function: 'sopMobilechecklistMultiSectionFormatter', error: error, body: req.body } );
|
|
@@ -1932,7 +1991,7 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
|
|
|
1932
1991
|
let des = [];
|
|
1933
1992
|
if ( requestSection[i].answer != 'null' && requestSection[i].answer != '' && requestSection[i].answer != null ) {
|
|
1934
1993
|
let validationAnswer = '';
|
|
1935
|
-
if ( requestSection[i].answer.split( '?' ).length > 1 ) {
|
|
1994
|
+
if ( requestSection[i].answer.split( '?' ).length > 1 || requestSection[i].answer.includes( 'https://' ) ) {
|
|
1936
1995
|
validationAnswer = decodeURIComponent( requestSection[i].answer.split( '?' )[0] );
|
|
1937
1996
|
}
|
|
1938
1997
|
if ( validationAnswer.length ) {
|
|
@@ -2031,7 +2090,13 @@ function QuestionFlag( req, res ) {
|
|
|
2031
2090
|
|
|
2032
2091
|
async function updateRecurringFlagTracker( processedChecklist, questionAnswers, currentDateTime ) {
|
|
2033
2092
|
try {
|
|
2034
|
-
if ( !processedChecklist?.
|
|
2093
|
+
if ( !processedChecklist?.sourceCheckList_id ) return;
|
|
2094
|
+
|
|
2095
|
+
const isUserBased = processedChecklist?.coverage === 'user';
|
|
2096
|
+
const storeId = isUserBased ? '' : ( processedChecklist?.store_id || '' );
|
|
2097
|
+
const userId = isUserBased ? ( processedChecklist?.userId ? String( processedChecklist.userId ) : ( processedChecklist?.userEmail || '' ) ) : '';
|
|
2098
|
+
if ( !isUserBased && !storeId ) return;
|
|
2099
|
+
if ( isUserBased && !userId ) return;
|
|
2035
2100
|
|
|
2036
2101
|
const today = currentDateTime ? currentDateTime.format( 'YYYY-MM-DD' ) : dayjs().format( 'YYYY-MM-DD' );
|
|
2037
2102
|
const yesterday = dayjs( today, 'YYYY-MM-DD' ).subtract( 1, 'day' ).format( 'YYYY-MM-DD' );
|
|
@@ -2039,7 +2104,7 @@ async function updateRecurringFlagTracker( processedChecklist, questionAnswers,
|
|
|
2039
2104
|
const trackerKeyBase = {
|
|
2040
2105
|
client_id: processedChecklist.client_id,
|
|
2041
2106
|
sourceCheckList_id: processedChecklist.sourceCheckList_id,
|
|
2042
|
-
store_id:
|
|
2107
|
+
...( isUserBased ) ? { user_id: userId } : { store_id: storeId },
|
|
2043
2108
|
};
|
|
2044
2109
|
|
|
2045
2110
|
const existingRows = await recurringFlagTracker.find( trackerKeyBase, { section_id: 1, qno: 1, consecutiveCount: 1, lastFlaggedDate: 1 } );
|
|
@@ -2059,7 +2124,7 @@ async function updateRecurringFlagTracker( processedChecklist, questionAnswers,
|
|
|
2059
2124
|
const flaggedNow = Array.isArray( question?.userAnswer ) && question.userAnswer.some( ( a ) => a?.sopFlag === true );
|
|
2060
2125
|
const key = `${sectionId}::${qno}`;
|
|
2061
2126
|
const existing = existingMap.get( key );
|
|
2062
|
-
|
|
2127
|
+
console.log( flaggedNow, 'test' );
|
|
2063
2128
|
if ( flaggedNow ) {
|
|
2064
2129
|
let newCount;
|
|
2065
2130
|
if ( !existing ) {
|
|
@@ -2079,8 +2144,11 @@ async function updateRecurringFlagTracker( processedChecklist, questionAnswers,
|
|
|
2079
2144
|
filter: { ...trackerKeyBase, section_id: sectionId, qno },
|
|
2080
2145
|
update: {
|
|
2081
2146
|
$set: {
|
|
2147
|
+
coverage: isUserBased ? 'user' : 'store',
|
|
2082
2148
|
checkListName: processedChecklist.checkListName,
|
|
2083
|
-
storeName: processedChecklist.storeName,
|
|
2149
|
+
storeName: isUserBased ? '' : ( processedChecklist.storeName || '' ),
|
|
2150
|
+
userName: processedChecklist.userName || '',
|
|
2151
|
+
userEmail: processedChecklist.userEmail || '',
|
|
2084
2152
|
sectionName: section?.sectionName || '',
|
|
2085
2153
|
qname: question?.qname || '',
|
|
2086
2154
|
consecutiveCount: newCount,
|
|
@@ -2103,9 +2171,13 @@ async function updateRecurringFlagTracker( processedChecklist, questionAnswers,
|
|
|
2103
2171
|
}
|
|
2104
2172
|
} );
|
|
2105
2173
|
} );
|
|
2106
|
-
|
|
2107
2174
|
if ( ops.length ) {
|
|
2108
|
-
|
|
2175
|
+
try {
|
|
2176
|
+
let data = await recurringFlagTracker.bulkWrite( ops, { ordered: false } );
|
|
2177
|
+
console.log( 'recurringFlagTracker bulkWrite result', data );
|
|
2178
|
+
} catch ( bulkErr ) {
|
|
2179
|
+
logger.error( { function: 'updateRecurringFlagTracker.bulkWrite', code: bulkErr?.code, message: bulkErr?.message, writeErrors: bulkErr?.writeErrors } );
|
|
2180
|
+
}
|
|
2109
2181
|
}
|
|
2110
2182
|
} catch ( error ) {
|
|
2111
2183
|
logger.error( { function: 'updateRecurringFlagTracker', error } );
|
|
@@ -2159,6 +2231,9 @@ export async function submitChecklist( req, res ) {
|
|
|
2159
2231
|
let flagCount = QuestionFlag( req, res );
|
|
2160
2232
|
updateData.questionFlag = flagCount;
|
|
2161
2233
|
updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
2234
|
+
if ( getchecklist?.[0]?.redoEdit != undefined ) {
|
|
2235
|
+
updateData.redoEdit = false;
|
|
2236
|
+
}
|
|
2162
2237
|
if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
|
|
2163
2238
|
updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
|
|
2164
2239
|
}
|
|
@@ -2247,6 +2322,7 @@ export async function submitChecklist( req, res ) {
|
|
|
2247
2322
|
// };
|
|
2248
2323
|
// await detectionService.create( detectionData );
|
|
2249
2324
|
if ( requestData.submittype == 'submit' ) {
|
|
2325
|
+
console.log( checklistDetails?.recurringFlag?.notifyType?.length );
|
|
2250
2326
|
if ( checklistDetails?.recurringFlag?.notifyType?.length ) {
|
|
2251
2327
|
updateRecurringFlagTracker( getchecklist[0], requestData.questionAnswers, currentDateTime );
|
|
2252
2328
|
}
|
|
@@ -2430,7 +2506,8 @@ export async function submitTask( req, res ) {
|
|
|
2430
2506
|
'storeResponseTime': currentDateTime.format( 'HH:mm:ss - MMM DD, YYYY' ),
|
|
2431
2507
|
'message_mode': 'retriggered',
|
|
2432
2508
|
};
|
|
2433
|
-
sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).storeHygiene}`, JSON.stringify( sqsData ) );
|
|
2509
|
+
let sqsResponse = await sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).storeHygiene}`, JSON.stringify( sqsData ) );
|
|
2510
|
+
console.log( sqsResponse );
|
|
2434
2511
|
}
|
|
2435
2512
|
if ( !excludedChecklists.includes( checklist.checkListName ) ) {
|
|
2436
2513
|
const query1 = [
|
|
@@ -2935,6 +3012,9 @@ export async function dashboardv1( req, res ) {
|
|
|
2935
3012
|
// const { store_id, date } = req.query;
|
|
2936
3013
|
const { date } = req.query;
|
|
2937
3014
|
const userId = req.user._id;
|
|
3015
|
+
let fromDate = new Date( req.query.date );
|
|
3016
|
+
let toDate = new Date( req.query.date );
|
|
3017
|
+
toDate.setDate( toDate.getDate() + 1 );
|
|
2938
3018
|
|
|
2939
3019
|
// //Get User Based Checklist //
|
|
2940
3020
|
const clientId = { client_id: req.user.clientId };
|
|
@@ -2951,7 +3031,7 @@ export async function dashboardv1( req, res ) {
|
|
|
2951
3031
|
...storeMatch,
|
|
2952
3032
|
};
|
|
2953
3033
|
const buildPipeline = ( matchExtraConditions = {} ) => [
|
|
2954
|
-
{ $match: { ...baseMatch, ...matchExtraConditions } },
|
|
3034
|
+
{ $match: { $or: [ { ...baseMatch, ...matchExtraConditions }, { $and: [ { redoStatus: true }, { scheduleStartTime_iso: { $lt: toDate } }, { scheduleEndTime_iso: { $gte: fromDate } }, { userId }, { ...storeMatch } ] } ] } },
|
|
2955
3035
|
{
|
|
2956
3036
|
$facet: {
|
|
2957
3037
|
total: [ { $count: 'total' } ],
|
|
@@ -2971,9 +3051,7 @@ export async function dashboardv1( req, res ) {
|
|
|
2971
3051
|
},
|
|
2972
3052
|
];
|
|
2973
3053
|
|
|
2974
|
-
|
|
2975
|
-
let toDate = new Date( req.query.date );
|
|
2976
|
-
toDate.setDate( toDate.getDate() + 1 );
|
|
3054
|
+
|
|
2977
3055
|
const taskBaseMatch = {
|
|
2978
3056
|
// eslint-disable-next-line camelcase
|
|
2979
3057
|
// store_id,
|
|
@@ -3022,6 +3100,8 @@ export async function dashboardv1( req, res ) {
|
|
|
3022
3100
|
processedTask.aggregate( taskQuery ),
|
|
3023
3101
|
] );
|
|
3024
3102
|
|
|
3103
|
+
console.log( checklistResult );
|
|
3104
|
+
|
|
3025
3105
|
const checklistResultData =
|
|
3026
3106
|
checklistResult.status === 'fulfilled' ?
|
|
3027
3107
|
processResult( checklistResult.value ) :
|
|
@@ -3151,6 +3231,9 @@ export async function checklistv1( req, res ) {
|
|
|
3151
3231
|
// const { store_id, date, checklistStatus, searchValue } = req.query;
|
|
3152
3232
|
const { date, checklistStatus, searchValue } = req.query;
|
|
3153
3233
|
const userId = req.user._id;
|
|
3234
|
+
let fromDate = new Date( req.query.date );
|
|
3235
|
+
let toDate = new Date( req.query.date );
|
|
3236
|
+
toDate.setDate( toDate.getDate() + 1 );
|
|
3154
3237
|
|
|
3155
3238
|
// Get User Based Checklist //
|
|
3156
3239
|
const clientId = { client_id: req.user.clientId };
|
|
@@ -3162,16 +3245,18 @@ export async function checklistv1( req, res ) {
|
|
|
3162
3245
|
// eslint-disable-next-line camelcase
|
|
3163
3246
|
// { store_id },
|
|
3164
3247
|
{ userId },
|
|
3165
|
-
{ date_string: date },
|
|
3248
|
+
{ $or: [ { date_string: date }, { $and: [ { redoStatus: true }, { scheduleStartTime_iso: { $lt: toDate } }, { scheduleEndTime_iso: { $gte: fromDate } } ] } ] },
|
|
3166
3249
|
{ timeFlagStatus: true },
|
|
3167
3250
|
...matchExtraConditions,
|
|
3168
3251
|
clientId,
|
|
3169
3252
|
storeMatch,
|
|
3170
3253
|
];
|
|
3254
|
+
|
|
3171
3255
|
if ( checklistStatus ) {
|
|
3172
3256
|
matchConditions.push( { checklistStatus } );
|
|
3173
3257
|
}
|
|
3174
3258
|
|
|
3259
|
+
|
|
3175
3260
|
const pipeline = [
|
|
3176
3261
|
{ $match: { $and: matchConditions } },
|
|
3177
3262
|
...( searchValue ?
|
|
@@ -3224,9 +3309,7 @@ export async function checklistv1( req, res ) {
|
|
|
3224
3309
|
return pipeline;
|
|
3225
3310
|
};
|
|
3226
3311
|
|
|
3227
|
-
|
|
3228
|
-
let toDate = new Date( req.query.date );
|
|
3229
|
-
toDate.setDate( toDate.getDate() + 1 );
|
|
3312
|
+
|
|
3230
3313
|
const taskBuildPipeline = ( matchExtraConditions = [], projectExtraConditions = {} ) => {
|
|
3231
3314
|
const matchConditions = [
|
|
3232
3315
|
// eslint-disable-next-line camelcase
|
|
@@ -3606,7 +3689,7 @@ export async function questionList( req, res ) {
|
|
|
3606
3689
|
checkvalidation = answer.validationAnswer;
|
|
3607
3690
|
}
|
|
3608
3691
|
}
|
|
3609
|
-
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
3692
|
+
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation, ...( answer.redo && { redo: answer.redo } ) } );
|
|
3610
3693
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
3611
3694
|
}
|
|
3612
3695
|
|