tango-app-api-audit 3.3.0-alpha.9 → 3.3.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-audit",
|
|
3
|
-
"version": "3.3.0-
|
|
3
|
+
"version": "3.3.0-beta.0",
|
|
4
4
|
"description": "audit & audit metrics apis",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "app.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"start": "nodemon --exec \"eslint --fix . && node
|
|
8
|
+
"start": "nodemon --exec \"eslint --fix . && node app.js\""
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=18.10.0"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"mongodb": "^6.7.0",
|
|
25
25
|
"nodemon": "^3.1.3",
|
|
26
26
|
"swagger-ui-express": "^5.0.1",
|
|
27
|
-
"tango-api-schema": "^2.0.
|
|
27
|
+
"tango-api-schema": "^2.0.157",
|
|
28
28
|
"tango-app-api-middleware": "^3.3.0-alpha.0",
|
|
29
29
|
"winston": "^3.13.0",
|
|
30
30
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -738,21 +738,24 @@ export const mapFunction = async ( chunk, filter ) => {
|
|
|
738
738
|
|
|
739
739
|
export async function workSpace( req, res ) {
|
|
740
740
|
try {
|
|
741
|
-
const inputData = req.
|
|
741
|
+
const inputData = req.body;
|
|
742
742
|
const limit = inputData.limit || 10;
|
|
743
743
|
const offset = inputData.offset ?
|
|
744
744
|
( inputData.offset - 1 ) * limit :
|
|
745
745
|
0;
|
|
746
746
|
const dateRange = await getUTC( new Date(), new Date() );
|
|
747
|
-
|
|
747
|
+
const filter =[
|
|
748
|
+
{ status: { $in: [ 'active', 'hold' ] } },
|
|
749
|
+
{ 'auditConfigs.audit': { $eq: true } },
|
|
750
|
+
];
|
|
751
|
+
if ( inputData?.clientId?.length > 0 ) {
|
|
752
|
+
filter.push( { clientId: { $in: inputData.clientId } } );
|
|
753
|
+
}
|
|
748
754
|
const temp = [];
|
|
749
755
|
const clientQuery = [
|
|
750
756
|
{
|
|
751
757
|
$match: {
|
|
752
|
-
$and:
|
|
753
|
-
{ status: { $in: [ 'active', 'hold' ] } },
|
|
754
|
-
{ 'auditConfigs.audit': { $eq: true } },
|
|
755
|
-
],
|
|
758
|
+
$and: filter,
|
|
756
759
|
},
|
|
757
760
|
},
|
|
758
761
|
{
|
|
@@ -776,9 +779,9 @@ export async function workSpace( req, res ) {
|
|
|
776
779
|
}
|
|
777
780
|
if ( inputData.sortColumnName ) {
|
|
778
781
|
const sortBy = inputData.sortBy || -1;
|
|
779
|
-
|
|
782
|
+
const sortColumn = inputData.sortColumnName;
|
|
780
783
|
clientQuery.push( {
|
|
781
|
-
$sort: { [
|
|
784
|
+
$sort: { [sortColumn]: sortBy },
|
|
782
785
|
},
|
|
783
786
|
);
|
|
784
787
|
}
|
|
@@ -1201,8 +1204,8 @@ export async function getDraftedData( req, res ) {
|
|
|
1201
1204
|
};
|
|
1202
1205
|
const result = await findOneAuditLog( query, {}, { createdAt: -1 }, 1 );
|
|
1203
1206
|
|
|
1204
|
-
if ( result
|
|
1205
|
-
return res.sendError( 'No Data Found',
|
|
1207
|
+
if ( !result ) {
|
|
1208
|
+
return res.sendError( 'No Data Found', 204 );
|
|
1206
1209
|
}
|
|
1207
1210
|
return res.sendSuccess( { result: result } );
|
|
1208
1211
|
} catch ( error ) {
|
|
@@ -1475,7 +1478,9 @@ export async function userAuditHistory( req, res ) {
|
|
|
1475
1478
|
auditStatus: { $in: inputData.filterByStatus },
|
|
1476
1479
|
} );
|
|
1477
1480
|
}
|
|
1478
|
-
|
|
1481
|
+
if ( inputData?.clientId?.length > 0 ) {
|
|
1482
|
+
filter.push( { clientId: { $in: inputData.clientId } } );
|
|
1483
|
+
}
|
|
1479
1484
|
const query = [
|
|
1480
1485
|
{
|
|
1481
1486
|
$match: {
|
|
@@ -1620,9 +1625,10 @@ export async function userAuditHistory( req, res ) {
|
|
|
1620
1625
|
}
|
|
1621
1626
|
|
|
1622
1627
|
if ( inputData.sortColumnName ) {
|
|
1623
|
-
const sortBy =inputData.sortBy || -1;
|
|
1628
|
+
const sortBy = inputData.sortBy || -1;
|
|
1629
|
+
const sortColumn = inputData.sortColumnName;
|
|
1624
1630
|
query.push( {
|
|
1625
|
-
$sort: { [
|
|
1631
|
+
$sort: { [sortColumn]: sortBy },
|
|
1626
1632
|
},
|
|
1627
1633
|
);
|
|
1628
1634
|
}
|
|
@@ -1638,18 +1644,18 @@ export async function userAuditHistory( req, res ) {
|
|
|
1638
1644
|
chunk.forEach( ( element ) => {
|
|
1639
1645
|
exportData.push( {
|
|
1640
1646
|
|
|
1641
|
-
'
|
|
1642
|
-
'
|
|
1643
|
-
'Store
|
|
1647
|
+
'Brand ID': element.clientId,
|
|
1648
|
+
'Brand Name': element.clientName,
|
|
1649
|
+
'Store ID': element.storeId,
|
|
1644
1650
|
'Store Name': element.storeName,
|
|
1645
1651
|
'Zone Name': element.zoneName,
|
|
1646
1652
|
'Audit Type': element.auditType,
|
|
1647
1653
|
'Module Type': element.moduleType,
|
|
1648
1654
|
'Before Count': element.beforeCount,
|
|
1649
|
-
'After Count': element.afterCount,
|
|
1650
|
-
'Accuracy': element.accuracy,
|
|
1655
|
+
'After Count': element.afterCount || '',
|
|
1656
|
+
'Accuracy': element.accuracy || '',
|
|
1651
1657
|
'Start Time': element.startTime,
|
|
1652
|
-
'End Time': element.endTime,
|
|
1658
|
+
'End Time': element.endTime || '',
|
|
1653
1659
|
'Time Spent': element.timeSpent,
|
|
1654
1660
|
'Audit Status': element.auditStatus,
|
|
1655
1661
|
'CreatedAt': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
|
|
@@ -1660,8 +1666,8 @@ export async function userAuditHistory( req, res ) {
|
|
|
1660
1666
|
} );
|
|
1661
1667
|
const mappedArrays = await Promise.all( promises );
|
|
1662
1668
|
mappedArrays.flat();
|
|
1663
|
-
|
|
1664
|
-
await download( mappedArrays, res );
|
|
1669
|
+
logger.info( { mappedArrays: mappedArrays[0] } );
|
|
1670
|
+
await download( mappedArrays[0], res );
|
|
1665
1671
|
return;
|
|
1666
1672
|
}
|
|
1667
1673
|
|
|
@@ -1851,8 +1857,9 @@ export async function clientMetrics( req, res ) {
|
|
|
1851
1857
|
}
|
|
1852
1858
|
if ( inputData.sortColumnName ) {
|
|
1853
1859
|
const sortBy = inputData.sortBy || -1;
|
|
1860
|
+
const sortColumn = inputData.sortColumnName;
|
|
1854
1861
|
query.push( {
|
|
1855
|
-
$sort: { [
|
|
1862
|
+
$sort: { [sortColumn]: sortBy },
|
|
1856
1863
|
},
|
|
1857
1864
|
);
|
|
1858
1865
|
}
|
|
@@ -1976,7 +1983,7 @@ export async function storeMetrics( req, res ) {
|
|
|
1976
1983
|
_id: 0,
|
|
1977
1984
|
fileDate: 1,
|
|
1978
1985
|
storeId: 1,
|
|
1979
|
-
storeName: '$
|
|
1986
|
+
storeName: '$stores.storeName',
|
|
1980
1987
|
clientName: '',
|
|
1981
1988
|
clientId: 1,
|
|
1982
1989
|
zoneName: 1,
|
|
@@ -2058,7 +2065,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2058
2065
|
_id: 0,
|
|
2059
2066
|
fileDate: 1,
|
|
2060
2067
|
storeId: 1,
|
|
2061
|
-
storeName:
|
|
2068
|
+
storeName: 1,
|
|
2062
2069
|
userName: '$users.userName',
|
|
2063
2070
|
userEmail: '$users.userEmail',
|
|
2064
2071
|
clientId: 1,
|
|
@@ -2125,8 +2132,9 @@ export async function storeMetrics( req, res ) {
|
|
|
2125
2132
|
|
|
2126
2133
|
if ( inputData.sortColumnName ) {
|
|
2127
2134
|
const sortBy = inputData.sortBy || -1;
|
|
2135
|
+
const sortColumn = inputData.sortColumnName;
|
|
2128
2136
|
query.push( {
|
|
2129
|
-
$sort: { [
|
|
2137
|
+
$sort: { [sortColumn]: sortBy },
|
|
2130
2138
|
},
|
|
2131
2139
|
);
|
|
2132
2140
|
}
|
|
@@ -2151,7 +2159,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2151
2159
|
result.forEach( ( element ) => {
|
|
2152
2160
|
exportdata.push( {
|
|
2153
2161
|
'File Date': element.fileDate,
|
|
2154
|
-
'Store
|
|
2162
|
+
'Store ID': element.storeId,
|
|
2155
2163
|
'Store Name': element.storeName,
|
|
2156
2164
|
'Client Id': element.clientId,
|
|
2157
2165
|
'Client Name': element.clientName,
|
|
@@ -2287,6 +2295,7 @@ export async function userMetrics( req, res ) {
|
|
|
2287
2295
|
afterCount: 1,
|
|
2288
2296
|
checkIntime: 1,
|
|
2289
2297
|
checkOutTime: 1,
|
|
2298
|
+
mappingPerc: 1,
|
|
2290
2299
|
hours: {
|
|
2291
2300
|
$cond: {
|
|
2292
2301
|
if: { $lt: [ '$hours', 10 ] },
|
|
@@ -2322,6 +2331,7 @@ export async function userMetrics( req, res ) {
|
|
|
2322
2331
|
checkIntime: 1,
|
|
2323
2332
|
zoneName: 1,
|
|
2324
2333
|
checkOutTime: 1,
|
|
2334
|
+
mappingPerc: 1,
|
|
2325
2335
|
workingHours: {
|
|
2326
2336
|
$concat: [ '$hours', ':', '$minutes', ':', '$seconds' ],
|
|
2327
2337
|
},
|
|
@@ -2362,6 +2372,7 @@ export async function userMetrics( req, res ) {
|
|
|
2362
2372
|
totalCompletedFiles: 1,
|
|
2363
2373
|
beforeCount: 1,
|
|
2364
2374
|
afterCount: 1,
|
|
2375
|
+
mappingPerc: 1,
|
|
2365
2376
|
checkIntime: {
|
|
2366
2377
|
$dateToString: {
|
|
2367
2378
|
format: '%Y-%m-%d %H:%M:%S',
|
|
@@ -2393,8 +2404,9 @@ export async function userMetrics( req, res ) {
|
|
|
2393
2404
|
}
|
|
2394
2405
|
if ( inputData.sortColumnName ) {
|
|
2395
2406
|
const sortBy = inputData.sortBy || -1;
|
|
2407
|
+
const sortColumn = inputData.sortColumnName;
|
|
2396
2408
|
query.push( {
|
|
2397
|
-
$sort: { [
|
|
2409
|
+
$sort: { [sortColumn]: sortBy },
|
|
2398
2410
|
},
|
|
2399
2411
|
);
|
|
2400
2412
|
}
|
|
@@ -2415,13 +2427,13 @@ export async function userMetrics( req, res ) {
|
|
|
2415
2427
|
'_id': 0,
|
|
2416
2428
|
'File Date': '$fileDate',
|
|
2417
2429
|
'User Name': '$userName',
|
|
2418
|
-
'User Id': '$userId',
|
|
2419
2430
|
'Total Completed Files Count': '$totalCompletedFiles',
|
|
2420
|
-
'Total
|
|
2431
|
+
'Total Before Count': '$beforeCount',
|
|
2421
2432
|
'Total After Count': '$afterCount',
|
|
2422
2433
|
'check Intime': '$checkIntime',
|
|
2423
2434
|
'check OutTime': '$checkOutTime',
|
|
2424
2435
|
'working Hours': '$workingHours',
|
|
2436
|
+
'Mapping Percentage': '$mappingPerc',
|
|
2425
2437
|
},
|
|
2426
2438
|
},
|
|
2427
2439
|
);
|
|
@@ -2436,12 +2448,12 @@ export async function userMetrics( req, res ) {
|
|
|
2436
2448
|
return res.sendSuccess( { result: result, count: count.length } );
|
|
2437
2449
|
} catch ( error ) {
|
|
2438
2450
|
const err = error.error || 'Internal Server Error';
|
|
2439
|
-
logger.info( { error: error, message: req.body, function: '
|
|
2451
|
+
logger.info( { error: error, message: req.body, function: 'userMetrics' } );
|
|
2440
2452
|
return res.sendError( err, 500 );
|
|
2441
2453
|
}
|
|
2442
2454
|
}
|
|
2443
2455
|
|
|
2444
|
-
export async function
|
|
2456
|
+
export async function pendingSummaryTable( req, res ) {
|
|
2445
2457
|
try {
|
|
2446
2458
|
const inputData = req.body;
|
|
2447
2459
|
const limit = inputData.limit || 10;
|
|
@@ -2450,7 +2462,7 @@ export async function overViewTable( req, res ) {
|
|
|
2450
2462
|
let filters =[
|
|
2451
2463
|
{ fileDateISO: { $gte: dateRange.start } },
|
|
2452
2464
|
{ fileDateISO: { $lte: dateRange.end } },
|
|
2453
|
-
{ auditStatus: { $
|
|
2465
|
+
{ auditStatus: { $ne: 'completed' } },
|
|
2454
2466
|
|
|
2455
2467
|
];
|
|
2456
2468
|
|
|
@@ -2465,6 +2477,10 @@ export async function overViewTable( req, res ) {
|
|
|
2465
2477
|
if ( inputData.filterByAuditType.length > 0 ) {
|
|
2466
2478
|
filters.push( { auditType: { $in: inputData.filterByAuditType } } );
|
|
2467
2479
|
}
|
|
2480
|
+
|
|
2481
|
+
if ( inputData.filterByStatus.length > 0 ) {
|
|
2482
|
+
filters.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
2483
|
+
}
|
|
2468
2484
|
const query =[
|
|
2469
2485
|
{
|
|
2470
2486
|
$match: {
|
|
@@ -2480,7 +2496,13 @@ export async function overViewTable( req, res ) {
|
|
|
2480
2496
|
fileDate: 1,
|
|
2481
2497
|
moduleType: 1,
|
|
2482
2498
|
beforeCount: 1,
|
|
2483
|
-
startTime:
|
|
2499
|
+
startTime: { $dateToString: {
|
|
2500
|
+
format: '%Y-%m-%d %H:%M:%S',
|
|
2501
|
+
date: '$startTime',
|
|
2502
|
+
timezone: 'Asia/Kolkata',
|
|
2503
|
+
},
|
|
2504
|
+
|
|
2505
|
+
},
|
|
2484
2506
|
auditType: 1,
|
|
2485
2507
|
auditStatus: 1,
|
|
2486
2508
|
userId: 1,
|
|
@@ -2521,6 +2543,7 @@ export async function overViewTable( req, res ) {
|
|
|
2521
2543
|
moduleType: 1,
|
|
2522
2544
|
beforeCount: 1,
|
|
2523
2545
|
startTime: 1,
|
|
2546
|
+
endTime: 1,
|
|
2524
2547
|
auditType: 1,
|
|
2525
2548
|
auditStatus: 1,
|
|
2526
2549
|
userName: '$user.userName',
|
|
@@ -2546,8 +2569,9 @@ export async function overViewTable( req, res ) {
|
|
|
2546
2569
|
}
|
|
2547
2570
|
if ( inputData.sortColumnName ) {
|
|
2548
2571
|
const sortBy = inputData.sortBy || -1;
|
|
2572
|
+
const sortColumn = inputData.sortColumnName;
|
|
2549
2573
|
query.push( {
|
|
2550
|
-
$sort: { [
|
|
2574
|
+
$sort: { [sortColumn]: sortBy },
|
|
2551
2575
|
},
|
|
2552
2576
|
);
|
|
2553
2577
|
}
|
|
@@ -2572,7 +2596,7 @@ export async function overViewTable( req, res ) {
|
|
|
2572
2596
|
const exportdata = [];
|
|
2573
2597
|
result.forEach( ( element ) => {
|
|
2574
2598
|
exportdata.push( {
|
|
2575
|
-
'Store
|
|
2599
|
+
'Store ID': element.storeId,
|
|
2576
2600
|
'zoneName': element.zoneName,
|
|
2577
2601
|
'File Date': element.fileDate,
|
|
2578
2602
|
'Module Type': element.moduleType,
|
|
@@ -2590,7 +2614,7 @@ export async function overViewTable( req, res ) {
|
|
|
2590
2614
|
return res.sendSuccess( { result: result, count: count.length } );
|
|
2591
2615
|
} catch ( error ) {
|
|
2592
2616
|
const err = error.message || 'Internal Server Error';
|
|
2593
|
-
logger.error( { error: error, message: req.body, function: '
|
|
2617
|
+
logger.error( { error: error, message: req.body, function: 'pendingSummaryTable' } );
|
|
2594
2618
|
return res.sendError( err, 500 );
|
|
2595
2619
|
}
|
|
2596
2620
|
}
|
|
@@ -2661,8 +2685,8 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
2661
2685
|
auditInprogress: { $cond: [ { $and: [ { $in: [ '$status', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
|
|
2662
2686
|
reAuditInprogress: { $cond: [ { $and: [ { $in: [ '$status', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
|
|
2663
2687
|
draft: { $cond: [ { $eq: [ '$status', 'drafted' ] }, 1, 0 ] },
|
|
2664
|
-
assigned: { $cond: [ { $eq: [ '$status', '
|
|
2665
|
-
exceptNoAssigned: { $cond:
|
|
2688
|
+
assigned: { $cond: [ { $eq: [ '$status', 'assigned' ] }, 1, 0 ] },
|
|
2689
|
+
exceptNoAssigned: { $cond: { if: { $not: { $in: [ '$status', [ 'skipped', 'not_assign' ] ] } }, then: 1, else: 0 } },
|
|
2666
2690
|
auditCompleted: { $cond: [ { $and: [ { $in: [ '$status', [ 'completed' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
|
|
2667
2691
|
reAuditCompleted: { $cond: [ { $and: [ { $in: [ '$status', [ 'completed' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
|
|
2668
2692
|
|
|
@@ -2690,7 +2714,6 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
2690
2714
|
reAuditInprogress: 1,
|
|
2691
2715
|
draft: 1,
|
|
2692
2716
|
assigned: 1,
|
|
2693
|
-
exceptNoAssigned1: 1,
|
|
2694
2717
|
exceptNoAssigned: { $subtract: [ temp.auditStores, '$exceptNoAssigned' ] },
|
|
2695
2718
|
auditCompleted: 1,
|
|
2696
2719
|
reAuditCompleted: 1,
|
|
@@ -2713,7 +2736,7 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
2713
2736
|
return res.sendSuccess( { result: temp } );
|
|
2714
2737
|
} catch ( error ) {
|
|
2715
2738
|
const err = error.message || 'Internal Server Error';
|
|
2716
|
-
logger.error( { error: error, message: req.body, function: '
|
|
2739
|
+
logger.error( { error: error, message: req.body, function: 'overAllAuditSummary' } );
|
|
2717
2740
|
return res.sendError( err, 500 );
|
|
2718
2741
|
}
|
|
2719
2742
|
}
|
|
@@ -2861,7 +2884,7 @@ export async function reTrigger( req, res ) {
|
|
|
2861
2884
|
return res.sendSuccess( { result: 'The File has been Re Trigger Succesfully' } );
|
|
2862
2885
|
} catch ( error ) {
|
|
2863
2886
|
const err = error.message;
|
|
2864
|
-
logger.error( { error: error, message: req.body } );
|
|
2887
|
+
logger.error( { error: error, message: req.body, function: 'reTrigger' } );
|
|
2865
2888
|
return res.sendError( err, 500 );
|
|
2866
2889
|
}
|
|
2867
2890
|
}
|
|
@@ -2995,12 +3018,12 @@ export async function summarySplit( req, res ) {
|
|
|
2995
3018
|
},
|
|
2996
3019
|
draft: {
|
|
2997
3020
|
$cond: [
|
|
2998
|
-
{ $
|
|
3021
|
+
{ $eq: [ '$status', 'drafted' ] }, 1, 0,
|
|
2999
3022
|
],
|
|
3000
3023
|
},
|
|
3001
3024
|
assigned: {
|
|
3002
3025
|
$cond: [
|
|
3003
|
-
{ $
|
|
3026
|
+
{ $eq: [ '$status', 'assigned' ] }, 1, 0,
|
|
3004
3027
|
],
|
|
3005
3028
|
},
|
|
3006
3029
|
|
|
@@ -3018,11 +3041,11 @@ export async function summarySplit( req, res ) {
|
|
|
3018
3041
|
},
|
|
3019
3042
|
{
|
|
3020
3043
|
$group: {
|
|
3021
|
-
_id:
|
|
3044
|
+
_id: null,
|
|
3022
3045
|
auditInprogress: { $sum: '$auditInprogress' },
|
|
3023
3046
|
reAuditInprogress: { $sum: '$reAuditInprogress' },
|
|
3024
3047
|
draft: { $sum: '$draft' },
|
|
3025
|
-
assigned: { $sum: 'assigned' },
|
|
3048
|
+
assigned: { $sum: '$assigned' },
|
|
3026
3049
|
reAuditCompleted: { $sum: '$reAuditCompleted' },
|
|
3027
3050
|
auditCompleted: { $sum: '$auditCompleted' },
|
|
3028
3051
|
|
|
@@ -3065,8 +3088,7 @@ export async function summarySplit( req, res ) {
|
|
|
3065
3088
|
];
|
|
3066
3089
|
const result = await aggregateStoreAudit( query );
|
|
3067
3090
|
const totalCount = await aggregateAuditStoreData( totalQuery );
|
|
3068
|
-
result[0].totalCount = totalCount[0]?.total
|
|
3069
|
-
logger.info( { result: result } );
|
|
3091
|
+
result[0].totalCount = totalCount[0]?.total;
|
|
3070
3092
|
return res.sendSuccess( { result: result.length> 0? result[0]: temp } );
|
|
3071
3093
|
} catch ( error ) {
|
|
3072
3094
|
const err = error.message || 'Internal Server Error';
|
|
@@ -3075,6 +3097,282 @@ export async function summarySplit( req, res ) {
|
|
|
3075
3097
|
}
|
|
3076
3098
|
}
|
|
3077
3099
|
|
|
3100
|
+
export async function overviewTable( req, res ) {
|
|
3101
|
+
try {
|
|
3102
|
+
const inputData = req.body;
|
|
3103
|
+
const limit = inputData.limit || 10;
|
|
3104
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
3105
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
3106
|
+
let filters =[
|
|
3107
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
3108
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
3109
|
+
|
|
3110
|
+
];
|
|
3111
|
+
|
|
3112
|
+
if ( inputData.clientId.length > 0 ) {
|
|
3113
|
+
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
if ( inputData.filterByModuleType.length > 0 ) {
|
|
3117
|
+
filters.push( { moduleType: { $in: inputData.filterByModuleType } } );
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
if ( inputData.filterByAuditType.length > 0 ) {
|
|
3121
|
+
filters.push( { auditType: { $in: inputData.filterByAuditType } } );
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3124
|
+
if ( inputData.filterByStatus.length > 0 ) {
|
|
3125
|
+
filters.push( { status: { $in: inputData.filterByStatus } } );
|
|
3126
|
+
}
|
|
3127
|
+
|
|
3128
|
+
const query =[
|
|
3129
|
+
{
|
|
3130
|
+
$match: {
|
|
3131
|
+
$and: filters,
|
|
3132
|
+
},
|
|
3133
|
+
|
|
3134
|
+
},
|
|
3135
|
+
{
|
|
3136
|
+
$project: {
|
|
3137
|
+
_id: 0,
|
|
3138
|
+
storeId: 1,
|
|
3139
|
+
clientId: 1,
|
|
3140
|
+
zoneName: 1,
|
|
3141
|
+
fileDate: 1,
|
|
3142
|
+
moduleType: 1,
|
|
3143
|
+
beforeCount: 1,
|
|
3144
|
+
afterCount: 1,
|
|
3145
|
+
auditType: 1,
|
|
3146
|
+
status: 1,
|
|
3147
|
+
// userId: 1,
|
|
3148
|
+
},
|
|
3149
|
+
},
|
|
3150
|
+
// {
|
|
3151
|
+
// $lookup: {
|
|
3152
|
+
// from: 'users',
|
|
3153
|
+
// let: { userId: '$userId' },
|
|
3154
|
+
// pipeline: [
|
|
3155
|
+
// {
|
|
3156
|
+
// $match: {
|
|
3157
|
+
// $expr: {
|
|
3158
|
+
// $eq: [ '$_id', '$$userId' ],
|
|
3159
|
+
// },
|
|
3160
|
+
// },
|
|
3161
|
+
// },
|
|
3162
|
+
// {
|
|
3163
|
+
// $project: {
|
|
3164
|
+
// userName: 1,
|
|
3165
|
+
// userEmail: '$email',
|
|
3166
|
+
// },
|
|
3167
|
+
// },
|
|
3168
|
+
// ], as: 'user',
|
|
3169
|
+
// },
|
|
3170
|
+
// },
|
|
3171
|
+
// {
|
|
3172
|
+
// $unwind: {
|
|
3173
|
+
// path: '$user',
|
|
3174
|
+
// preserveNullAndEmptyArrays: true,
|
|
3175
|
+
// },
|
|
3176
|
+
// },
|
|
3177
|
+
{
|
|
3178
|
+
$project: {
|
|
3179
|
+
storeId: 1,
|
|
3180
|
+
clientId: 1,
|
|
3181
|
+
zoneName: 1,
|
|
3182
|
+
fileDate: 1,
|
|
3183
|
+
moduleType: 1,
|
|
3184
|
+
beforeCount: 1,
|
|
3185
|
+
afterCount: 1,
|
|
3186
|
+
auditType: 1,
|
|
3187
|
+
status: 1,
|
|
3188
|
+
// userName: '$user.userName',
|
|
3189
|
+
// userEmail: '$user.userEmail',
|
|
3190
|
+
|
|
3191
|
+
},
|
|
3192
|
+
},
|
|
3193
|
+
];
|
|
3194
|
+
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
3195
|
+
query.push( {
|
|
3196
|
+
$match: {
|
|
3197
|
+
$or: [
|
|
3198
|
+
{ storeId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3199
|
+
{ clientId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3200
|
+
{ fileDate: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3201
|
+
{ auditType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3202
|
+
{ status: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3203
|
+
{ moduleType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3204
|
+
{ zoneName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3205
|
+
// { userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3206
|
+
// { userEmail: { $regex: inputData.searchValue, $options: 'i' } },
|
|
3207
|
+
],
|
|
3208
|
+
|
|
3209
|
+
},
|
|
3210
|
+
} );
|
|
3211
|
+
}
|
|
3212
|
+
if ( inputData.sortColumnName ) {
|
|
3213
|
+
const sortBy = inputData.sortBy || -1;
|
|
3214
|
+
const sortColumn = inputData.sortColumnName;
|
|
3215
|
+
query.push( {
|
|
3216
|
+
$sort: { [sortColumn]: sortBy },
|
|
3217
|
+
},
|
|
3218
|
+
);
|
|
3219
|
+
}
|
|
3220
|
+
const count = await aggregateStoreAudit( query );
|
|
3221
|
+
if ( count.length == 0 ) {
|
|
3222
|
+
return res.sendError( 'No Data Found', 204 );
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
if ( inputData.isExport ) {
|
|
3226
|
+
query.push( { $limit: 10000 } );
|
|
3227
|
+
} else {
|
|
3228
|
+
query.push( {
|
|
3229
|
+
$skip: offset,
|
|
3230
|
+
},
|
|
3231
|
+
{
|
|
3232
|
+
$limit: limit,
|
|
3233
|
+
} );
|
|
3234
|
+
}
|
|
3235
|
+
|
|
3236
|
+
const result = await aggregateStoreAudit( query );
|
|
3237
|
+
if ( inputData.isExport ) {
|
|
3238
|
+
const exportdata = [];
|
|
3239
|
+
result.forEach( ( element ) => {
|
|
3240
|
+
exportdata.push( {
|
|
3241
|
+
'Store ID': element.storeId,
|
|
3242
|
+
'Client ID': element.clientId,
|
|
3243
|
+
'zoneName': element.zoneName,
|
|
3244
|
+
'File Date': element.fileDate,
|
|
3245
|
+
'Module Type': element.moduleType,
|
|
3246
|
+
'Audit Type': element.auditType,
|
|
3247
|
+
'Before Count': element.beforeCount,
|
|
3248
|
+
'After Count': element.afterCount,
|
|
3249
|
+
// 'User Name': element.userName,
|
|
3250
|
+
// 'User Email': element.userEmail,
|
|
3251
|
+
'Status': element.status,
|
|
3252
|
+
} );
|
|
3253
|
+
} );
|
|
3254
|
+
await download( exportdata, res );
|
|
3255
|
+
return;
|
|
3256
|
+
}
|
|
3257
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
3258
|
+
} catch ( error ) {
|
|
3259
|
+
const err = error.message || 'Internal Server Error';
|
|
3260
|
+
logger.error( { error: error, message: req.body, function: 'overviewTable' } );
|
|
3261
|
+
return res.sendError( err, 500 );
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
|
|
3265
|
+
export async function totalNotAssignedCount( req, res ) {
|
|
3266
|
+
try {
|
|
3267
|
+
let notAssignedCount = {
|
|
3268
|
+
totalAuditCount: 0,
|
|
3269
|
+
totalZoneCount: 0,
|
|
3270
|
+
totalTrafficCount: 0,
|
|
3271
|
+
};
|
|
3272
|
+
const getStoreData = await findOneStoreData(
|
|
3273
|
+
{},
|
|
3274
|
+
{ fileDate: 1 },
|
|
3275
|
+
{ createdAt: -1 },
|
|
3276
|
+
);
|
|
3277
|
+
const latestDate = getStoreData?.fileDate || dayjs( fileDate ).format( 'DD-MM-YYYY' );
|
|
3278
|
+
const query =[
|
|
3279
|
+
{
|
|
3280
|
+
$match: {
|
|
3281
|
+
fileDate: { $eq: latestDate },
|
|
3282
|
+
},
|
|
3283
|
+
},
|
|
3284
|
+
{
|
|
3285
|
+
$project: {
|
|
3286
|
+
totalZoneCount: { $cond: [
|
|
3287
|
+
{ $eq: [ '$moduleType', 'zone' ] }, 1, 0,
|
|
3288
|
+
] },
|
|
3289
|
+
totalTrafficCount: { $cond: [
|
|
3290
|
+
{ $eq: [ '$moduleType', 'traffic' ] }, 1, 0,
|
|
3291
|
+
] },
|
|
3292
|
+
|
|
3293
|
+
},
|
|
3294
|
+
},
|
|
3295
|
+
{
|
|
3296
|
+
$group: {
|
|
3297
|
+
_id: null,
|
|
3298
|
+
totalAuditCount: { $sum: 1 },
|
|
3299
|
+
totalZoneCount: { $sum: '$totalZoneCount' },
|
|
3300
|
+
totalTrafficCount: { $sum: '$totalTrafficCount' },
|
|
3301
|
+
|
|
3302
|
+
},
|
|
3303
|
+
},
|
|
3304
|
+
{
|
|
3305
|
+
$project: {
|
|
3306
|
+
_id: 0,
|
|
3307
|
+
totalAuditCount: 1,
|
|
3308
|
+
totalZoneCount: 1,
|
|
3309
|
+
totalTrafficCount: 1,
|
|
3310
|
+
},
|
|
3311
|
+
},
|
|
3312
|
+
];
|
|
3313
|
+
const inprogressCount=[
|
|
3314
|
+
{
|
|
3315
|
+
$match: {
|
|
3316
|
+
fileDate: { $eq: latestDate },
|
|
3317
|
+
},
|
|
3318
|
+
},
|
|
3319
|
+
{
|
|
3320
|
+
$project: {
|
|
3321
|
+
inprogressAuditCount: {
|
|
3322
|
+
$cond: [
|
|
3323
|
+
{ $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] }, 1, 0,
|
|
3324
|
+
],
|
|
3325
|
+
},
|
|
3326
|
+
inprogressZoneCount: { $cond: [
|
|
3327
|
+
{ $and: [ { $eq: [ '$moduleType', 'zone' ] }, { $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] } ] }, 1, 0,
|
|
3328
|
+
] },
|
|
3329
|
+
inprogressTrafficCount: { $cond: [
|
|
3330
|
+
{ $and: [ { $eq: [ '$moduleType', 'traffic' ] }, { $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] } ] }, 1, 0,
|
|
3331
|
+
] },
|
|
3332
|
+
|
|
3333
|
+
},
|
|
3334
|
+
},
|
|
3335
|
+
{
|
|
3336
|
+
$group: {
|
|
3337
|
+
_id: null,
|
|
3338
|
+
inprogressAuditCount: { $sum: '$inprogressAuditCount' },
|
|
3339
|
+
inprogressZoneCount: { $sum: '$inprogressZoneCount' },
|
|
3340
|
+
inprogressTrafficCount: { $sum: '$inprogressTrafficCount' },
|
|
3341
|
+
|
|
3342
|
+
},
|
|
3343
|
+
},
|
|
3344
|
+
{
|
|
3345
|
+
$project: {
|
|
3346
|
+
_id: 0,
|
|
3347
|
+
inprogressAuditCount: { $ifNull: [ '$inprogressAuditCount', 0 ] },
|
|
3348
|
+
inprogressZoneCount: { $ifNull: [ '$inprogressZoneCount', 0 ] },
|
|
3349
|
+
inprogressTrafficCount: { $ifNull: [ '$inprogressTrafficCount', 0 ] },
|
|
3350
|
+
},
|
|
3351
|
+
},
|
|
3352
|
+
];
|
|
3353
|
+
const getTotalcount = await aggregateAuditStoreData( query );
|
|
3354
|
+
|
|
3355
|
+
const getInprogressCount = await aggregateStoreAudit( inprogressCount );
|
|
3356
|
+
if ( getTotalcount.length == 0 ) {
|
|
3357
|
+
return res.sendError( 'No Data Found', 204 );
|
|
3358
|
+
}
|
|
3359
|
+
|
|
3360
|
+
if ( getInprogressCount.length >0 ) {
|
|
3361
|
+
notAssignedCount.totalAuditCount = getTotalcount[0].totalAuditCount - getInprogressCount[0]?.inprogressAuditCount;
|
|
3362
|
+
notAssignedCount.totalZoneCount = getTotalcount[0].totalZoneCount - getInprogressCount[0]?.inprogressZoneCount;
|
|
3363
|
+
notAssignedCount.totalTrafficCount = getTotalcount[0].totalTrafficCount - getInprogressCount[0]?.inprogressTrafficCount;
|
|
3364
|
+
} else {
|
|
3365
|
+
notAssignedCount.totalAuditCount = getTotalcount[0].totalAuditCount;
|
|
3366
|
+
notAssignedCount.totalZoneCount = getTotalcount[0].totalZoneCount;
|
|
3367
|
+
notAssignedCount.totalTrafficCount;
|
|
3368
|
+
}
|
|
3369
|
+
return res.sendSuccess( { result: notAssignedCount } );
|
|
3370
|
+
} catch ( error ) {
|
|
3371
|
+
const err = error.message || 'Internal Server Error';
|
|
3372
|
+
logger.info( { error: error, message: req.body, function: 'totalNotAssignedCount' } );
|
|
3373
|
+
return res.sendError( err, 500 );
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3078
3376
|
|
|
3079
3377
|
export async function auditImages( req, res ) {
|
|
3080
3378
|
try {
|
|
@@ -3142,7 +3440,7 @@ export async function auditImages( req, res ) {
|
|
|
3142
3440
|
// return res.sendSuccess( { result: inputData } );
|
|
3143
3441
|
} catch ( error ) {
|
|
3144
3442
|
const err = error.message || 'Internal Server Error';
|
|
3145
|
-
logger.info( { error: error, message: req.body, function: '
|
|
3443
|
+
logger.info( { error: error, message: req.body, function: 'auditImages' } );
|
|
3146
3444
|
return res.sendError( err, 500 );
|
|
3147
3445
|
}
|
|
3148
3446
|
}
|
package/src/docs/audit.docs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { auditStoreSchema, clientMetricsSchema, clientSchema, getDraftedDataSchema, getFileSchema, overAllAuditSummarySchema, overViewCardSchema,
|
|
1
|
+
import { auditStoreSchema, clientMetricsSchema, clientSchema, getDraftedDataSchema, getFileSchema, overAllAuditSummarySchema, overViewCardSchema, reTriggerValidSchema, saveDraftSchema, saveSchema, storeMetricsSchema, summarySplitSchema, userAuditHistorySchema, userMetricsSchema, userSchema, workSpaceSchema, auditImageValidSchema, pendingSummaryTableSchema, overviewTableSchema } from '../dtos/audit.dtos.js';
|
|
2
2
|
import j2s from 'joi-to-swagger';
|
|
3
3
|
|
|
4
4
|
export const auditDocs = {
|
|
@@ -170,6 +170,24 @@ export const auditDocs = {
|
|
|
170
170
|
in: 'query',
|
|
171
171
|
name: 'storeId',
|
|
172
172
|
scema: j2s( getDraftedDataSchema ).swagger,
|
|
173
|
+
require: true,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
in: 'query',
|
|
177
|
+
name: 'moduleType',
|
|
178
|
+
scema: j2s( getDraftedDataSchema ).swagger,
|
|
179
|
+
require: true,
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
in: 'query',
|
|
183
|
+
name: 'zoneName',
|
|
184
|
+
scema: j2s( getDraftedDataSchema ).swagger,
|
|
185
|
+
require: true,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
in: 'query',
|
|
189
|
+
name: 'userId',
|
|
190
|
+
scema: j2s( getDraftedDataSchema ).swagger,
|
|
173
191
|
require: false,
|
|
174
192
|
},
|
|
175
193
|
],
|
|
@@ -205,54 +223,17 @@ export const auditDocs = {
|
|
|
205
223
|
},
|
|
206
224
|
},
|
|
207
225
|
'/v3/audit/work-space': {
|
|
208
|
-
|
|
226
|
+
post: {
|
|
209
227
|
tags: [ 'Audit Mapping' ],
|
|
210
228
|
description: 'queue wise info of audit files ',
|
|
211
229
|
operationId: 'work-space',
|
|
212
|
-
|
|
213
|
-
{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
require: true,
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
in: 'query',
|
|
221
|
-
name: 'searchValue',
|
|
222
|
-
scema: j2s( workSpaceSchema ).swagger,
|
|
223
|
-
require: false,
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
in: 'query',
|
|
227
|
-
name: 'offset',
|
|
228
|
-
scema: j2s( workSpaceSchema ).swagger,
|
|
229
|
-
require: false,
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
in: 'query',
|
|
233
|
-
name: 'limit',
|
|
234
|
-
scema: j2s( workSpaceSchema ).swagger,
|
|
235
|
-
require: false,
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
in: 'query',
|
|
239
|
-
name: 'isExport',
|
|
240
|
-
scema: j2s( workSpaceSchema ).swagger,
|
|
241
|
-
require: false,
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
in: 'query',
|
|
245
|
-
name: 'sortColumnName',
|
|
246
|
-
scema: j2s( workSpaceSchema ).swagger,
|
|
247
|
-
require: false,
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
in: 'query',
|
|
251
|
-
name: 'sortBy',
|
|
252
|
-
scema: j2s( workSpaceSchema ).swagger,
|
|
253
|
-
require: false,
|
|
230
|
+
requestBody: {
|
|
231
|
+
content: {
|
|
232
|
+
'application/json': {
|
|
233
|
+
schema: j2s( workSpaceSchema ).swagger,
|
|
234
|
+
},
|
|
254
235
|
},
|
|
255
|
-
|
|
236
|
+
},
|
|
256
237
|
responses: {
|
|
257
238
|
200: { description: 'Successful' },
|
|
258
239
|
401: { description: 'Unauthorized User' },
|
|
@@ -353,6 +334,29 @@ export const auditDocs = {
|
|
|
353
334
|
},
|
|
354
335
|
},
|
|
355
336
|
},
|
|
337
|
+
'/v3/audit/metrics/pending-summary-table': {
|
|
338
|
+
post: {
|
|
339
|
+
tags: [ 'Audit Metrics' ],
|
|
340
|
+
description: `Get overall user taken data with some filters `,
|
|
341
|
+
operationId: 'metrics/pending-summary-table',
|
|
342
|
+
parameters: {},
|
|
343
|
+
requestBody: {
|
|
344
|
+
content: {
|
|
345
|
+
'application/json': {
|
|
346
|
+
schema: j2s( pendingSummaryTableSchema ).swagger,
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
responses: {
|
|
351
|
+
200: { description: 'Successful' },
|
|
352
|
+
401: { description: 'Unauthorized User' },
|
|
353
|
+
422: { description: 'Field Error' },
|
|
354
|
+
500: { description: 'Server Error' },
|
|
355
|
+
204: { description: 'Not Found' },
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
|
|
356
360
|
'/v3/audit/metrics/overview-table': {
|
|
357
361
|
post: {
|
|
358
362
|
tags: [ 'Audit Metrics' ],
|
|
@@ -362,7 +366,7 @@ export const auditDocs = {
|
|
|
362
366
|
requestBody: {
|
|
363
367
|
content: {
|
|
364
368
|
'application/json': {
|
|
365
|
-
schema: j2s(
|
|
369
|
+
schema: j2s( overviewTableSchema ).swagger,
|
|
366
370
|
},
|
|
367
371
|
},
|
|
368
372
|
},
|
|
@@ -520,4 +524,18 @@ export const auditDocs = {
|
|
|
520
524
|
|
|
521
525
|
},
|
|
522
526
|
},
|
|
527
|
+
'/v3/audit/total-not-assigned-count': {
|
|
528
|
+
get: {
|
|
529
|
+
tags: [ 'Audit Mapping' ],
|
|
530
|
+
description: 'Get total Not Assigned Count',
|
|
531
|
+
operationId: 'clients',
|
|
532
|
+
responses: {
|
|
533
|
+
200: { description: 'Successful' },
|
|
534
|
+
401: { description: 'Unauthorized User' },
|
|
535
|
+
422: { description: 'Field Error' },
|
|
536
|
+
500: { description: 'Server Error' },
|
|
537
|
+
204: { description: 'Not Found' },
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
},
|
|
523
541
|
};
|
package/src/dtos/audit.dtos.js
CHANGED
|
@@ -125,6 +125,7 @@ export const workSpaceSchema = joi.object(
|
|
|
125
125
|
{
|
|
126
126
|
searchValue: joi.string().optional().allow( '' ),
|
|
127
127
|
moduleType: joi.string().required(),
|
|
128
|
+
clientId: joi.array().optional(),
|
|
128
129
|
offset: joi.number().optional(),
|
|
129
130
|
limit: joi.number().optional(),
|
|
130
131
|
isExport: joi.boolean().optional(),
|
|
@@ -134,7 +135,7 @@ export const workSpaceSchema = joi.object(
|
|
|
134
135
|
);
|
|
135
136
|
|
|
136
137
|
export const workSpaceValid = {
|
|
137
|
-
|
|
138
|
+
body: workSpaceSchema,
|
|
138
139
|
};
|
|
139
140
|
|
|
140
141
|
/* < -- *** Audit Metrics *** --> */
|
|
@@ -145,6 +146,7 @@ export const userAuditHistorySchema = joi.object(
|
|
|
145
146
|
fromDate: joi.string().required(),
|
|
146
147
|
toDate: joi.string().required(),
|
|
147
148
|
dateType: joi.string().required(),
|
|
149
|
+
clientId: joi.array().optional(),
|
|
148
150
|
filterByStoreId: joi.array().required(),
|
|
149
151
|
filterByModuleType: joi.array().optional(),
|
|
150
152
|
filterByAuditType: joi.array().optional(),
|
|
@@ -227,7 +229,7 @@ export const userMetricsValid = {
|
|
|
227
229
|
body: userMetricsSchema,
|
|
228
230
|
};
|
|
229
231
|
|
|
230
|
-
export const
|
|
232
|
+
export const pendingSummaryTableSchema = joi.object(
|
|
231
233
|
{
|
|
232
234
|
fromDate: joi.string().required(),
|
|
233
235
|
toDate: joi.string().required(),
|
|
@@ -244,8 +246,29 @@ export const overViewTableSchema = joi.object(
|
|
|
244
246
|
},
|
|
245
247
|
);
|
|
246
248
|
|
|
247
|
-
export const
|
|
248
|
-
body:
|
|
249
|
+
export const pendingSummaryTableValid = {
|
|
250
|
+
body: pendingSummaryTableSchema,
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export const overviewTableSchema = joi.object(
|
|
254
|
+
{
|
|
255
|
+
fromDate: joi.string().required(),
|
|
256
|
+
toDate: joi.string().required(),
|
|
257
|
+
clientId: joi.array().optional(),
|
|
258
|
+
limit: joi.number().optional(),
|
|
259
|
+
offset: joi.number().optional(),
|
|
260
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
261
|
+
filterByStatus: joi.array().optional(),
|
|
262
|
+
filterByModuleType: joi.array().optional(),
|
|
263
|
+
filterByAuditType: joi.array().optional(),
|
|
264
|
+
sortColumnName: joi.string().optional(),
|
|
265
|
+
sortBy: joi.number().optional(),
|
|
266
|
+
isExport: joi.boolean().optional(),
|
|
267
|
+
},
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
export const overviewTableValid= {
|
|
271
|
+
body: overviewTableSchema,
|
|
249
272
|
};
|
|
250
273
|
|
|
251
274
|
export const overAllAuditSummarySchema = joi.object(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { isAuditDocumentExist, isAuditInputFolderExist, isExistsQueue, validateUserAudit } from '../validation/audit.validation.js';
|
|
3
3
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
4
|
-
import { auditImages, auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard,
|
|
5
|
-
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid,
|
|
4
|
+
import { auditImages, auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard, overviewTable, pendingSummaryTable, reTrigger, save, saveDraft, storeMetrics, summarySplit, totalNotAssignedCount, userAuditHistory, userMetrics, workSpace } from '../controllers/audit.controllers.js';
|
|
5
|
+
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid, pendingSummaryTableValid, reTriggerValid, saveDraftValid, saveValid, storeMetricsValid, summarySplitValid, userAuditHistoryValid, userMetricsValid, workSpaceValid, auditImageValid, overviewTableValid } from '../dtos/audit.dtos.js';
|
|
6
6
|
|
|
7
7
|
export const auditRouter = express.Router();
|
|
8
8
|
|
|
@@ -17,20 +17,22 @@ auditRouter.get( '/get-file', isAllowedSessionHandler, validate( getFileValid ),
|
|
|
17
17
|
auditRouter.post( '/save-draft', isAllowedSessionHandler, validate( saveDraftValid ), saveDraft );
|
|
18
18
|
auditRouter.get( '/get-drafted-data', isAllowedSessionHandler, validate( getDraftedDataValid ), getDraftedData );
|
|
19
19
|
auditRouter.post( '/save', isAllowedSessionHandler, validate( saveValid ), validateUserAudit, save );
|
|
20
|
-
auditRouter.
|
|
20
|
+
auditRouter.post( '/work-space', isAllowedSessionHandler, validate( workSpaceValid ), workSpace );
|
|
21
21
|
|
|
22
22
|
// Audit Metrics
|
|
23
23
|
auditRouter.post( '/metrics/user-audit-history', isAllowedSessionHandler, validate( userAuditHistoryValid ), userAuditHistory );
|
|
24
24
|
auditRouter.post( '/metrics/client-metrics', isAllowedSessionHandler, validate( clientMetricsValid ), clientMetrics );
|
|
25
25
|
auditRouter.post( '/metrics/store-metrics', isAllowedSessionHandler, validate( storeMetricsValid ), storeMetrics );
|
|
26
26
|
auditRouter.post( '/metrics/user-metrics', isAllowedSessionHandler, validate( userMetricsValid ), userMetrics );
|
|
27
|
-
auditRouter.post( '/metrics/
|
|
27
|
+
auditRouter.post( '/metrics/pending-summary-table', isAllowedSessionHandler, validate( pendingSummaryTableValid ), pendingSummaryTable );
|
|
28
28
|
auditRouter.post( '/metrics/overall-audit-summary', isAllowedSessionHandler, validate( overAllAuditSummaryValid ), overAllAuditSummary );
|
|
29
29
|
auditRouter.post( '/metrics/re-trigger', isAllowedSessionHandler, validate( reTriggerValid ), isAuditDocumentExist, isAuditInputFolderExist, reTrigger );
|
|
30
30
|
auditRouter.get( '/audit-images', isAllowedSessionHandler, validate( auditImageValid ), isAuditInputFolderExist, auditImages );
|
|
31
31
|
// summary
|
|
32
32
|
auditRouter.post( '/metrics/overview-card', isAllowedSessionHandler, validate( overViewCardValid ), overViewCard );
|
|
33
33
|
auditRouter.post( '/metrics/summary-split-up', isAllowedSessionHandler, validate( summarySplitValid ), summarySplit );
|
|
34
|
+
auditRouter.post( '/metrics/overview-table', isAllowedSessionHandler, validate( overviewTableValid ), overviewTable );
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
// ticket
|
|
37
|
+
auditRouter.get( '/total-not-assigned-count', isAllowedSessionHandler, totalNotAssignedCount );
|
|
36
38
|
export default auditRouter;
|
|
@@ -246,7 +246,7 @@ export async function getAuditImageData( data ) {
|
|
|
246
246
|
if ( auditImages && auditImages?.length > 0 ) {
|
|
247
247
|
for ( let i = 0; i < auditImages.length; i++ ) {
|
|
248
248
|
const img = auditImages[i].Key.split( '/' );
|
|
249
|
-
const image = img[
|
|
249
|
+
const image = img[3].split( '.' );
|
|
250
250
|
const indexes = image[0].split( '_' );
|
|
251
251
|
const params = {
|
|
252
252
|
file_path: auditImages[i].Key,
|