tango-app-api-audit 3.4.51 → 3.4.52
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
|
@@ -66,7 +66,22 @@ export async function workSpace( req, res ) {
|
|
|
66
66
|
{ $eq: [ inputData.moduleType, 'eye-test-camera' ] }, '$auditConfigs.traxQueueName.eyeTestCamera',
|
|
67
67
|
{
|
|
68
68
|
$cond: [
|
|
69
|
-
{ $eq: [ inputData.moduleType, 'cleaning' ] }, '$auditConfigs.traxQueueName.cleaning',
|
|
69
|
+
{ $eq: [ inputData.moduleType, 'cleaning' ] }, '$auditConfigs.traxQueueName.cleaning',
|
|
70
|
+
{
|
|
71
|
+
$cond: [
|
|
72
|
+
{ $eq: [ inputData.moduleType, 'scrum' ] }, '$auditConfigs.traxQueueName.scrum',
|
|
73
|
+
{
|
|
74
|
+
$cond: [
|
|
75
|
+
{ $eq: [ inputData.moduleType, 'open-time' ] }, '$auditConfigs.traxQueueName.openTime',
|
|
76
|
+
{
|
|
77
|
+
$cond: [
|
|
78
|
+
{ $eq: [ inputData.moduleType, 'close-time' ] }, '$auditConfigs.traxQueueName.closeTime', '$auditConfigs.traxQueueName.anomaly' ],
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
70
85
|
},
|
|
71
86
|
],
|
|
72
87
|
},
|
|
@@ -208,18 +223,11 @@ export async function workSpace( req, res ) {
|
|
|
208
223
|
},
|
|
209
224
|
},
|
|
210
225
|
},
|
|
211
|
-
|
|
212
|
-
// $group: {
|
|
213
|
-
// _id: { clientId: '$clientId', storeId: '$storeId' },
|
|
214
|
-
// clientId: { $first: '$clientId' },
|
|
215
|
-
// completedStoresCount: { $sum: '$completed' },
|
|
216
|
-
// },
|
|
217
|
-
// },
|
|
226
|
+
|
|
218
227
|
{
|
|
219
228
|
$group: {
|
|
220
229
|
_id: '$clientId',
|
|
221
230
|
clientId: { $first: '$clientId' },
|
|
222
|
-
// completedStoresCount: { $first: '$completedStoresCount' },
|
|
223
231
|
completedStoresCount: { $sum: '$completed' },
|
|
224
232
|
},
|
|
225
233
|
},
|
|
@@ -544,6 +552,7 @@ export async function getAuditFile( req, res ) {
|
|
|
544
552
|
};
|
|
545
553
|
break;
|
|
546
554
|
case 'camera-angle-change':
|
|
555
|
+
case 'anomaly-audit':
|
|
547
556
|
query ={
|
|
548
557
|
storeId: userDetails[0].storeId,
|
|
549
558
|
fileDate: userDetails[0].fileDate,
|
|
@@ -632,10 +641,6 @@ export async function getAuditFile( req, res ) {
|
|
|
632
641
|
const folderPath = list.data;
|
|
633
642
|
if ( folderPath?.length ) {
|
|
634
643
|
for ( let i = 0; i < folderPath.length; i++ ) {
|
|
635
|
-
// const signedParams ={
|
|
636
|
-
// Bucket: msg.inputBucketName,
|
|
637
|
-
// file_path: folderPath[i].Key,
|
|
638
|
-
// };
|
|
639
644
|
const BucketCDN = url.traxAuditInput;
|
|
640
645
|
const data = `${BucketCDN}${ folderPath[i].Key}`;
|
|
641
646
|
files.push(
|
|
@@ -682,6 +687,19 @@ export async function getAuditFile( req, res ) {
|
|
|
682
687
|
file: eyeTestfiles,
|
|
683
688
|
} );
|
|
684
689
|
break;
|
|
690
|
+
case 'anomaly-audit':
|
|
691
|
+
for ( let i =0; i< msg.fileDetails.length; i++ ) {
|
|
692
|
+
const files = [];
|
|
693
|
+
const data = msg.fileDetails[i].folderPath;
|
|
694
|
+
files.push(
|
|
695
|
+
data,
|
|
696
|
+
);
|
|
697
|
+
result.push( {
|
|
698
|
+
type: msg.fileDetails[i].type,
|
|
699
|
+
file: files,
|
|
700
|
+
} );
|
|
701
|
+
}
|
|
702
|
+
break;
|
|
685
703
|
default:
|
|
686
704
|
return res.sendError( 'Please given valid moduleType', 400 );
|
|
687
705
|
}
|
|
@@ -722,7 +740,7 @@ export async function getAuditFile( req, res ) {
|
|
|
722
740
|
questionType: msg.questionType,
|
|
723
741
|
streamName: msg.streamName,
|
|
724
742
|
};
|
|
725
|
-
record.streamName = inputData.moduleType == 'camera-angle-change' || inputData.moduleType == 'eye-test-camera'? msg.streamName : '';
|
|
743
|
+
record.streamName = inputData.moduleType == 'camera-angle-change' || inputData.moduleType == 'eye-test-camera' || inputData.moduleType == 'anomaly-audit'? msg.streamName : '';
|
|
726
744
|
record.videoDetails = inputData.moduleType == 'left-in-middle'? {
|
|
727
745
|
'startHour': msg.startHour,
|
|
728
746
|
'inspectHour': msg.inspectHour,
|
|
@@ -752,6 +770,7 @@ export async function getAuditFile( req, res ) {
|
|
|
752
770
|
break;
|
|
753
771
|
case 'camera-angle-change':
|
|
754
772
|
case 'eye-test-camera':
|
|
773
|
+
case 'anomaly-audit':
|
|
755
774
|
getQuery ={
|
|
756
775
|
storeId: msg.storeId,
|
|
757
776
|
fileDate: msg.fileDate,
|
|
@@ -897,10 +916,6 @@ export async function getUpdatedFile( req, res ) {
|
|
|
897
916
|
logger.info( { folderPath: list, params: params, list: list } );
|
|
898
917
|
if ( folderPath?.length ) {
|
|
899
918
|
for ( let i = 0; i < folderPath.length; i++ ) {
|
|
900
|
-
// const signedParams ={
|
|
901
|
-
// Bucket: msg.inputBucketName,
|
|
902
|
-
// file_path: folderPath[i].Key,
|
|
903
|
-
// };
|
|
904
919
|
const BucketCDN = url.traxAuditInput;
|
|
905
920
|
const data = `${BucketCDN}${ folderPath[i].Key}`;
|
|
906
921
|
|
|
@@ -947,6 +962,19 @@ export async function getUpdatedFile( req, res ) {
|
|
|
947
962
|
file: eyeTestfiles,
|
|
948
963
|
} );
|
|
949
964
|
break;
|
|
965
|
+
case 'anomaly-audit':
|
|
966
|
+
for ( let i =0; i< msg.fileDetails.length; i++ ) {
|
|
967
|
+
const files = [];
|
|
968
|
+
const data = msg.fileDetails[i].folderPath;
|
|
969
|
+
files.push(
|
|
970
|
+
data,
|
|
971
|
+
);
|
|
972
|
+
result.push( {
|
|
973
|
+
type: msg.fileDetails[i].type,
|
|
974
|
+
file: files,
|
|
975
|
+
} );
|
|
976
|
+
}
|
|
977
|
+
break;
|
|
950
978
|
default:
|
|
951
979
|
return res.sendError( 'Please given valid moduleType', 400 );
|
|
952
980
|
}
|
|
@@ -1393,6 +1421,120 @@ export async function saveBinary( req, res ) {
|
|
|
1393
1421
|
return res.sendSuccess( `Successfully updated in ${value}` );
|
|
1394
1422
|
}
|
|
1395
1423
|
|
|
1424
|
+
case 'anomaly-audit':
|
|
1425
|
+
let anomalyQury ={
|
|
1426
|
+
_id: inputData.auditId,
|
|
1427
|
+
storeId: inputData.storeId,
|
|
1428
|
+
fileDate: inputData.fileDate,
|
|
1429
|
+
tempId: inputData.tempId,
|
|
1430
|
+
moduleType: inputData.moduleType,
|
|
1431
|
+
};
|
|
1432
|
+
|
|
1433
|
+
let anomalyRecord={
|
|
1434
|
+
auditStatus: 'completed',
|
|
1435
|
+
answer: inputData.answer,
|
|
1436
|
+
userComments: inputData.userComments || '',
|
|
1437
|
+
endTime: new Date(),
|
|
1438
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1439
|
+
};
|
|
1440
|
+
let updatedAnomaly= await updateOneBinaryAuditModel( anomalyQury, anomalyRecord );
|
|
1441
|
+
if ( updatedAnomaly==0 ) {
|
|
1442
|
+
return res.sendError( 'Update failed, it may be invalid request', 400 );
|
|
1443
|
+
}
|
|
1444
|
+
let anomalyFilter= [
|
|
1445
|
+
{
|
|
1446
|
+
'term': {
|
|
1447
|
+
'storeId.keyword': inputData.storeId,
|
|
1448
|
+
},
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
'term': {
|
|
1452
|
+
'fileDate.keyword': inputData.fileDate,
|
|
1453
|
+
},
|
|
1454
|
+
},
|
|
1455
|
+
{
|
|
1456
|
+
'term': {
|
|
1457
|
+
'moduleType.keyword': inputData.moduleType,
|
|
1458
|
+
},
|
|
1459
|
+
},
|
|
1460
|
+
{
|
|
1461
|
+
'term': {
|
|
1462
|
+
'moduleType.keyword': inputData.streamName,
|
|
1463
|
+
},
|
|
1464
|
+
},
|
|
1465
|
+
];
|
|
1466
|
+
let anomalySearchQuery={
|
|
1467
|
+
'size': 1,
|
|
1468
|
+
'query': {
|
|
1469
|
+
'bool': {
|
|
1470
|
+
'must': anomalyFilter,
|
|
1471
|
+
},
|
|
1472
|
+
},
|
|
1473
|
+
};
|
|
1474
|
+
const [ getStore, getClient ] = await Promise.all( [ findOneStore( { storeId: inputData.storeId }, { storeName: 1, storeProfile: 1, spocDetails: 1 } ), findOneClient( { clientId: req.userAudit?.clientId }, { clientName: 1 } ) ] );
|
|
1475
|
+
const getData = await findOneTraxAuditData(
|
|
1476
|
+
{
|
|
1477
|
+
fileDate: inputData.fileDate,
|
|
1478
|
+
storeId: inputData.storeId,
|
|
1479
|
+
moduleType: inputData.moduleType,
|
|
1480
|
+
streamName: inputData.streamName,
|
|
1481
|
+
},
|
|
1482
|
+
);
|
|
1483
|
+
const output = {
|
|
1484
|
+
clientId: req.userAudit?.clientId,
|
|
1485
|
+
clientName: getClient?.clientName,
|
|
1486
|
+
storeId: inputData.storeId,
|
|
1487
|
+
storeName: getStore?.storeName,
|
|
1488
|
+
question: getData?.sqs?.Body?.question,
|
|
1489
|
+
spocName: getStore?.spocDetails? getStore?.spocDetails[0]?.name : '',
|
|
1490
|
+
spocEmail: getStore?.spocDetails? getStore?.spocDetails[0]?.email:'',
|
|
1491
|
+
spocContact: getStore?.spocDetails? getStore?.spocDetails[0].contact:'',
|
|
1492
|
+
address: getStore?.storeProfile?.address,
|
|
1493
|
+
fileDate: inputData.fileDate,
|
|
1494
|
+
moduleType: inputData.moduleType,
|
|
1495
|
+
Answer: inputData.answer,
|
|
1496
|
+
configTime: getData?.sqs?.Body?.configTime,
|
|
1497
|
+
inputBucketName: getData?.sqs?.Body?.inputBucketName,
|
|
1498
|
+
incidentType: getData?.sqs?.Body?.incidentType,
|
|
1499
|
+
incidentId: getData?.sqs?.Body?.incidentId,
|
|
1500
|
+
incidentTime: getData?.sqs?.Body?.incidentTime,
|
|
1501
|
+
thumnailImage: getData?.sqs?.Body?.thumnailImage,
|
|
1502
|
+
folderPath: getData?.sqs?.Body?.fileDetails[0]?.outputFilePath,
|
|
1503
|
+
createdAt: new Date(),
|
|
1504
|
+
};
|
|
1505
|
+
const anomalySearchData= await getOpenSearchData( openSearch.traxDetectionOutput, anomalySearchQuery );
|
|
1506
|
+
logger.info( { length: anomalySearchData?.body?.hits?.hits?.length, _id: anomalySearchData?.body?.hits?.hits[0]?._id, output: output } );
|
|
1507
|
+
if ( anomalySearchData?.body?.hits?.hits?.length >0 ) {
|
|
1508
|
+
await updateOpenSearchData( openSearch.traxDetectionOutput, anomalySearchData?.body?.hits?.hits[0]?._id, { doc: output } );
|
|
1509
|
+
} else {
|
|
1510
|
+
await insertOpenSearchData( openSearch.traxDetectionOutput, output );
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
const logData4 = {
|
|
1514
|
+
userId: req.user._id,
|
|
1515
|
+
userName: req.user.userName,
|
|
1516
|
+
logType: 'traxAudit',
|
|
1517
|
+
logSubType: 'auditDone',
|
|
1518
|
+
logData: {
|
|
1519
|
+
fileDate: req.userAudit?.fileDate,
|
|
1520
|
+
auditType: req.userAudit?.auditType,
|
|
1521
|
+
storeId: req.userAudit?.storeId,
|
|
1522
|
+
moduleType: req.userAudit?.moduleType,
|
|
1523
|
+
queueName: req.userAudit?.queueName,
|
|
1524
|
+
clientId: req.userAudit?.clientId,
|
|
1525
|
+
startTime: req.userAudit?.startTime,
|
|
1526
|
+
streamName: req.userAudit?.streamName,
|
|
1527
|
+
tempId: req.userAudit?.tempId,
|
|
1528
|
+
question: req.userAudit?.question,
|
|
1529
|
+
result: req.userAudit?.answer,
|
|
1530
|
+
endTime: Date.now(),
|
|
1531
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1532
|
+
auditId: new mongoose.Types.ObjectId( inputData.auditId ),
|
|
1533
|
+
},
|
|
1534
|
+
createdAt: Date.now(),
|
|
1535
|
+
};
|
|
1536
|
+
await insertOpenSearchData( openSearch.auditLog, logData4 );
|
|
1537
|
+
return res.sendSuccess( `Successfully updated in ${value}` );
|
|
1396
1538
|
|
|
1397
1539
|
default:
|
|
1398
1540
|
res.sendError( 'No Data', 204 );
|
|
@@ -1507,6 +1649,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1507
1649
|
},
|
|
1508
1650
|
];
|
|
1509
1651
|
break;
|
|
1652
|
+
case 'anomaly-audit':
|
|
1510
1653
|
case 'camera-angle-change':
|
|
1511
1654
|
traxAuditDataQuery= {
|
|
1512
1655
|
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
|
|
@@ -1694,9 +1837,6 @@ export async function userAuditHistory( req, res ) {
|
|
|
1694
1837
|
timezone: 'Asia/Kolkata',
|
|
1695
1838
|
},
|
|
1696
1839
|
},
|
|
1697
|
-
// timeSpent: { $round: [
|
|
1698
|
-
// { $divide: [ '$timeSpent', 60 ] }, 2,
|
|
1699
|
-
// ] },
|
|
1700
1840
|
timeSpent: {
|
|
1701
1841
|
|
|
1702
1842
|
$cond: [
|
|
@@ -1787,6 +1927,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1787
1927
|
|
|
1788
1928
|
};
|
|
1789
1929
|
switch ( inputData.moduleType ) {
|
|
1930
|
+
case 'anomaly-audit':
|
|
1790
1931
|
case 'camera-angle-change':
|
|
1791
1932
|
temp['stream Name'] = element.streamName;
|
|
1792
1933
|
temp['Result'] = element.answer;
|
|
@@ -2217,6 +2358,124 @@ export async function storeMetrics( req, res ) {
|
|
|
2217
2358
|
if ( inputData.filterByAuditType && inputData.filterByAuditType?.length > 0 ) {
|
|
2218
2359
|
filter.push( { auditType: { $in: inputData.filterByAuditType } } );
|
|
2219
2360
|
}
|
|
2361
|
+
let traxAuditDataQuery ={};
|
|
2362
|
+
let traxAuditDataFilter = [];
|
|
2363
|
+
switch ( inputData.moduleType ) {
|
|
2364
|
+
case 'unattended-customer':
|
|
2365
|
+
traxAuditDataQuery= {
|
|
2366
|
+
fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
|
|
2367
|
+
};
|
|
2368
|
+
traxAuditDataFilter=[ {
|
|
2369
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2370
|
+
},
|
|
2371
|
+
{
|
|
2372
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2373
|
+
},
|
|
2374
|
+
{
|
|
2375
|
+
$eq: [ '$tempId', '$$tempId' ],
|
|
2376
|
+
},
|
|
2377
|
+
{
|
|
2378
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2379
|
+
},
|
|
2380
|
+
];
|
|
2381
|
+
break;
|
|
2382
|
+
case 'left-in-middle':
|
|
2383
|
+
traxAuditDataQuery= {
|
|
2384
|
+
fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
|
|
2385
|
+
};
|
|
2386
|
+
traxAuditDataFilter=[ {
|
|
2387
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2388
|
+
},
|
|
2389
|
+
{
|
|
2390
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2391
|
+
},
|
|
2392
|
+
{
|
|
2393
|
+
$eq: [ '$question', '$$question' ],
|
|
2394
|
+
},
|
|
2395
|
+
{
|
|
2396
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2397
|
+
},
|
|
2398
|
+
];
|
|
2399
|
+
break;
|
|
2400
|
+
case 'uniform-detection':
|
|
2401
|
+
case 'mobile-detection':
|
|
2402
|
+
case 'scrum':
|
|
2403
|
+
case 'cleaning':
|
|
2404
|
+
traxAuditDataQuery= {
|
|
2405
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType',
|
|
2406
|
+
};
|
|
2407
|
+
traxAuditDataFilter=[ {
|
|
2408
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2409
|
+
},
|
|
2410
|
+
{
|
|
2411
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2412
|
+
},
|
|
2413
|
+
{
|
|
2414
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2415
|
+
},
|
|
2416
|
+
];
|
|
2417
|
+
break;
|
|
2418
|
+
case 'anomaly-audit':
|
|
2419
|
+
case 'camera-angle-change':
|
|
2420
|
+
traxAuditDataQuery= {
|
|
2421
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
|
|
2422
|
+
};
|
|
2423
|
+
traxAuditDataFilter=[ {
|
|
2424
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2425
|
+
},
|
|
2426
|
+
{
|
|
2427
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2428
|
+
},
|
|
2429
|
+
{
|
|
2430
|
+
$eq: [ '$streamName', '$$streamName' ],
|
|
2431
|
+
},
|
|
2432
|
+
{
|
|
2433
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2434
|
+
},
|
|
2435
|
+
];
|
|
2436
|
+
break;
|
|
2437
|
+
case 'hygiene':
|
|
2438
|
+
traxAuditDataQuery= {
|
|
2439
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', zoneName: '$zoneName',
|
|
2440
|
+
};
|
|
2441
|
+
traxAuditDataFilter=[ {
|
|
2442
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2443
|
+
},
|
|
2444
|
+
{
|
|
2445
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2446
|
+
},
|
|
2447
|
+
{
|
|
2448
|
+
$eq: [ '$zoneName', '$$zoneName' ],
|
|
2449
|
+
},
|
|
2450
|
+
{
|
|
2451
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2452
|
+
},
|
|
2453
|
+
];
|
|
2454
|
+
break;
|
|
2455
|
+
case 'eye-test-camera':
|
|
2456
|
+
traxAuditDataQuery= {
|
|
2457
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', question: '$question', streamName: '$streamName',
|
|
2458
|
+
};
|
|
2459
|
+
traxAuditDataFilter=[ {
|
|
2460
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2461
|
+
},
|
|
2462
|
+
{
|
|
2463
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
2464
|
+
},
|
|
2465
|
+
{
|
|
2466
|
+
$eq: [ '$question', '$$question' ],
|
|
2467
|
+
},
|
|
2468
|
+
{
|
|
2469
|
+
$eq: [ '$streamName', '$$streamName' ],
|
|
2470
|
+
},
|
|
2471
|
+
{
|
|
2472
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
2473
|
+
},
|
|
2474
|
+
];
|
|
2475
|
+
break;
|
|
2476
|
+
default:
|
|
2477
|
+
return res.sendError( 'Please give valid modueType', 400 );
|
|
2478
|
+
}
|
|
2220
2479
|
|
|
2221
2480
|
|
|
2222
2481
|
const query = [
|
|
@@ -2256,24 +2515,12 @@ export async function storeMetrics( req, res ) {
|
|
|
2256
2515
|
{
|
|
2257
2516
|
$lookup: {
|
|
2258
2517
|
from: 'traxAuditData',
|
|
2259
|
-
let:
|
|
2260
|
-
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
2261
|
-
},
|
|
2518
|
+
let: traxAuditDataQuery,
|
|
2262
2519
|
pipeline: [
|
|
2263
2520
|
{
|
|
2264
2521
|
$match: {
|
|
2265
2522
|
$expr: {
|
|
2266
|
-
$and:
|
|
2267
|
-
{
|
|
2268
|
-
$eq: [ '$fileDate', '$$fileDate' ],
|
|
2269
|
-
},
|
|
2270
|
-
{
|
|
2271
|
-
$eq: [ '$storeId', '$$storeId' ],
|
|
2272
|
-
},
|
|
2273
|
-
{
|
|
2274
|
-
$eq: [ '$zoneName', '$$zoneName' ],
|
|
2275
|
-
},
|
|
2276
|
-
],
|
|
2523
|
+
$and: traxAuditDataFilter,
|
|
2277
2524
|
},
|
|
2278
2525
|
},
|
|
2279
2526
|
},
|
|
@@ -2725,6 +2972,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2725
2972
|
};
|
|
2726
2973
|
switch ( inputData.moduleType ) {
|
|
2727
2974
|
case 'camera-angle-change':
|
|
2975
|
+
case 'anomaly-audit':
|
|
2728
2976
|
temp['stream Name'] = element.streamName;
|
|
2729
2977
|
temp['User Comments'] = element.userComments;
|
|
2730
2978
|
temp['Status'] = toCamelCase( element.auditStatus );
|
|
@@ -3119,7 +3367,125 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3119
3367
|
if ( inputData.filterByStatus.length > 0 ) {
|
|
3120
3368
|
filters.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
3121
3369
|
}
|
|
3122
|
-
|
|
3370
|
+
|
|
3371
|
+
let traxAuditDataQuery={};
|
|
3372
|
+
let traxAuditDataFilter = [];
|
|
3373
|
+
switch ( inputData.moduleType ) {
|
|
3374
|
+
case 'unattended-customer':
|
|
3375
|
+
traxAuditDataQuery= {
|
|
3376
|
+
fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
|
|
3377
|
+
};
|
|
3378
|
+
traxAuditDataFilter=[ {
|
|
3379
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3380
|
+
},
|
|
3381
|
+
{
|
|
3382
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3383
|
+
},
|
|
3384
|
+
{
|
|
3385
|
+
$eq: [ '$tempId', '$$tempId' ],
|
|
3386
|
+
},
|
|
3387
|
+
{
|
|
3388
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3389
|
+
},
|
|
3390
|
+
];
|
|
3391
|
+
break;
|
|
3392
|
+
case 'left-in-middle':
|
|
3393
|
+
traxAuditDataQuery= {
|
|
3394
|
+
fileDate: '$fileDate', storeId: '$storeId', tempId: '$tempId', moduleType: '$moduleType',
|
|
3395
|
+
};
|
|
3396
|
+
traxAuditDataFilter=[ {
|
|
3397
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3398
|
+
},
|
|
3399
|
+
{
|
|
3400
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3401
|
+
},
|
|
3402
|
+
{
|
|
3403
|
+
$eq: [ '$question', '$$question' ],
|
|
3404
|
+
},
|
|
3405
|
+
{
|
|
3406
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3407
|
+
},
|
|
3408
|
+
];
|
|
3409
|
+
break;
|
|
3410
|
+
case 'uniform-detection':
|
|
3411
|
+
case 'mobile-detection':
|
|
3412
|
+
case 'scrum':
|
|
3413
|
+
case 'cleaning':
|
|
3414
|
+
traxAuditDataQuery= {
|
|
3415
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType',
|
|
3416
|
+
};
|
|
3417
|
+
traxAuditDataFilter=[ {
|
|
3418
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3419
|
+
},
|
|
3420
|
+
{
|
|
3421
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3422
|
+
},
|
|
3423
|
+
{
|
|
3424
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3425
|
+
},
|
|
3426
|
+
];
|
|
3427
|
+
break;
|
|
3428
|
+
case 'anomaly-audit':
|
|
3429
|
+
case 'camera-angle-change':
|
|
3430
|
+
traxAuditDataQuery= {
|
|
3431
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
|
|
3432
|
+
};
|
|
3433
|
+
traxAuditDataFilter=[ {
|
|
3434
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3435
|
+
},
|
|
3436
|
+
{
|
|
3437
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3438
|
+
},
|
|
3439
|
+
{
|
|
3440
|
+
$eq: [ '$streamName', '$$streamName' ],
|
|
3441
|
+
},
|
|
3442
|
+
{
|
|
3443
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3444
|
+
},
|
|
3445
|
+
];
|
|
3446
|
+
break;
|
|
3447
|
+
case 'hygiene':
|
|
3448
|
+
traxAuditDataQuery= {
|
|
3449
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', zoneName: '$zoneName',
|
|
3450
|
+
};
|
|
3451
|
+
traxAuditDataFilter=[ {
|
|
3452
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3453
|
+
},
|
|
3454
|
+
{
|
|
3455
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3456
|
+
},
|
|
3457
|
+
{
|
|
3458
|
+
$eq: [ '$zoneName', '$$zoneName' ],
|
|
3459
|
+
},
|
|
3460
|
+
{
|
|
3461
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3462
|
+
},
|
|
3463
|
+
];
|
|
3464
|
+
break;
|
|
3465
|
+
case 'eye-test-camera':
|
|
3466
|
+
traxAuditDataQuery= {
|
|
3467
|
+
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', question: '$question', streamName: '$streamName',
|
|
3468
|
+
};
|
|
3469
|
+
traxAuditDataFilter=[ {
|
|
3470
|
+
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3471
|
+
},
|
|
3472
|
+
{
|
|
3473
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
3474
|
+
},
|
|
3475
|
+
{
|
|
3476
|
+
$eq: [ '$question', '$$question' ],
|
|
3477
|
+
},
|
|
3478
|
+
{
|
|
3479
|
+
$eq: [ '$streamName', '$$streamName' ],
|
|
3480
|
+
},
|
|
3481
|
+
{
|
|
3482
|
+
$eq: [ '$moduleType', '$$moduleType' ],
|
|
3483
|
+
},
|
|
3484
|
+
];
|
|
3485
|
+
break;
|
|
3486
|
+
default:
|
|
3487
|
+
return res.sendError( 'Please give valid modueType', 400 );
|
|
3488
|
+
} const query =[
|
|
3123
3489
|
{
|
|
3124
3490
|
$match: {
|
|
3125
3491
|
$and: filters,
|
|
@@ -3129,24 +3495,12 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3129
3495
|
{
|
|
3130
3496
|
$lookup: {
|
|
3131
3497
|
from: 'traxAuditData',
|
|
3132
|
-
let:
|
|
3133
|
-
fileDate: '$fileDate', storeId: '$storeId', zoneName: '$zoneName',
|
|
3134
|
-
},
|
|
3498
|
+
let: traxAuditDataQuery,
|
|
3135
3499
|
pipeline: [
|
|
3136
3500
|
{
|
|
3137
3501
|
$match: {
|
|
3138
3502
|
$expr: {
|
|
3139
|
-
$and:
|
|
3140
|
-
{
|
|
3141
|
-
$eq: [ '$fileDate', '$$fileDate' ],
|
|
3142
|
-
},
|
|
3143
|
-
{
|
|
3144
|
-
$eq: [ '$storeId', '$$storeId' ],
|
|
3145
|
-
},
|
|
3146
|
-
{
|
|
3147
|
-
$eq: [ '$zoneName', '$$zoneName' ],
|
|
3148
|
-
},
|
|
3149
|
-
],
|
|
3503
|
+
$and: traxAuditDataFilter,
|
|
3150
3504
|
},
|
|
3151
3505
|
},
|
|
3152
3506
|
},
|
|
@@ -3257,7 +3611,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3257
3611
|
{ userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3258
3612
|
{ userEmail: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3259
3613
|
{ value: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3260
|
-
{ question: { $regex: inputData.
|
|
3614
|
+
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3261
3615
|
],
|
|
3262
3616
|
|
|
3263
3617
|
},
|
|
@@ -3302,6 +3656,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3302
3656
|
'Status': toCamelCase( element.auditStatus ),
|
|
3303
3657
|
};
|
|
3304
3658
|
switch ( inputData.moduleType ) {
|
|
3659
|
+
case 'anomaly-audit':
|
|
3305
3660
|
case 'camera-angle-change':
|
|
3306
3661
|
temp['stream Name'] = element.streamName;
|
|
3307
3662
|
break;
|
|
@@ -3767,6 +4122,7 @@ export async function overviewTable( req, res ) {
|
|
|
3767
4122
|
},
|
|
3768
4123
|
];
|
|
3769
4124
|
break;
|
|
4125
|
+
case 'anomaly-audit':
|
|
3770
4126
|
case 'camera-angle-change':
|
|
3771
4127
|
traxAuditDataQuery= {
|
|
3772
4128
|
fileDate: '$fileDate', storeId: '$storeId', moduleType: '$moduleType', streamName: '$streamName',
|
|
@@ -3824,6 +4180,7 @@ export async function overviewTable( req, res ) {
|
|
|
3824
4180
|
},
|
|
3825
4181
|
];
|
|
3826
4182
|
break;
|
|
4183
|
+
|
|
3827
4184
|
default:
|
|
3828
4185
|
return res.sendError( 'Please give valid modueType', 400 );
|
|
3829
4186
|
}
|
|
@@ -3964,6 +4321,7 @@ export async function overviewTable( req, res ) {
|
|
|
3964
4321
|
};
|
|
3965
4322
|
|
|
3966
4323
|
switch ( inputData.moduleType ) {
|
|
4324
|
+
case 'anomaly-audit':
|
|
3967
4325
|
case 'camera-angle-change':
|
|
3968
4326
|
temp['stream Name'] = element.streamName;
|
|
3969
4327
|
temp['User Comments'] = element.userComments;
|
|
@@ -4400,6 +4758,7 @@ export async function saveDraft( req, res ) {
|
|
|
4400
4758
|
let storeQuery = {
|
|
4401
4759
|
storeId: inputData.storeId,
|
|
4402
4760
|
fileDate: inputData.fileDate,
|
|
4761
|
+
moduleType: inputData.moduleType,
|
|
4403
4762
|
};
|
|
4404
4763
|
|
|
4405
4764
|
inputData?.zoneName ? storeQuery['zoneName'] = inputData?.zoneName : null;
|