tango-app-api-audit 3.4.5 → 3.4.6
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
|
@@ -1927,10 +1927,16 @@ export async function clientMetrics( req, res ) {
|
|
|
1927
1927
|
return res.sendError( 'No Data Found', 204 );
|
|
1928
1928
|
}
|
|
1929
1929
|
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1930
|
+
if ( inputData.isExport ) {
|
|
1931
|
+
query.push( { $limit: 10000 } );
|
|
1932
|
+
} else {
|
|
1933
|
+
query.push( {
|
|
1934
|
+
$skip: offset,
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
$limit: limit,
|
|
1938
|
+
} );
|
|
1939
|
+
}
|
|
1934
1940
|
if ( inputData.isExport ) {
|
|
1935
1941
|
query.push(
|
|
1936
1942
|
{
|
|
@@ -2311,7 +2317,7 @@ export async function userMetrics( req, res ) {
|
|
|
2311
2317
|
startTime: 1,
|
|
2312
2318
|
endTime: 1,
|
|
2313
2319
|
totalCompletedFiles: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, 1, 0 ] },
|
|
2314
|
-
beforeCount:
|
|
2320
|
+
beforeCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$beforeCount', 0 ] },
|
|
2315
2321
|
afterCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$afterCount', 0 ] },
|
|
2316
2322
|
createdAt: 1,
|
|
2317
2323
|
},
|
|
@@ -2504,10 +2510,16 @@ export async function userMetrics( req, res ) {
|
|
|
2504
2510
|
return res.sendError( 'No Data Found', 204 );
|
|
2505
2511
|
}
|
|
2506
2512
|
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2513
|
+
if ( inputData.isExport ) {
|
|
2514
|
+
query.push( { $limit: 10000 } );
|
|
2515
|
+
} else {
|
|
2516
|
+
query.push( {
|
|
2517
|
+
$skip: offset,
|
|
2518
|
+
},
|
|
2519
|
+
{
|
|
2520
|
+
$limit: limit,
|
|
2521
|
+
} );
|
|
2522
|
+
}
|
|
2511
2523
|
if ( inputData.isExport ) {
|
|
2512
2524
|
query.push(
|
|
2513
2525
|
{
|
|
@@ -4536,52 +4548,208 @@ export async function getUserAuditCountMTD( req, res ) {
|
|
|
4536
4548
|
export async function auditViewLogs( req, res ) {
|
|
4537
4549
|
try {
|
|
4538
4550
|
const inputData = req.query;
|
|
4551
|
+
let logsQuery;
|
|
4539
4552
|
const parsedOpenSearch = JSON.parse( process.env.OPENSEARCH );
|
|
4540
4553
|
const logData =[];
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
'
|
|
4545
|
-
'
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
'
|
|
4554
|
+
if ( inputData.moduleType == 'traffic' ||inputData.moduleType == 'zone' ) {
|
|
4555
|
+
logsQuery = {
|
|
4556
|
+
'size': 100,
|
|
4557
|
+
'query': {
|
|
4558
|
+
'bool': {
|
|
4559
|
+
'must': [
|
|
4560
|
+
{
|
|
4561
|
+
'term': {
|
|
4562
|
+
'logData.fileDate.keyword': inputData.fileDate,
|
|
4563
|
+
},
|
|
4564
|
+
},
|
|
4565
|
+
{
|
|
4566
|
+
'term': {
|
|
4567
|
+
'logData.storeId.keyword': inputData.storeId,
|
|
4568
|
+
},
|
|
4569
|
+
},
|
|
4570
|
+
{
|
|
4571
|
+
'term': {
|
|
4572
|
+
'logData.moduleType.keyword': inputData.moduleType,
|
|
4573
|
+
},
|
|
4574
|
+
},
|
|
4575
|
+
{
|
|
4576
|
+
'term': {
|
|
4577
|
+
'logData.zoneName.keyword': inputData.zoneName,
|
|
4578
|
+
},
|
|
4579
|
+
},
|
|
4580
|
+
{
|
|
4581
|
+
'terms': {
|
|
4582
|
+
'logSubType.keyword': [ 'auditDone', 'reTrigger' ],
|
|
4583
|
+
},
|
|
4584
|
+
},
|
|
4585
|
+
],
|
|
4586
|
+
},
|
|
4587
|
+
},
|
|
4588
|
+
};
|
|
4589
|
+
} else {
|
|
4590
|
+
switch ( inputData.moduleType ) {
|
|
4591
|
+
case 'unattended-customer':
|
|
4592
|
+
logsQuery = {
|
|
4593
|
+
'size': 100,
|
|
4594
|
+
'query': {
|
|
4595
|
+
'bool': {
|
|
4596
|
+
'must': [
|
|
4597
|
+
{
|
|
4598
|
+
'term': {
|
|
4599
|
+
'data.fileDate.keyword': inputData.fileDate,
|
|
4600
|
+
},
|
|
4601
|
+
},
|
|
4602
|
+
{
|
|
4603
|
+
'term': {
|
|
4604
|
+
'data.storeId.keyword': inputData.storeId,
|
|
4605
|
+
},
|
|
4606
|
+
},
|
|
4607
|
+
{
|
|
4608
|
+
'term': {
|
|
4609
|
+
'data.moduleType.keyword': inputData.moduleType,
|
|
4610
|
+
},
|
|
4611
|
+
},
|
|
4612
|
+
{
|
|
4613
|
+
'term': {
|
|
4614
|
+
'data.tempId.keyword': inputData.tempId,
|
|
4615
|
+
},
|
|
4616
|
+
},
|
|
4617
|
+
{
|
|
4618
|
+
'terms': {
|
|
4619
|
+
'logSubType.keyword': [ 'auditDone', 'reTrigger' ],
|
|
4620
|
+
},
|
|
4621
|
+
},
|
|
4622
|
+
],
|
|
4549
4623
|
},
|
|
4550
4624
|
},
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4625
|
+
};
|
|
4626
|
+
break;
|
|
4627
|
+
case 'left-in-middle':
|
|
4628
|
+
logsQuery = {
|
|
4629
|
+
'size': 100,
|
|
4630
|
+
'query': {
|
|
4631
|
+
'bool': {
|
|
4632
|
+
'must': [
|
|
4633
|
+
{
|
|
4634
|
+
'term': {
|
|
4635
|
+
'data.fileDate.keyword': inputData.fileDate,
|
|
4636
|
+
},
|
|
4637
|
+
},
|
|
4638
|
+
{
|
|
4639
|
+
'term': {
|
|
4640
|
+
'data.storeId.keyword': inputData.storeId,
|
|
4641
|
+
},
|
|
4642
|
+
},
|
|
4643
|
+
{
|
|
4644
|
+
'term': {
|
|
4645
|
+
'data.moduleType.keyword': inputData.moduleType,
|
|
4646
|
+
},
|
|
4647
|
+
},
|
|
4648
|
+
{
|
|
4649
|
+
'term': {
|
|
4650
|
+
'data.question.keyword': inputData.question,
|
|
4651
|
+
},
|
|
4652
|
+
},
|
|
4653
|
+
{
|
|
4654
|
+
'terms': {
|
|
4655
|
+
'logSubType.keyword': [ 'auditDone', 'reTrigger' ],
|
|
4656
|
+
},
|
|
4657
|
+
},
|
|
4658
|
+
],
|
|
4554
4659
|
},
|
|
4555
4660
|
},
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4661
|
+
};
|
|
4662
|
+
break;
|
|
4663
|
+
case 'uniform-detection':
|
|
4664
|
+
case 'mobile-detection': // Handle both in the same block
|
|
4665
|
+
logsQuery = {
|
|
4666
|
+
'size': 100,
|
|
4667
|
+
'query': {
|
|
4668
|
+
'bool': {
|
|
4669
|
+
'must': [
|
|
4670
|
+
{
|
|
4671
|
+
'term': {
|
|
4672
|
+
'logData.fileDate.keyword': inputData.fileDate,
|
|
4673
|
+
},
|
|
4674
|
+
},
|
|
4675
|
+
{
|
|
4676
|
+
'term': {
|
|
4677
|
+
'logData.storeId.keyword': inputData.storeId,
|
|
4678
|
+
},
|
|
4679
|
+
},
|
|
4680
|
+
{
|
|
4681
|
+
'term': {
|
|
4682
|
+
'logData.moduleType.keyword': inputData.moduleType,
|
|
4683
|
+
},
|
|
4684
|
+
},
|
|
4685
|
+
{
|
|
4686
|
+
'terms': {
|
|
4687
|
+
'logSubType.keyword': [ 'auditDone', 'reTrigger' ],
|
|
4688
|
+
},
|
|
4689
|
+
},
|
|
4690
|
+
],
|
|
4559
4691
|
},
|
|
4560
4692
|
},
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4693
|
+
};
|
|
4694
|
+
break;
|
|
4695
|
+
case 'camera-angle-change':
|
|
4696
|
+
logsQuery = {
|
|
4697
|
+
'size': 100,
|
|
4698
|
+
'query': {
|
|
4699
|
+
'bool': {
|
|
4700
|
+
'must': [
|
|
4701
|
+
{
|
|
4702
|
+
'term': {
|
|
4703
|
+
'data.fileDate.keyword': inputData.fileDate,
|
|
4704
|
+
},
|
|
4705
|
+
},
|
|
4706
|
+
{
|
|
4707
|
+
'term': {
|
|
4708
|
+
'data.storeId.keyword': inputData.storeId,
|
|
4709
|
+
},
|
|
4710
|
+
},
|
|
4711
|
+
{
|
|
4712
|
+
'term': {
|
|
4713
|
+
'data.moduleType.keyword': inputData.moduleType,
|
|
4714
|
+
},
|
|
4715
|
+
},
|
|
4716
|
+
{
|
|
4717
|
+
'term': {
|
|
4718
|
+
'data.streamName.keyword': inputData.streamName,
|
|
4719
|
+
},
|
|
4720
|
+
},
|
|
4721
|
+
{
|
|
4722
|
+
'terms': {
|
|
4723
|
+
'logSubType.keyword': [ 'auditDone', 'reTrigger' ],
|
|
4724
|
+
},
|
|
4725
|
+
},
|
|
4726
|
+
],
|
|
4564
4727
|
},
|
|
4565
4728
|
},
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4729
|
+
};
|
|
4730
|
+
break;
|
|
4731
|
+
default:
|
|
4732
|
+
return res.sendError( 'Please give valid modueType', 400 );
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4570
4735
|
const logs = await getOpenSearchData( parsedOpenSearch.auditLog, logsQuery );
|
|
4571
4736
|
logger.info( { logs: logs.body.hits, inputData: inputData, auditLog: parsedOpenSearch.auditLog } );
|
|
4572
4737
|
if ( logs.body.hits.hits.length > 0 ) {
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4738
|
+
const sourcesArray = logs.body.hits.hits.map( ( hit ) => hit._source );
|
|
4739
|
+
for ( const i of sourcesArray ) { // Loop through sourcesArray, not result._doc.camera
|
|
4740
|
+
if ( i.logSubType == 'auditDone' ) {
|
|
4741
|
+
const convertedTime = await convertTimestampToDateTime( i.logData.endTime );
|
|
4742
|
+
logData.push( {
|
|
4743
|
+
...i, // Spread the individual log object
|
|
4744
|
+
time: convertedTime, // Add the converted time
|
|
4745
|
+
} );
|
|
4746
|
+
} else {
|
|
4747
|
+
const convertedTime = await convertTimestampToDateTime( i.createdAt );
|
|
4748
|
+
logData.push( {
|
|
4749
|
+
...i, // Spread the individual log object
|
|
4750
|
+
time: convertedTime, // Add the converted time
|
|
4751
|
+
} );
|
|
4752
|
+
}
|
|
4585
4753
|
}
|
|
4586
4754
|
return res.sendSuccess( logData );
|
|
4587
4755
|
} else {
|
|
@@ -1192,7 +1192,7 @@ export async function getAuditFile( req, res ) {
|
|
|
1192
1192
|
const logData = {
|
|
1193
1193
|
userId: insertData.userId,
|
|
1194
1194
|
userName: userdata.name,
|
|
1195
|
-
logType: '
|
|
1195
|
+
logType: 'traxAudit',
|
|
1196
1196
|
logSubType: 'auditStart',
|
|
1197
1197
|
data: {
|
|
1198
1198
|
fileDate: msg.fileDate,
|
|
@@ -1360,7 +1360,7 @@ export async function getUpdatedFile( req, res ) {
|
|
|
1360
1360
|
const logData = {
|
|
1361
1361
|
userId: req.user._id,
|
|
1362
1362
|
userName: userdata.name,
|
|
1363
|
-
logType: '
|
|
1363
|
+
logType: 'traxAudit',
|
|
1364
1364
|
logSubType: 'auditStart',
|
|
1365
1365
|
data: {
|
|
1366
1366
|
fileDate: msg.fileDate,
|
|
@@ -2600,10 +2600,9 @@ export async function storeMetrics( req, res ) {
|
|
|
2600
2600
|
result.forEach( ( element ) => {
|
|
2601
2601
|
const temp ={
|
|
2602
2602
|
'File Date': element.fileDate,
|
|
2603
|
-
'Store ID': element.storeId,
|
|
2604
2603
|
'Store Name': element.storeName,
|
|
2605
|
-
'
|
|
2606
|
-
'
|
|
2604
|
+
'Store ID': element.storeId,
|
|
2605
|
+
'Product Type': element.value,
|
|
2607
2606
|
'User Name': element.userName,
|
|
2608
2607
|
'User Email': element.userEmail,
|
|
2609
2608
|
'Audit Type': element.auditType,
|
|
@@ -2613,16 +2612,19 @@ export async function storeMetrics( req, res ) {
|
|
|
2613
2612
|
case 'camera-angle-change':
|
|
2614
2613
|
temp['stream Name'] = element.streamName;
|
|
2615
2614
|
temp['User Comments'] = element.userComments;
|
|
2615
|
+
temp['Result'] = element.answer;
|
|
2616
2616
|
break;
|
|
2617
2617
|
case 'unattended-customer':
|
|
2618
2618
|
temp['Customer ID'] = element.tempId;
|
|
2619
2619
|
temp['Question'] = element.question;
|
|
2620
2620
|
temp['User Comments'] = element.userComments;
|
|
2621
|
+
temp['Result'] = element.answer;
|
|
2621
2622
|
break;
|
|
2622
2623
|
case 'left-in-middle':
|
|
2623
2624
|
temp['Question'] = element.question;
|
|
2624
2625
|
temp['User Comments'] = element.userComments;
|
|
2625
2626
|
temp['Status'] = toCamelCase( element.auditStatus );
|
|
2627
|
+
temp['Result'] = element.answer;
|
|
2626
2628
|
break;
|
|
2627
2629
|
case 'mobile-detection':
|
|
2628
2630
|
temp['Before Count'] = element.beforeCount;
|