tango-app-api-trax 3.8.31 → 3.9.0-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 +27 -89
- package/src/controllers/handlebar-helper.js +1 -0
- package/src/controllers/internalTrax.controller.js +10 -10
- package/src/controllers/mobileTrax.controller.js +151 -199
- package/src/controllers/teaxFlag.controller.js +5 -5
- package/src/controllers/trax.controller.js +2 -2
- package/src/hbs/flag.hbs +248 -248
- package/src/hbs/login-otp.hbs +943 -943
- package/src/hbs/recurringFlag.hbs +250 -250
- package/src/hbs/weeklyWrap.hbs +218 -218
- package/src/routes/mobileTrax.routes.js +1 -0
- package/src/utils/visitChecklistPdf.utils.js +1 -1
|
@@ -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
|
-
{
|
|
121
|
+
{ date_string: requestData.date },
|
|
122
122
|
],
|
|
123
123
|
},
|
|
124
124
|
} );
|
|
@@ -1082,15 +1082,12 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1082
1082
|
try {
|
|
1083
1083
|
let requestData = req.body;
|
|
1084
1084
|
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
|
|
1085
|
+
let getChecklistQA = await processedchecklist.findOne( { _id: new ObjectId( requestData.processedcheckListId ) }, { questionAnswers: 1 } );
|
|
1086
1086
|
let reqAnswers = requestData.questionAnswers;
|
|
1087
1087
|
logger.error( { functionName: 'updatedPayload', message: reqAnswers } );
|
|
1088
1088
|
let CLQAnswers = getChecklistQA.questionAnswers;
|
|
1089
1089
|
|
|
1090
1090
|
if ( requestData.submittype == 'submit' ) {
|
|
1091
|
-
if ( getChecklistQA?.redoEdit ) {
|
|
1092
|
-
requestData.submittype = 'draft';
|
|
1093
|
-
}
|
|
1094
1091
|
reqAnswers.forEach( ( reqA ) => {
|
|
1095
1092
|
if ( ![ 'multiplechoicemultiple', 'multipleImage', 'image/video' ].includes( reqA?.answerType ) && ( reqA.answerType == 'dropDown' && !reqA.allowMultiple ) ) {
|
|
1096
1093
|
if ( ( !reqA.linkType && ( reqA.answer == null || reqA.answer == '' ) ) || ( reqA.linkType && reqA.linkquestionenabled && ( reqA.answer == null || reqA.answer == '' ) ) ) {
|
|
@@ -1177,29 +1174,24 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1177
1174
|
if ( qaAnswers[j].answerType == 'yes/no' ) {
|
|
1178
1175
|
let qaans = qaAnswers[j].answers;
|
|
1179
1176
|
let yn = [];
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
if (
|
|
1183
|
-
if (
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1191
|
-
}
|
|
1177
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1178
|
+
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1179
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1180
|
+
if ( requestSection[i].validationAnswer ) {
|
|
1181
|
+
let validateAns = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
|
|
1182
|
+
if ( validateAns.length ) {
|
|
1183
|
+
let splitImgUrl = validateAns.split( '/' );
|
|
1184
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1185
|
+
splitImgUrl.splice( 0, 3 );
|
|
1186
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1192
1187
|
}
|
|
1193
1188
|
}
|
|
1194
|
-
} else {
|
|
1195
|
-
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1196
|
-
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1197
|
-
}
|
|
1198
|
-
if ( requestSection[i]?.runAIData && requestSection[i]?.runAIData?.length ) {
|
|
1199
|
-
qaans[k].runAIData = requestSection[i].runAIData;
|
|
1200
1189
|
}
|
|
1201
|
-
|
|
1190
|
+
} else {
|
|
1191
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1192
|
+
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1202
1193
|
}
|
|
1194
|
+
yn.push( qaans[k] );
|
|
1203
1195
|
}
|
|
1204
1196
|
}
|
|
1205
1197
|
let structure = {};
|
|
@@ -1239,44 +1231,39 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1239
1231
|
} else if ( qaAnswers[j].answerType == 'multiplechoicesingle' || ( qaAnswers[j].answerType == 'dropdown' && !qaAnswers[j].allowMultiple ) ) {
|
|
1240
1232
|
let qaans = qaAnswers[j].answers;
|
|
1241
1233
|
let ms = [];
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
if (
|
|
1245
|
-
if (
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1253
|
-
}
|
|
1234
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1235
|
+
if ( requestSection[i].answer == qaans[k].answer ) {
|
|
1236
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1237
|
+
if ( requestSection[i].validationAnswer ) {
|
|
1238
|
+
let validationAnswer = decodeURIComponent( requestSection[i].validationAnswer.split( '?' )[0] );
|
|
1239
|
+
if ( validationAnswer.length ) {
|
|
1240
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1241
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1242
|
+
splitImgUrl.splice( 0, 3 );
|
|
1243
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1254
1244
|
}
|
|
1255
1245
|
}
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1246
|
+
}
|
|
1247
|
+
} else {
|
|
1248
|
+
if ( qaans[k].validationType == 'Capture Multiple Image with description' ) {
|
|
1249
|
+
qaans[k]['validationImage']=[];
|
|
1250
|
+
if ( requestSection[i].validationImage.length ) {
|
|
1251
|
+
for ( let image of requestSection[i].validationImage ) {
|
|
1252
|
+
let validationAnswer = decodeURIComponent( image.split( '?' )[0] );
|
|
1253
|
+
if ( validationAnswer.length ) {
|
|
1254
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1255
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1256
|
+
splitImgUrl.splice( 0, 3 );
|
|
1257
|
+
qaans[k].validationImage.push( splitImgUrl.join( '/' ) || '' );
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1270
1260
|
}
|
|
1271
1261
|
}
|
|
1272
|
-
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1273
|
-
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1274
|
-
}
|
|
1275
|
-
if ( requestSection[i]?.runAIData && requestSection[i]?.runAIData?.length ) {
|
|
1276
|
-
qaans[k].runAIData = requestSection[i].runAIData;
|
|
1277
1262
|
}
|
|
1278
|
-
|
|
1263
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1264
|
+
qaans[k].validationAnswer = requestSection[i].validationAnswer || '';
|
|
1279
1265
|
}
|
|
1266
|
+
ms.push( qaans[k] );
|
|
1280
1267
|
}
|
|
1281
1268
|
}
|
|
1282
1269
|
let structure = {};
|
|
@@ -1317,42 +1304,30 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1317
1304
|
} else if ( qaAnswers[j].answerType == 'multiplechoicemultiple' || ( qaAnswers[j].answerType == 'dropdown' && qaAnswers[j].allowMultiple ) ) {
|
|
1318
1305
|
let qaans = qaAnswers[j].answers;
|
|
1319
1306
|
let mcmo = [];
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
if (
|
|
1325
|
-
if (
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
splitImgUrl.splice( 0, 3 );
|
|
1333
|
-
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1307
|
+
for ( let k = 0; k < qaans.length; k++ ) {
|
|
1308
|
+
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1309
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1310
|
+
if ( separatedArray[s].answer == qaans[k].answer ) {
|
|
1311
|
+
if ( qaans[k].validationType == 'Capture Image' || qaans[k].validationType == 'Capture Video' ) {
|
|
1312
|
+
if ( separatedArray[s].validationAnswer ) {
|
|
1313
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].validationAnswer.split( '?' )[0] );
|
|
1314
|
+
if ( validationAnswer.length ) {
|
|
1315
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1316
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1317
|
+
splitImgUrl.splice( 0, 3 );
|
|
1318
|
+
qaans[k].validationAnswer = splitImgUrl.join( '/' ) || '';
|
|
1336
1319
|
}
|
|
1337
|
-
} else {
|
|
1338
|
-
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1339
|
-
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1340
|
-
}
|
|
1341
|
-
if ( separatedArray[s]?.runAIData && separatedArray[s]?.runAIData?.length ) {
|
|
1342
|
-
qaans[k].runAIData = separatedArray[s].runAIData;
|
|
1343
1320
|
}
|
|
1344
1321
|
}
|
|
1345
|
-
|
|
1322
|
+
} else {
|
|
1323
|
+
// qaans[k].descriptivetype = qaAnswers[j].descriptivetype || '';
|
|
1324
|
+
qaans[k].validationAnswer = separatedArray[s].validationAnswer || '';
|
|
1346
1325
|
}
|
|
1326
|
+
|
|
1327
|
+
mcmo.push( qaans[k] );
|
|
1347
1328
|
}
|
|
1348
1329
|
}
|
|
1349
1330
|
}
|
|
1350
|
-
qaAnswers[j].answers.forEach( ( ele ) => {
|
|
1351
|
-
if ( typeof ele?.redo === 'boolean' && requestData.submittype === 'submit' ) {
|
|
1352
|
-
ele.redo = false;
|
|
1353
|
-
}
|
|
1354
|
-
} );
|
|
1355
|
-
|
|
1356
1331
|
let structure = {};
|
|
1357
1332
|
structure.qno = qaAnswers[j].qno;
|
|
1358
1333
|
structure.uniqueqno = qaAnswers[j].uniqueqno;
|
|
@@ -1391,42 +1366,37 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1391
1366
|
} else if ( [ 'image/video', 'multipleImage' ].includes( qaAnswers[j].answerType ) ) {
|
|
1392
1367
|
let separatedArray = typeof requestSection[i].Multianswer == 'string' ? JSON.parse( requestSection[i].Multianswer ) : requestSection[i].Multianswer;
|
|
1393
1368
|
let mcmi = [];
|
|
1394
|
-
if ( ( getChecklistQA?.redoEdit && qaAnswers[j].redo == requestSection[i].redo ) || !getChecklistQA?.redoEdit ) {
|
|
1395
1369
|
// for (let k = 0; k < qaans.length; k++) {
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
}
|
|
1370
|
+
for ( let s = 0; s < separatedArray.length; s++ ) {
|
|
1371
|
+
if ( separatedArray[s].answer && separatedArray[s].answer !='' ) {
|
|
1372
|
+
let newAnswer = {};
|
|
1373
|
+
let validationAnswer = decodeURIComponent( separatedArray[s].answer.split( '?' )[0] );
|
|
1374
|
+
if ( validationAnswer.length ) {
|
|
1375
|
+
let splitImgUrl = validationAnswer.split( '/' );
|
|
1376
|
+
if ( splitImgUrl.length > 1 ) {
|
|
1377
|
+
splitImgUrl.splice( 0, 3 );
|
|
1378
|
+
newAnswer.answer = splitImgUrl.join( '/' ) || '';
|
|
1406
1379
|
}
|
|
1380
|
+
}
|
|
1407
1381
|
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
}
|
|
1425
|
-
if ( separatedArray[s]?.runAIData && separatedArray[s]?.runAIData?.length ) {
|
|
1426
|
-
newAnswer.runAIData = separatedArray[s].runAIData;
|
|
1427
|
-
}
|
|
1428
|
-
mcmi.push( newAnswer );
|
|
1382
|
+
newAnswer.answeroptionNumber = 0;
|
|
1383
|
+
newAnswer.sopFlag = false;
|
|
1384
|
+
newAnswer.validation = false;
|
|
1385
|
+
newAnswer.validationType = '';
|
|
1386
|
+
newAnswer.referenceImage = '';
|
|
1387
|
+
newAnswer.allowUploadfromGallery = false;
|
|
1388
|
+
newAnswer.descriptivetype = '';
|
|
1389
|
+
newAnswer.showLinked = false;
|
|
1390
|
+
newAnswer.linkedQuestion = 0;
|
|
1391
|
+
newAnswer.nestedQuestion = [];
|
|
1392
|
+
newAnswer.index = s;
|
|
1393
|
+
newAnswer.runAI = qaAnswers[j].answers[0]?.runAI || false;
|
|
1394
|
+
newAnswer.runAIFeatures = qaAnswers[j].answers[0]?.runAIFeatures || [];
|
|
1395
|
+
newAnswer.runAIDescription = qaAnswers[j].answers[0]?.runAIDescription || '';
|
|
1396
|
+
if ( qaAnswers[j].answerType == 'image/video' ) {
|
|
1397
|
+
newAnswer.answerType = separatedArray[s].answerType;
|
|
1429
1398
|
}
|
|
1399
|
+
mcmi.push( newAnswer );
|
|
1430
1400
|
}
|
|
1431
1401
|
}
|
|
1432
1402
|
// }
|
|
@@ -1466,76 +1436,71 @@ export async function sopMobilechecklistMultiSectionFormatterv1( req, res, next
|
|
|
1466
1436
|
newArray.push( structure );
|
|
1467
1437
|
} else {
|
|
1468
1438
|
let des = [];
|
|
1469
|
-
if (
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
requestSection[i].answer = splitImgUrl.join( '/' );
|
|
1480
|
-
}
|
|
1439
|
+
if ( requestSection[i].answer != 'null' && requestSection[i].answer != '' && requestSection[i].answer != null ) {
|
|
1440
|
+
let validationAnswer = '';
|
|
1441
|
+
if ( requestSection[i].answer.split( '?' ).length > 1 || requestSection[i].answer.includes( 'https://' ) ) {
|
|
1442
|
+
validationAnswer = decodeURIComponent( requestSection[i].answer.split( '?' )[0] );
|
|
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( '/' );
|
|
1481
1449
|
}
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1450
|
+
}
|
|
1451
|
+
let ansstructure = {
|
|
1452
|
+
answer: requestSection[i].answer,
|
|
1453
|
+
answeroptionNumber: 1,
|
|
1454
|
+
sopFlag: false,
|
|
1455
|
+
validation: false,
|
|
1456
|
+
validationType: '',
|
|
1457
|
+
validationAnswer: '',
|
|
1458
|
+
referenceImage: qaAnswers[j].answers[0].referenceImage || '',
|
|
1459
|
+
multiReferenceImage: qaAnswers[j].answers[0].multiReferenceImage || [],
|
|
1460
|
+
showLinked: qaAnswers[j].answers[0].showLinked,
|
|
1461
|
+
linkedQuestion: qaAnswers[j].answers[0].linkedQuestion,
|
|
1462
|
+
runAI: qaAnswers[j].answers[0]?.runAI || false,
|
|
1463
|
+
runAIFeatures: qaAnswers[j]?.answers[0]?.runAIFeatures || [],
|
|
1464
|
+
runAIDescription: qaAnswers[j].answers[0]?.runAIDescription || '',
|
|
1465
|
+
};
|
|
1466
|
+
if ( qaAnswers[j].answerType == 'date' ) {
|
|
1467
|
+
ansstructure.dateRangeType = requestSection[i].dateRangeType || false;
|
|
1468
|
+
if ( qaAnswers[j].compliance ) {
|
|
1499
1469
|
if ( qaAnswers[j].compliance ) {
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
ansArray = requestSection[i].answer.split( '-' );
|
|
1504
|
-
}
|
|
1505
|
-
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 ) ) {
|
|
1506
|
-
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1507
|
-
} 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 ) ) {
|
|
1508
|
-
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1509
|
-
} 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 ) {
|
|
1510
|
-
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1511
|
-
} else {
|
|
1512
|
-
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1513
|
-
}
|
|
1470
|
+
let ansArray = requestSection[i].answer.split( ',' );
|
|
1471
|
+
if ( ansArray.includes( '-' ) ) {
|
|
1472
|
+
ansArray = requestSection[i].answer.split( '-' );
|
|
1514
1473
|
}
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
if ( parseInt( linearAnswer?.[0] ) >= qaAnswers[j]?.answers[0]?.minValue && parseInt( linearAnswer?.[1] ) <= qaAnswers[j]?.answers[0]?.maxValue ) {
|
|
1474
|
+
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 ) ) {
|
|
1475
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1476
|
+
} 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 ) ) {
|
|
1477
|
+
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1478
|
+
} 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 ) {
|
|
1521
1479
|
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1522
1480
|
} else {
|
|
1523
1481
|
ansstructure.complianceScore = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1524
1482
|
}
|
|
1525
1483
|
}
|
|
1526
|
-
ansstructure.linearType = qaAnswers[j]?.answers[0]?.linearType;
|
|
1527
|
-
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1528
|
-
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1529
|
-
}
|
|
1530
|
-
if ( qaAnswers[j].answerType == 'image' ) {
|
|
1531
|
-
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1532
|
-
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1533
1484
|
}
|
|
1534
|
-
|
|
1535
|
-
|
|
1485
|
+
}
|
|
1486
|
+
if ( qaAnswers[j].answerType == 'linearscale' ) {
|
|
1487
|
+
if ( qaAnswers[j].compliance ) {
|
|
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
|
+
}
|
|
1536
1494
|
}
|
|
1537
|
-
|
|
1495
|
+
ansstructure.linearType = qaAnswers[j]?.answers[0]?.linearType;
|
|
1496
|
+
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1497
|
+
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1498
|
+
}
|
|
1499
|
+
if ( qaAnswers[j].answerType == 'image' ) {
|
|
1500
|
+
ansstructure.matchedCount = qaAnswers[j]?.answers[0]?.matchedCount;
|
|
1501
|
+
ansstructure.notMatchedCount = qaAnswers[j]?.answers[0]?.notMatchedCount;
|
|
1538
1502
|
}
|
|
1503
|
+
des.push( ansstructure );
|
|
1539
1504
|
}
|
|
1540
1505
|
let structure = {};
|
|
1541
1506
|
structure.qno = qaAnswers[j].qno;
|
|
@@ -2207,7 +2172,6 @@ export async function submitChecklist( req, res ) {
|
|
|
2207
2172
|
let flagCount = QuestionFlag( req, res );
|
|
2208
2173
|
updateData.questionFlag = flagCount;
|
|
2209
2174
|
updateData.submitTime_string = currentDateTime.format( 'hh:mm A, DD MMM YYYY' );
|
|
2210
|
-
updateData.redoEdit = false;
|
|
2211
2175
|
if ( requestData.deviceDetails && requestData.deviceDetails != '' ) {
|
|
2212
2176
|
updateData.deviceDetails =JSON.parse( requestData.deviceDetails );
|
|
2213
2177
|
}
|
|
@@ -2480,8 +2444,7 @@ export async function submitTask( req, res ) {
|
|
|
2480
2444
|
'storeResponseTime': currentDateTime.format( 'HH:mm:ss - MMM DD, YYYY' ),
|
|
2481
2445
|
'message_mode': 'retriggered',
|
|
2482
2446
|
};
|
|
2483
|
-
|
|
2484
|
-
console.log( sqsResponse );
|
|
2447
|
+
sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).storeHygiene}`, JSON.stringify( sqsData ) );
|
|
2485
2448
|
}
|
|
2486
2449
|
if ( !excludedChecklists.includes( checklist.checkListName ) ) {
|
|
2487
2450
|
const query1 = [
|
|
@@ -2986,9 +2949,6 @@ export async function dashboardv1( req, res ) {
|
|
|
2986
2949
|
// const { store_id, date } = req.query;
|
|
2987
2950
|
const { date } = req.query;
|
|
2988
2951
|
const userId = req.user._id;
|
|
2989
|
-
let fromDate = new Date( req.query.date );
|
|
2990
|
-
let toDate = new Date( req.query.date );
|
|
2991
|
-
toDate.setDate( toDate.getDate() + 1 );
|
|
2992
2952
|
|
|
2993
2953
|
// //Get User Based Checklist //
|
|
2994
2954
|
const clientId = { client_id: req.user.clientId };
|
|
@@ -2999,7 +2959,7 @@ export async function dashboardv1( req, res ) {
|
|
|
2999
2959
|
// eslint-disable-next-line camelcase
|
|
3000
2960
|
// store_id,
|
|
3001
2961
|
userId,
|
|
3002
|
-
|
|
2962
|
+
date_string: date,
|
|
3003
2963
|
timeFlagStatus: true,
|
|
3004
2964
|
...clientId,
|
|
3005
2965
|
...storeMatch,
|
|
@@ -3025,7 +2985,9 @@ export async function dashboardv1( req, res ) {
|
|
|
3025
2985
|
},
|
|
3026
2986
|
];
|
|
3027
2987
|
|
|
3028
|
-
|
|
2988
|
+
let fromDate = new Date( req.query.date );
|
|
2989
|
+
let toDate = new Date( req.query.date );
|
|
2990
|
+
toDate.setDate( toDate.getDate() + 1 );
|
|
3029
2991
|
const taskBaseMatch = {
|
|
3030
2992
|
// eslint-disable-next-line camelcase
|
|
3031
2993
|
// store_id,
|
|
@@ -3074,8 +3036,6 @@ export async function dashboardv1( req, res ) {
|
|
|
3074
3036
|
processedTask.aggregate( taskQuery ),
|
|
3075
3037
|
] );
|
|
3076
3038
|
|
|
3077
|
-
console.log( checklistResult );
|
|
3078
|
-
|
|
3079
3039
|
const checklistResultData =
|
|
3080
3040
|
checklistResult.status === 'fulfilled' ?
|
|
3081
3041
|
processResult( checklistResult.value ) :
|
|
@@ -3205,9 +3165,6 @@ export async function checklistv1( req, res ) {
|
|
|
3205
3165
|
// const { store_id, date, checklistStatus, searchValue } = req.query;
|
|
3206
3166
|
const { date, checklistStatus, searchValue } = req.query;
|
|
3207
3167
|
const userId = req.user._id;
|
|
3208
|
-
let fromDate = new Date( req.query.date );
|
|
3209
|
-
let toDate = new Date( req.query.date );
|
|
3210
|
-
toDate.setDate( toDate.getDate() + 1 );
|
|
3211
3168
|
|
|
3212
3169
|
// Get User Based Checklist //
|
|
3213
3170
|
const clientId = { client_id: req.user.clientId };
|
|
@@ -3219,23 +3176,16 @@ export async function checklistv1( req, res ) {
|
|
|
3219
3176
|
// eslint-disable-next-line camelcase
|
|
3220
3177
|
// { store_id },
|
|
3221
3178
|
{ userId },
|
|
3222
|
-
|
|
3179
|
+
{ date_string: date },
|
|
3223
3180
|
{ timeFlagStatus: true },
|
|
3224
3181
|
...matchExtraConditions,
|
|
3225
3182
|
clientId,
|
|
3226
3183
|
storeMatch,
|
|
3227
3184
|
];
|
|
3228
|
-
if ( checklistStatus != 'submit' ) {
|
|
3229
|
-
matchConditions.push( { $or: [ { date_string: date }, { $and: [ { redoStatus: true }, { scheduleEndTime_iso: { $gte: fromDate } } ] } ] } );
|
|
3230
|
-
}
|
|
3231
|
-
if ( checklistStatus == 'submit' ) {
|
|
3232
|
-
matchConditions.push( { date_string: date } );
|
|
3233
|
-
}
|
|
3234
3185
|
if ( checklistStatus ) {
|
|
3235
3186
|
matchConditions.push( { checklistStatus } );
|
|
3236
3187
|
}
|
|
3237
3188
|
|
|
3238
|
-
|
|
3239
3189
|
const pipeline = [
|
|
3240
3190
|
{ $match: { $and: matchConditions } },
|
|
3241
3191
|
...( searchValue ?
|
|
@@ -3288,7 +3238,9 @@ export async function checklistv1( req, res ) {
|
|
|
3288
3238
|
return pipeline;
|
|
3289
3239
|
};
|
|
3290
3240
|
|
|
3291
|
-
|
|
3241
|
+
let fromDate = new Date( req.query.date );
|
|
3242
|
+
let toDate = new Date( req.query.date );
|
|
3243
|
+
toDate.setDate( toDate.getDate() + 1 );
|
|
3292
3244
|
const taskBuildPipeline = ( matchExtraConditions = [], projectExtraConditions = {} ) => {
|
|
3293
3245
|
const matchConditions = [
|
|
3294
3246
|
// eslint-disable-next-line camelcase
|
|
@@ -3668,7 +3620,7 @@ export async function questionList( req, res ) {
|
|
|
3668
3620
|
checkvalidation = answer.validationAnswer;
|
|
3669
3621
|
}
|
|
3670
3622
|
}
|
|
3671
|
-
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation
|
|
3623
|
+
Multianswer.push( { 'answer': answer.answer, 'no': ansIndex, 'validationAnswer': checkvalidation } );
|
|
3672
3624
|
getchecklist[0].questionAnswers[secIndex].questions[questionIndex].answers[ansIndex].index = ansIndex;
|
|
3673
3625
|
}
|
|
3674
3626
|
|
|
@@ -608,7 +608,7 @@ export const flagCardsV1 = async ( req, res ) => {
|
|
|
608
608
|
{
|
|
609
609
|
client_id: clientId,
|
|
610
610
|
publish: true,
|
|
611
|
-
checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] },
|
|
611
|
+
checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring' ] },
|
|
612
612
|
},
|
|
613
613
|
{ checkListType: 1 },
|
|
614
614
|
);
|
|
@@ -2743,7 +2743,7 @@ export const checklistDropdownV1 = async ( req, res ) => {
|
|
|
2743
2743
|
$or: [
|
|
2744
2744
|
{ questionFlag: { $gte: 1 } },
|
|
2745
2745
|
{ timeFlag: { $gte: 1 } },
|
|
2746
|
-
{ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] } },
|
|
2746
|
+
{ checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring' ] } },
|
|
2747
2747
|
{
|
|
2748
2748
|
runAIQuestionCount: { $gte: 1 },
|
|
2749
2749
|
},
|
|
@@ -2945,7 +2945,7 @@ export const flagComparisonCardsV2 = async ( req, res ) => {
|
|
|
2945
2945
|
{
|
|
2946
2946
|
client_id: requestData.clientId,
|
|
2947
2947
|
publish: true,
|
|
2948
|
-
checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] },
|
|
2948
|
+
checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring' ] },
|
|
2949
2949
|
},
|
|
2950
2950
|
{ checkListType: 1 },
|
|
2951
2951
|
);
|
|
@@ -3047,7 +3047,7 @@ export const flagTablesV2 = async ( req, res ) => {
|
|
|
3047
3047
|
}
|
|
3048
3048
|
|
|
3049
3049
|
if ( requestData?.filter === 'all' ) {
|
|
3050
|
-
findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] } } ] } );
|
|
3050
|
+
findAndQuery.push( { $or: [ { checkListType: { $in: [ 'custom', 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring' ] } } ] } );
|
|
3051
3051
|
} else if ( requestData?.filter === 'question' ) {
|
|
3052
3052
|
findAndQuery.push( { checkListType: 'custom' } );
|
|
3053
3053
|
findAndQuery.push( { questionFlag: { $gte: 1 } } );
|
|
@@ -3055,7 +3055,7 @@ export const flagTablesV2 = async ( req, res ) => {
|
|
|
3055
3055
|
findAndQuery.push( { checkListType: 'custom' } );
|
|
3056
3056
|
findAndQuery.push( { timeFlag: { $gte: 1 } } );
|
|
3057
3057
|
} else if ( requestData?.filter === 'detection' ) {
|
|
3058
|
-
findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ] } } );
|
|
3058
|
+
findAndQuery.push( { checkListType: { $in: [ 'customerunattended', 'mobileusagedetection', 'staffleftinthemiddle', 'storeopenandclose', 'uniformdetection', 'cleaning', 'scrum', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount', 'storehygienemonitoring' ] } } );
|
|
3059
3059
|
} else if ( requestData?.filter === 'runAI' ) {
|
|
3060
3060
|
if ( req.body.runAIChecklistName ) {
|
|
3061
3061
|
findAndQuery.push( { checkListName: { $in: req.body.runAIChecklistName } } );
|
|
@@ -4131,7 +4131,7 @@ async function updateOpenSearch( user, data ) {
|
|
|
4131
4131
|
export const aiChecklist = async ( req, res ) => {
|
|
4132
4132
|
try {
|
|
4133
4133
|
let storeDetails = await storeService.count( { clientId: req.query.clientId, status: 'active' } );
|
|
4134
|
-
let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', '
|
|
4134
|
+
let aiList = [ 'mobileusagedetection', 'storeopenandclose', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'eyetest', 'remoteoptometrist', 'storehygienemonitoring', 'cleaning', 'scrum', 'suspiciousactivity', 'suspiciousfootfall', 'drinking', 'bagdetection', 'inventorycount', 'carsattended', 'numberplateinfo', 'vehicle_check_in', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ];
|
|
4135
4135
|
let checklistDetails = [];
|
|
4136
4136
|
let publishList = [];
|
|
4137
4137
|
let unpublishList = [];
|
|
@@ -4144,7 +4144,7 @@ export const aiChecklist = async ( req, res ) => {
|
|
|
4144
4144
|
checklistDetails = [ ...publishList, ...unpublishList ];
|
|
4145
4145
|
|
|
4146
4146
|
checklistDetails.forEach( ( item ) => {
|
|
4147
|
-
if ( ![ 'mobileusagedetection', 'storeopenandclose', 'cleaning', 'scrum', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert' ].includes( item.checkListType ) ) {
|
|
4147
|
+
if ( ![ 'mobileusagedetection', 'storeopenandclose', 'cleaning', 'scrum', 'uniformdetection', 'staffleftinthemiddle', 'customerunattended', 'outsidebusinesshoursqueuetracking', 'halfshutter', 'tvcompliance', 'cameratampering', 'queuealert', 'staffgrouping', 'boxalert', 'employeeCount' ].includes( item.checkListType ) ) {
|
|
4148
4148
|
item.storeCount = storeDetails;
|
|
4149
4149
|
}
|
|
4150
4150
|
} );
|