tango-app-api-audit 1.0.54 → 1.0.56
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/index.js +1 -3
- package/package.json +1 -1
- package/src/controllers/audit.controllers.js +468 -1
- package/src/controllers/auditMetrics.controllers.js +3 -455
- package/src/docs/audit.docs.js +94 -5
- package/src/docs/auditMetrics.docs.js +1 -89
- package/src/dtos/audit.dtos.js +58 -0
- package/src/dtos/auditMetrics.dtos.js +0 -58
- package/src/routes/audit.routes.js +8 -2
- package/src/routes/auditMetrics.routes.js +2 -6
package/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { auditRouter } from './src/routes/audit.routes.js';
|
|
4
|
-
import { auditMetricsRouter } from './src/routes/auditMetrics.routes.js';
|
|
5
|
-
import { auditMetricsDocs } from './src/docs/auditMetrics.docs.js';
|
|
6
4
|
import { auditDocs } from './src/docs/audit.docs.js';
|
|
7
5
|
|
|
8
|
-
export { auditRouter,
|
|
6
|
+
export { auditRouter, auditDocs };
|
|
9
7
|
|
|
10
8
|
|
package/package.json
CHANGED
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
createAuditLog,
|
|
40
40
|
findOneAuditLog,
|
|
41
41
|
} from '../service/auditLog.service.js';
|
|
42
|
-
import { aggregateStore, findOneStore } from '../service/store.service.js';
|
|
42
|
+
import { aggregateStore, countDocumentsStore, findOneStore } from '../service/store.service.js';
|
|
43
43
|
import {
|
|
44
44
|
mapCustomer,
|
|
45
45
|
mapEmployee,
|
|
@@ -2420,3 +2420,470 @@ export async function userMetrics( req, res ) {
|
|
|
2420
2420
|
return res.sendError( err, 500 );
|
|
2421
2421
|
}
|
|
2422
2422
|
}
|
|
2423
|
+
|
|
2424
|
+
export async function overViewTable( req, res ) {
|
|
2425
|
+
try {
|
|
2426
|
+
const inputData = req.body;
|
|
2427
|
+
const limit = inputData.limit || 10;
|
|
2428
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
2429
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
2430
|
+
let filters =[
|
|
2431
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
2432
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
2433
|
+
{ auditStatus: { $in: inputData.filterByStatus } },
|
|
2434
|
+
|
|
2435
|
+
];
|
|
2436
|
+
|
|
2437
|
+
if ( inputData.clientId.length > 0 ) {
|
|
2438
|
+
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
if ( inputData.filterByModuleType.length > 0 ) {
|
|
2442
|
+
filters.push( { moduleType: { $in: inputData.filterByModuleType } } );
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
if ( inputData.filterByAuditType.length > 0 ) {
|
|
2446
|
+
filters.push( { auditType: { $in: inputData.filterByAuditType } } );
|
|
2447
|
+
}
|
|
2448
|
+
const query =[
|
|
2449
|
+
{
|
|
2450
|
+
$match: {
|
|
2451
|
+
$and: filters,
|
|
2452
|
+
},
|
|
2453
|
+
|
|
2454
|
+
},
|
|
2455
|
+
{
|
|
2456
|
+
$project: {
|
|
2457
|
+
_id: 0,
|
|
2458
|
+
storeId: 1,
|
|
2459
|
+
zoneName: 1,
|
|
2460
|
+
fileDate: 1,
|
|
2461
|
+
moduleType: 1,
|
|
2462
|
+
beforeCount: 1,
|
|
2463
|
+
startTime: 1,
|
|
2464
|
+
auditType: 1,
|
|
2465
|
+
auditStatus: 1,
|
|
2466
|
+
userId: 1,
|
|
2467
|
+
},
|
|
2468
|
+
},
|
|
2469
|
+
{
|
|
2470
|
+
$lookup: {
|
|
2471
|
+
from: 'users',
|
|
2472
|
+
let: { userId: '$userId' },
|
|
2473
|
+
pipeline: [
|
|
2474
|
+
{
|
|
2475
|
+
$match: {
|
|
2476
|
+
$expr: {
|
|
2477
|
+
$eq: [ '$_id', '$$userId' ],
|
|
2478
|
+
},
|
|
2479
|
+
},
|
|
2480
|
+
},
|
|
2481
|
+
{
|
|
2482
|
+
$project: {
|
|
2483
|
+
userName: 1,
|
|
2484
|
+
userEmail: '$email',
|
|
2485
|
+
},
|
|
2486
|
+
},
|
|
2487
|
+
], as: 'user',
|
|
2488
|
+
},
|
|
2489
|
+
},
|
|
2490
|
+
{
|
|
2491
|
+
$unwind: {
|
|
2492
|
+
path: '$user',
|
|
2493
|
+
preserveNullAndEmptyArrays: true,
|
|
2494
|
+
},
|
|
2495
|
+
},
|
|
2496
|
+
{
|
|
2497
|
+
$project: {
|
|
2498
|
+
storeId: 1,
|
|
2499
|
+
zoneName: 1,
|
|
2500
|
+
fileDate: 1,
|
|
2501
|
+
moduleType: 1,
|
|
2502
|
+
beforeCount: 1,
|
|
2503
|
+
startTime: 1,
|
|
2504
|
+
auditType: 1,
|
|
2505
|
+
auditStatus: 1,
|
|
2506
|
+
userName: '$user.userName',
|
|
2507
|
+
userEmail: '$user.userEmail',
|
|
2508
|
+
|
|
2509
|
+
},
|
|
2510
|
+
},
|
|
2511
|
+
];
|
|
2512
|
+
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
2513
|
+
query.push( {
|
|
2514
|
+
$match: {
|
|
2515
|
+
$or: [
|
|
2516
|
+
{ storeId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2517
|
+
{ fileDate: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2518
|
+
{ auditType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2519
|
+
{ auditStatus: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2520
|
+
{ userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2521
|
+
{ userEmail: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2522
|
+
],
|
|
2523
|
+
|
|
2524
|
+
},
|
|
2525
|
+
} );
|
|
2526
|
+
}
|
|
2527
|
+
if ( inputData.sortColumnName ) {
|
|
2528
|
+
const sortBy = inputData.sortBy || -1;
|
|
2529
|
+
query.push( {
|
|
2530
|
+
$sort: { [inputData.sortColumName]: sortBy },
|
|
2531
|
+
},
|
|
2532
|
+
);
|
|
2533
|
+
}
|
|
2534
|
+
const count = await aggregateUserAudit( query );
|
|
2535
|
+
if ( count.length == 0 ) {
|
|
2536
|
+
return res.sendError( 'No Data Found', 204 );
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
if ( inputData.isExport ) {
|
|
2540
|
+
query.push( { $limit: 10000 } );
|
|
2541
|
+
} else {
|
|
2542
|
+
query.push( {
|
|
2543
|
+
$skip: offset,
|
|
2544
|
+
},
|
|
2545
|
+
{
|
|
2546
|
+
$limit: limit,
|
|
2547
|
+
} );
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
const result = await aggregateUserAudit( query );
|
|
2551
|
+
if ( inputData.isExport ) {
|
|
2552
|
+
const exportdata = [];
|
|
2553
|
+
result.forEach( ( element ) => {
|
|
2554
|
+
exportdata.push( {
|
|
2555
|
+
'Store Id': element.storeId,
|
|
2556
|
+
'zoneName': element.zoneName,
|
|
2557
|
+
'File Date': element.fileDate,
|
|
2558
|
+
'Module Type': element.moduleType,
|
|
2559
|
+
'Audit Type': element.auditType,
|
|
2560
|
+
'Before Count': element.beforeCount,
|
|
2561
|
+
'Start Time': element.startTime,
|
|
2562
|
+
'User Name': element.userName,
|
|
2563
|
+
'User Email': element.userEmail,
|
|
2564
|
+
'Status': element.auditStatus,
|
|
2565
|
+
} );
|
|
2566
|
+
} );
|
|
2567
|
+
await download( exportdata, res );
|
|
2568
|
+
return;
|
|
2569
|
+
}
|
|
2570
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
2571
|
+
} catch ( error ) {
|
|
2572
|
+
const err = error.message || 'Internal Server Error';
|
|
2573
|
+
logger.error( { error: error, message: req.body, function: 'summarySplit' } );
|
|
2574
|
+
return res.sendError( err, 500 );
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
export async function overAllAuditSummary( req, res ) {
|
|
2579
|
+
try {
|
|
2580
|
+
const inputData = req.body;
|
|
2581
|
+
let temp = {
|
|
2582
|
+
installedStores: 0,
|
|
2583
|
+
auditStores: 0,
|
|
2584
|
+
inprogreseStores: 0,
|
|
2585
|
+
completedStores: 0,
|
|
2586
|
+
auditInprogress: 0,
|
|
2587
|
+
reAuditInprogress: 0,
|
|
2588
|
+
draft: 0,
|
|
2589
|
+
assigned: 0,
|
|
2590
|
+
notAssigned: 0,
|
|
2591
|
+
auditCompleted: 0,
|
|
2592
|
+
reAuditCompleted: 0,
|
|
2593
|
+
|
|
2594
|
+
};
|
|
2595
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
2596
|
+
let filters =[
|
|
2597
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
2598
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
2599
|
+
{ moduleType: { $in: inputData.moduleType },
|
|
2600
|
+
},
|
|
2601
|
+
];
|
|
2602
|
+
if ( inputData.clientId.length > 0 ) {
|
|
2603
|
+
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
2604
|
+
}
|
|
2605
|
+
const storeQuery = inputData.clientId.length? { 'edge.firstFile': true, 'clientId': { $in: inputData. clientId } } : { 'edge.firstFile': true };
|
|
2606
|
+
temp.installedStores = await countDocumentsStore( storeQuery );
|
|
2607
|
+
const auditClientDataQuery =[
|
|
2608
|
+
{
|
|
2609
|
+
$match: {
|
|
2610
|
+
$and: filters,
|
|
2611
|
+
},
|
|
2612
|
+
|
|
2613
|
+
},
|
|
2614
|
+
{
|
|
2615
|
+
$group: {
|
|
2616
|
+
_id: null,
|
|
2617
|
+
totalFilesCount: { $sum: 1 },
|
|
2618
|
+
},
|
|
2619
|
+
},
|
|
2620
|
+
{
|
|
2621
|
+
$project: {
|
|
2622
|
+
_id: 0,
|
|
2623
|
+
totalFilesCount: 1,
|
|
2624
|
+
},
|
|
2625
|
+
},
|
|
2626
|
+
];
|
|
2627
|
+
const auditClientData = await aggregateAuditStoreDataSchema( auditClientDataQuery );
|
|
2628
|
+
if ( auditClientData.length >0 ) {
|
|
2629
|
+
temp.auditStores = auditClientData[0].totalFilesCount;
|
|
2630
|
+
}
|
|
2631
|
+
const storeAuditQuery =[
|
|
2632
|
+
{
|
|
2633
|
+
$match: {
|
|
2634
|
+
$and: filters,
|
|
2635
|
+
},
|
|
2636
|
+
|
|
2637
|
+
},
|
|
2638
|
+
{
|
|
2639
|
+
$project: {
|
|
2640
|
+
completedStores: { $cond: [ { $eq: [ '$status', 'completed' ] }, 1, 0 ] },
|
|
2641
|
+
auditInprogress: { $cond: [ { $and: [ { $in: [ '$status', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
|
|
2642
|
+
reAuditInprogress: { $cond: [ { $and: [ { $in: [ '$status', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
|
|
2643
|
+
draft: { $cond: [ { $eq: [ '$status', 'drafted' ] }, 1, 0 ] },
|
|
2644
|
+
assigned: { $cond: [ { $eq: [ '$status', 'drafted' ] }, 1, 0 ] },
|
|
2645
|
+
exceptNoAssigned: { $cond: [ { $in: [ '$status', [ 'skipped', 'not_assign' ] ] }, 1, 0 ] },
|
|
2646
|
+
auditCompleted: { $cond: [ { $and: [ { $in: [ '$status', [ 'completed' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
|
|
2647
|
+
reAuditCompleted: { $cond: [ { $and: [ { $in: [ '$status', [ 'completed' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
|
|
2648
|
+
|
|
2649
|
+
|
|
2650
|
+
},
|
|
2651
|
+
},
|
|
2652
|
+
{
|
|
2653
|
+
$group: {
|
|
2654
|
+
_id: null,
|
|
2655
|
+
completedStores: { $sum: '$completedStores' },
|
|
2656
|
+
auditInprogress: { $sum: '$auditInprogress' },
|
|
2657
|
+
reAuditInprogress: { $sum: '$reAuditInprogress' },
|
|
2658
|
+
draft: { $sum: '$draft' },
|
|
2659
|
+
assigned: { $sum: '$assigned' },
|
|
2660
|
+
exceptNoAssigned: { $sum: '$exceptNoAssigned' },
|
|
2661
|
+
auditCompleted: { $sum: '$auditCompleted' },
|
|
2662
|
+
reAuditCompleted: { $sum: '$reAuditCompleted' },
|
|
2663
|
+
},
|
|
2664
|
+
},
|
|
2665
|
+
{
|
|
2666
|
+
$project: {
|
|
2667
|
+
completedStores: 1,
|
|
2668
|
+
inprogressStores: { $subtract: [ temp.auditStores, '$completedStores' ] },
|
|
2669
|
+
auditInprogress: 1,
|
|
2670
|
+
reAuditInprogress: 1,
|
|
2671
|
+
draft: 1,
|
|
2672
|
+
assigned: 1,
|
|
2673
|
+
exceptNoAssigned1: 1,
|
|
2674
|
+
exceptNoAssigned: { $subtract: [ temp.auditStores, '$exceptNoAssigned' ] },
|
|
2675
|
+
auditCompleted: 1,
|
|
2676
|
+
reAuditCompleted: 1,
|
|
2677
|
+
},
|
|
2678
|
+
},
|
|
2679
|
+
];
|
|
2680
|
+
const storeAudit = await aggregateStoreAudit( storeAuditQuery );
|
|
2681
|
+
if ( storeAudit.length > 0 ) {
|
|
2682
|
+
temp.inprogreseStores= storeAudit[0].inprogreseStores;
|
|
2683
|
+
temp.completedStores = storeAudit[0].completedStores;
|
|
2684
|
+
temp.auditInprogress = storeAudit[0].auditInprogress;
|
|
2685
|
+
temp.reAuditInprogress = storeAudit[0].reAuditInprogress;
|
|
2686
|
+
temp.draft = storeAudit[0].draft;
|
|
2687
|
+
temp.assigned = storeAudit[0].assigned;
|
|
2688
|
+
temp.notAssigned = storeAudit[0].exceptNoAssigned;
|
|
2689
|
+
temp.auditCompleted = storeAudit[0].auditCompleted;
|
|
2690
|
+
temp.reAuditCompleted = storeAudit[0].reAuditCompleted;
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
return res.sendSuccess( { result: temp } );
|
|
2694
|
+
} catch ( error ) {
|
|
2695
|
+
const err = error.message || 'Internal Server Error';
|
|
2696
|
+
logger.error( { error: error, message: req.body, function: 'summarySplit' } );
|
|
2697
|
+
return res.sendError( err, 500 );
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
export async function overViewCard( req, res ) {
|
|
2702
|
+
try {
|
|
2703
|
+
const inputData = req.body;
|
|
2704
|
+
const temp = {
|
|
2705
|
+
totalCount: 0,
|
|
2706
|
+
auditFileCount: 0,
|
|
2707
|
+
ReAuditFileCount: 0,
|
|
2708
|
+
inprogressCount: 0,
|
|
2709
|
+
completedCount: 0,
|
|
2710
|
+
};
|
|
2711
|
+
|
|
2712
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
2713
|
+
let filters =[
|
|
2714
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
2715
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
2716
|
+
];
|
|
2717
|
+
if ( inputData.clientId.length > 0 ) {
|
|
2718
|
+
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
2719
|
+
}
|
|
2720
|
+
const query =[
|
|
2721
|
+
{
|
|
2722
|
+
$match: {
|
|
2723
|
+
$and: filters,
|
|
2724
|
+
},
|
|
2725
|
+
|
|
2726
|
+
},
|
|
2727
|
+
{
|
|
2728
|
+
$project: {
|
|
2729
|
+
auditFileCount: {
|
|
2730
|
+
$cond: [
|
|
2731
|
+
{ $eq: [ '$auditType', 'Audit' ] }, 1, 0,
|
|
2732
|
+
],
|
|
2733
|
+
},
|
|
2734
|
+
ReAuditFileCount: {
|
|
2735
|
+
$cond: [
|
|
2736
|
+
{ $eq: [ '$auditType', 'ReAudit' ] }, 1, 0,
|
|
2737
|
+
],
|
|
2738
|
+
},
|
|
2739
|
+
inprogressCount: {
|
|
2740
|
+
$cond: [
|
|
2741
|
+
{ $ne: [ '$status', 'completed' ] }, 1, 0,
|
|
2742
|
+
],
|
|
2743
|
+
},
|
|
2744
|
+
completedCount: {
|
|
2745
|
+
$cond: [
|
|
2746
|
+
{ $eq: [ '$status', 'completed' ] }, 1, 0,
|
|
2747
|
+
],
|
|
2748
|
+
},
|
|
2749
|
+
},
|
|
2750
|
+
},
|
|
2751
|
+
{
|
|
2752
|
+
$group: {
|
|
2753
|
+
_id: { fileDate: '$fileDate', clientId: '$clientId' },
|
|
2754
|
+
totalCount: { $sum: 1 },
|
|
2755
|
+
auditFileCount: { $sum: '$auditFileCount' },
|
|
2756
|
+
ReAuditFileCount: { $sum: '$ReAuditFileCount' },
|
|
2757
|
+
inprogressCount: { $sum: '$inprogressCount' },
|
|
2758
|
+
completedCount: { $sum: '$completedCount' },
|
|
2759
|
+
|
|
2760
|
+
},
|
|
2761
|
+
},
|
|
2762
|
+
{
|
|
2763
|
+
$project: {
|
|
2764
|
+
_id: 0,
|
|
2765
|
+
totalCount: 1,
|
|
2766
|
+
auditFileCount: 1,
|
|
2767
|
+
ReAuditFileCount: 1,
|
|
2768
|
+
inprogressCount: 1,
|
|
2769
|
+
completedCount: 1,
|
|
2770
|
+
},
|
|
2771
|
+
},
|
|
2772
|
+
];
|
|
2773
|
+
const result = await aggregateStoreAudit( query );
|
|
2774
|
+
logger.info( { result: result } );
|
|
2775
|
+
return res.sendSuccess( { result: result.length> 0? result[0]: temp } );
|
|
2776
|
+
} catch ( error ) {
|
|
2777
|
+
const err = error.message || 'Internal Server Error';
|
|
2778
|
+
logger.error( { error: error, message: req.body, function: 'overViewCard' } );
|
|
2779
|
+
return res.sendError( err, 500 );
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
export async function summarySplit( req, res ) {
|
|
2784
|
+
try {
|
|
2785
|
+
const inputData = req.body;
|
|
2786
|
+
const temp = {
|
|
2787
|
+
totalInprogress: 0,
|
|
2788
|
+
auditInprogress: 0,
|
|
2789
|
+
reAuditInprogress: 0,
|
|
2790
|
+
draft: 0,
|
|
2791
|
+
assigned: 0,
|
|
2792
|
+
auditCompleted: 0,
|
|
2793
|
+
reAuditCompleted: 0,
|
|
2794
|
+
completedCount: 0,
|
|
2795
|
+
};
|
|
2796
|
+
|
|
2797
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
2798
|
+
let filters =[
|
|
2799
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
2800
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
2801
|
+
];
|
|
2802
|
+
if ( inputData.clientId.length > 0 ) {
|
|
2803
|
+
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
2804
|
+
}
|
|
2805
|
+
const query =[
|
|
2806
|
+
{
|
|
2807
|
+
$match: {
|
|
2808
|
+
$and: filters,
|
|
2809
|
+
},
|
|
2810
|
+
|
|
2811
|
+
},
|
|
2812
|
+
{
|
|
2813
|
+
$project: {
|
|
2814
|
+
auditInprogress: {
|
|
2815
|
+
$cond: [
|
|
2816
|
+
{ $and: [ { $eq: [ '$auditType', 'Audit' ] }, { $eq: [ '$status', 'inprogress' ] } ] }, 1, 0,
|
|
2817
|
+
],
|
|
2818
|
+
},
|
|
2819
|
+
reAuditInprogress: {
|
|
2820
|
+
$cond: [
|
|
2821
|
+
{ $and: [ { $eq: [ '$auditType', 'ReAudit' ] }, { $eq: [ '$status', 'inprogress' ] } ] }, 1, 0,
|
|
2822
|
+
],
|
|
2823
|
+
},
|
|
2824
|
+
draft: {
|
|
2825
|
+
$cond: [
|
|
2826
|
+
{ $ne: [ '$status', 'drafted' ] }, 1, 0,
|
|
2827
|
+
],
|
|
2828
|
+
},
|
|
2829
|
+
assigned: {
|
|
2830
|
+
$cond: [
|
|
2831
|
+
{ $ne: [ '$status', 'assigned' ] }, 1, 0,
|
|
2832
|
+
],
|
|
2833
|
+
},
|
|
2834
|
+
completedCount: {
|
|
2835
|
+
$cond: [
|
|
2836
|
+
{ $eq: [ '$status', 'completed' ] }, 1, 0,
|
|
2837
|
+
],
|
|
2838
|
+
},
|
|
2839
|
+
reAuditCompleted: {
|
|
2840
|
+
$cond: [
|
|
2841
|
+
{ $and: [ { $eq: [ '$auditType', 'ReAudit' ] }, { $eq: [ '$status', 'completed' ] } ] }, 1, 0,
|
|
2842
|
+
],
|
|
2843
|
+
},
|
|
2844
|
+
auditCompleted: {
|
|
2845
|
+
$cond: [
|
|
2846
|
+
{ $and: [ { $eq: [ '$auditType', 'Audit' ] }, { $eq: [ '$status', 'completed' ] } ] }, 1, 0,
|
|
2847
|
+
],
|
|
2848
|
+
},
|
|
2849
|
+
},
|
|
2850
|
+
},
|
|
2851
|
+
{
|
|
2852
|
+
$group: {
|
|
2853
|
+
_id: { fileDate: '$fileDate', clientId: '$clientId' },
|
|
2854
|
+
totalInprogress: { $sum: 1 },
|
|
2855
|
+
auditInprogress: { $sum: '$auditInprogress' },
|
|
2856
|
+
reAuditInprogress: { $sum: '$reAuditInprogress' },
|
|
2857
|
+
draft: { $sum: '$draft' },
|
|
2858
|
+
assigned: { $sum: 'assigned' },
|
|
2859
|
+
completedCount: { $sum: '$completedCount' },
|
|
2860
|
+
reAuditCompleted: { $sum: '$reAuditCompleted' },
|
|
2861
|
+
auditCompleted: { $sum: '$auditCompleted' },
|
|
2862
|
+
completedCount: { $sum: '$completedCount' },
|
|
2863
|
+
|
|
2864
|
+
},
|
|
2865
|
+
},
|
|
2866
|
+
{
|
|
2867
|
+
$project: {
|
|
2868
|
+
_id: 0,
|
|
2869
|
+
totalInprogress: 1,
|
|
2870
|
+
auditInprogress: 1,
|
|
2871
|
+
reAuditInprogress: 1,
|
|
2872
|
+
draft: 1,
|
|
2873
|
+
assigned: 1,
|
|
2874
|
+
completedCount: 1,
|
|
2875
|
+
reAuditCompleted: 1,
|
|
2876
|
+
auditCompleted: 1,
|
|
2877
|
+
|
|
2878
|
+
},
|
|
2879
|
+
},
|
|
2880
|
+
];
|
|
2881
|
+
const result = await aggregateStoreAudit( query );
|
|
2882
|
+
logger.info( { result: result } );
|
|
2883
|
+
return res.sendSuccess( { result: result.length> 0? result[0]: temp } );
|
|
2884
|
+
} catch ( error ) {
|
|
2885
|
+
const err = error.message || 'Internal Server Error';
|
|
2886
|
+
logger.error( { error: error, message: req.body, function: 'summarySplit' } );
|
|
2887
|
+
return res.sendError( err, 500 );
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
@@ -1,468 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { insertOpenSearchData, logger, sendMessageToQueue } from 'tango-app-api-middleware';
|
|
2
|
+
import { updateOneUserAudit } from '../service/userAudit.service.js';
|
|
3
3
|
import mongoose from 'mongoose';
|
|
4
|
-
import {
|
|
4
|
+
import { updateOneStoreAudit } from '../service/storeAudit.service.js';
|
|
5
5
|
import { findOneUser } from '../service/user.service.js';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
7
|
import { createAssignAudit } from '../service/assignAudit.service.js';
|
|
8
|
-
import { countDocumentsStore } from '../service/store.service.js';
|
|
9
8
|
import { findOneClient } from '../service/client.service.js';
|
|
10
9
|
import { getAuditFilterData, getAuditImageData, zipDownloadImage } from '../validation/audit.validation.js';
|
|
11
10
|
import { getReauditImg } from './audit.controllers.js';
|
|
12
11
|
// import { listQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
|
|
13
12
|
|
|
14
13
|
|
|
15
|
-
export async function overViewCard( req, res ) {
|
|
16
|
-
try {
|
|
17
|
-
const inputData = req.body;
|
|
18
|
-
const temp = {
|
|
19
|
-
totalCount: 0,
|
|
20
|
-
auditFileCount: 0,
|
|
21
|
-
ReAuditFileCount: 0,
|
|
22
|
-
inprogressCount: 0,
|
|
23
|
-
completedCount: 0,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
27
|
-
let filters =[
|
|
28
|
-
{ fileDateISO: { $gte: dateRange.start } },
|
|
29
|
-
{ fileDateISO: { $lte: dateRange.end } },
|
|
30
|
-
];
|
|
31
|
-
if ( inputData.clientId.length > 0 ) {
|
|
32
|
-
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
33
|
-
}
|
|
34
|
-
const query =[
|
|
35
|
-
{
|
|
36
|
-
$match: {
|
|
37
|
-
$and: filters,
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
$project: {
|
|
43
|
-
auditFileCount: {
|
|
44
|
-
$cond: [
|
|
45
|
-
{ $eq: [ '$auditType', 'Audit' ] }, 1, 0,
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
ReAuditFileCount: {
|
|
49
|
-
$cond: [
|
|
50
|
-
{ $eq: [ '$auditType', 'ReAudit' ] }, 1, 0,
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
inprogressCount: {
|
|
54
|
-
$cond: [
|
|
55
|
-
{ $ne: [ '$status', 'completed' ] }, 1, 0,
|
|
56
|
-
],
|
|
57
|
-
},
|
|
58
|
-
completedCount: {
|
|
59
|
-
$cond: [
|
|
60
|
-
{ $eq: [ '$status', 'completed' ] }, 1, 0,
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
$group: {
|
|
67
|
-
_id: { fileDate: '$fileDate', clientId: '$clientId' },
|
|
68
|
-
totalCount: { $sum: 1 },
|
|
69
|
-
auditFileCount: { $sum: '$auditFileCount' },
|
|
70
|
-
ReAuditFileCount: { $sum: '$ReAuditFileCount' },
|
|
71
|
-
inprogressCount: { $sum: '$inprogressCount' },
|
|
72
|
-
completedCount: { $sum: '$completedCount' },
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
$project: {
|
|
78
|
-
_id: 0,
|
|
79
|
-
totalCount: 1,
|
|
80
|
-
auditFileCount: 1,
|
|
81
|
-
ReAuditFileCount: 1,
|
|
82
|
-
inprogressCount: 1,
|
|
83
|
-
completedCount: 1,
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
];
|
|
87
|
-
const result = await aggregateStoreAudit( query );
|
|
88
|
-
logger.info( { result: result } );
|
|
89
|
-
return res.sendSuccess( { result: result.length> 0? result[0]: temp } );
|
|
90
|
-
} catch ( error ) {
|
|
91
|
-
const err = error.message || 'Internal Server Error';
|
|
92
|
-
logger.error( { error: error, message: req.body, function: 'overViewCard' } );
|
|
93
|
-
return res.sendError( err, 500 );
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export async function summarySplit( req, res ) {
|
|
98
|
-
try {
|
|
99
|
-
const inputData = req.body;
|
|
100
|
-
const temp = {
|
|
101
|
-
totalInprogress: 0,
|
|
102
|
-
auditInprogress: 0,
|
|
103
|
-
reAuditInprogress: 0,
|
|
104
|
-
draft: 0,
|
|
105
|
-
assigned: 0,
|
|
106
|
-
auditCompleted: 0,
|
|
107
|
-
reAuditCompleted: 0,
|
|
108
|
-
completedCount: 0,
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
112
|
-
let filters =[
|
|
113
|
-
{ fileDateISO: { $gte: dateRange.start } },
|
|
114
|
-
{ fileDateISO: { $lte: dateRange.end } },
|
|
115
|
-
];
|
|
116
|
-
if ( inputData.clientId.length > 0 ) {
|
|
117
|
-
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
118
|
-
}
|
|
119
|
-
const query =[
|
|
120
|
-
{
|
|
121
|
-
$match: {
|
|
122
|
-
$and: filters,
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
$project: {
|
|
128
|
-
auditInprogress: {
|
|
129
|
-
$cond: [
|
|
130
|
-
{ $and: [ { $eq: [ '$auditType', 'Audit' ] }, { $eq: [ '$status', 'inprogress' ] } ] }, 1, 0,
|
|
131
|
-
],
|
|
132
|
-
},
|
|
133
|
-
reAuditInprogress: {
|
|
134
|
-
$cond: [
|
|
135
|
-
{ $and: [ { $eq: [ '$auditType', 'ReAudit' ] }, { $eq: [ '$status', 'inprogress' ] } ] }, 1, 0,
|
|
136
|
-
],
|
|
137
|
-
},
|
|
138
|
-
draft: {
|
|
139
|
-
$cond: [
|
|
140
|
-
{ $ne: [ '$status', 'drafted' ] }, 1, 0,
|
|
141
|
-
],
|
|
142
|
-
},
|
|
143
|
-
assigned: {
|
|
144
|
-
$cond: [
|
|
145
|
-
{ $ne: [ '$status', 'assigned' ] }, 1, 0,
|
|
146
|
-
],
|
|
147
|
-
},
|
|
148
|
-
completedCount: {
|
|
149
|
-
$cond: [
|
|
150
|
-
{ $eq: [ '$status', 'completed' ] }, 1, 0,
|
|
151
|
-
],
|
|
152
|
-
},
|
|
153
|
-
reAuditCompleted: {
|
|
154
|
-
$cond: [
|
|
155
|
-
{ $and: [ { $eq: [ '$auditType', 'ReAudit' ] }, { $eq: [ '$status', 'completed' ] } ] }, 1, 0,
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
auditCompleted: {
|
|
159
|
-
$cond: [
|
|
160
|
-
{ $and: [ { $eq: [ '$auditType', 'Audit' ] }, { $eq: [ '$status', 'completed' ] } ] }, 1, 0,
|
|
161
|
-
],
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
$group: {
|
|
167
|
-
_id: { fileDate: '$fileDate', clientId: '$clientId' },
|
|
168
|
-
totalInprogress: { $sum: 1 },
|
|
169
|
-
auditInprogress: { $sum: '$auditInprogress' },
|
|
170
|
-
reAuditInprogress: { $sum: '$reAuditInprogress' },
|
|
171
|
-
draft: { $sum: '$draft' },
|
|
172
|
-
assigned: { $sum: 'assigned' },
|
|
173
|
-
completedCount: { $sum: '$completedCount' },
|
|
174
|
-
reAuditCompleted: { $sum: '$reAuditCompleted' },
|
|
175
|
-
auditCompleted: { $sum: '$auditCompleted' },
|
|
176
|
-
completedCount: { $sum: '$completedCount' },
|
|
177
|
-
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
$project: {
|
|
182
|
-
_id: 0,
|
|
183
|
-
totalInprogress: 1,
|
|
184
|
-
auditInprogress: 1,
|
|
185
|
-
reAuditInprogress: 1,
|
|
186
|
-
draft: 1,
|
|
187
|
-
assigned: 1,
|
|
188
|
-
completedCount: 1,
|
|
189
|
-
reAuditCompleted: 1,
|
|
190
|
-
auditCompleted: 1,
|
|
191
|
-
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
];
|
|
195
|
-
const result = await aggregateStoreAudit( query );
|
|
196
|
-
logger.info( { result: result } );
|
|
197
|
-
return res.sendSuccess( { result: result.length> 0? result[0]: temp } );
|
|
198
|
-
} catch ( error ) {
|
|
199
|
-
const err = error.message || 'Internal Server Error';
|
|
200
|
-
logger.error( { error: error, message: req.body, function: 'summarySplit' } );
|
|
201
|
-
return res.sendError( err, 500 );
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export async function overViewTable( req, res ) {
|
|
206
|
-
try {
|
|
207
|
-
const inputData = req.body;
|
|
208
|
-
const limit = inputData.limit || 10;
|
|
209
|
-
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
210
|
-
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
211
|
-
let filters =[
|
|
212
|
-
{ fileDateISO: { $gte: dateRange.start } },
|
|
213
|
-
{ fileDateISO: { $lte: dateRange.end } },
|
|
214
|
-
{ auditStatus: { $in: inputData.filterByStatus } },
|
|
215
|
-
{ auditType: { $in: inputData.filterByType } },
|
|
216
|
-
|
|
217
|
-
];
|
|
218
|
-
if ( inputData.clientId.length > 0 ) {
|
|
219
|
-
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
220
|
-
}
|
|
221
|
-
if ( inputData.filterByAuditType.length > 0 ) {
|
|
222
|
-
filters.push( { moduleType: { $in: inputData.filterByAuditType } } );
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const query =[
|
|
226
|
-
{
|
|
227
|
-
$match: {
|
|
228
|
-
$and: filters,
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
$project: {
|
|
234
|
-
_id: 0,
|
|
235
|
-
storeId: 1,
|
|
236
|
-
fileDate: 1,
|
|
237
|
-
beforeCount: 1,
|
|
238
|
-
startTime: 1,
|
|
239
|
-
auditType: 1,
|
|
240
|
-
auditStatus: 1,
|
|
241
|
-
userId: 1,
|
|
242
|
-
},
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
$lookup: {
|
|
246
|
-
from: 'users',
|
|
247
|
-
let: { userId: '$userId' },
|
|
248
|
-
pipeline: [
|
|
249
|
-
{
|
|
250
|
-
$match: {
|
|
251
|
-
$expr: {
|
|
252
|
-
$eq: [ '$_id', '$$userId' ],
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
$project: {
|
|
258
|
-
userName: 1,
|
|
259
|
-
userEmail: '$email',
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
], as: 'user',
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
$unwind: {
|
|
267
|
-
path: '$user',
|
|
268
|
-
preserveNullAndEmptyArrays: true,
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
$project: {
|
|
273
|
-
storeId: 1,
|
|
274
|
-
fileDate: 1,
|
|
275
|
-
beforeCount: 1,
|
|
276
|
-
startTime: 1,
|
|
277
|
-
auditType: 1,
|
|
278
|
-
auditStatus: 1,
|
|
279
|
-
userName: '$user.userName',
|
|
280
|
-
userEmail: '$user.userEmail',
|
|
281
|
-
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
];
|
|
285
|
-
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
286
|
-
query.push( {
|
|
287
|
-
$match: {
|
|
288
|
-
$or: [
|
|
289
|
-
{ storeId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
290
|
-
{ fileDate: { $regex: inputData.searchValue, $options: 'i' } },
|
|
291
|
-
{ auditType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
292
|
-
{ auditStatus: { $regex: inputData.searchValue, $options: 'i' } },
|
|
293
|
-
{ userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
294
|
-
{ userEmail: { $regex: inputData.searchValue, $options: 'i' } },
|
|
295
|
-
],
|
|
296
|
-
|
|
297
|
-
},
|
|
298
|
-
} );
|
|
299
|
-
}
|
|
300
|
-
if ( inputData.sortColumnName ) {
|
|
301
|
-
const sortBy = inputData.sortBy || -1;
|
|
302
|
-
query.push( {
|
|
303
|
-
$sort: { [inputData.sortColumName]: sortBy },
|
|
304
|
-
},
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
const count = await aggregateUserAudit( query );
|
|
308
|
-
if ( count.length == 0 ) {
|
|
309
|
-
return res.sendError( 'No Data Found', 204 );
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
if ( inputData.isExport ) {
|
|
313
|
-
query.push( { limit: 10000 } );
|
|
314
|
-
} else {
|
|
315
|
-
query.push( {
|
|
316
|
-
$skip: offset,
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
$limit: limit,
|
|
320
|
-
} );
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const result = await aggregateUserAudit( query );
|
|
324
|
-
if ( inputData.isExport ) {
|
|
325
|
-
const exportdata = [];
|
|
326
|
-
result.forEach( ( element ) => {
|
|
327
|
-
exportdata.push( {
|
|
328
|
-
'Store Id': element.storeId,
|
|
329
|
-
'File Date': element.fileDtae,
|
|
330
|
-
'Type': element.audittype,
|
|
331
|
-
'Before Count': element.beforeCount,
|
|
332
|
-
'Start Time': element.startTime,
|
|
333
|
-
'User Name': element.userName,
|
|
334
|
-
'User Email': element.userEmail,
|
|
335
|
-
'Status': element.auditStatus,
|
|
336
|
-
'Audit Type': element.moduleType,
|
|
337
|
-
} );
|
|
338
|
-
} );
|
|
339
|
-
await download( exportdata, res );
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
return res.sendSuccess( { result: result, count: count.length } );
|
|
343
|
-
} catch ( error ) {
|
|
344
|
-
const err = error.message || 'Internal Server Error';
|
|
345
|
-
logger.error( { error: error, message: req.body, function: 'summarySplit' } );
|
|
346
|
-
return res.sendError( err, 500 );
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
export async function overAllAuditSummary( req, res ) {
|
|
351
|
-
try {
|
|
352
|
-
const inputData = req.body;
|
|
353
|
-
let temp = {
|
|
354
|
-
installedStores: 0,
|
|
355
|
-
auditStores: 0,
|
|
356
|
-
inprogreseStores: 0,
|
|
357
|
-
completedStores: 0,
|
|
358
|
-
auditInprogress: 0,
|
|
359
|
-
reAuditInprogress: 0,
|
|
360
|
-
draft: 0,
|
|
361
|
-
assigned: 0,
|
|
362
|
-
notAssigned: 0,
|
|
363
|
-
auditCompleted: 0,
|
|
364
|
-
reAuditCompleted: 0,
|
|
365
|
-
|
|
366
|
-
};
|
|
367
|
-
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
368
|
-
let filters =[
|
|
369
|
-
{ fileDateISO: { $gte: dateRange.start } },
|
|
370
|
-
{ fileDateISO: { $lte: dateRange.end } },
|
|
371
|
-
{ moduleType: { $eq: inputData.moduleType },
|
|
372
|
-
},
|
|
373
|
-
];
|
|
374
|
-
if ( inputData.clientId.length > 0 ) {
|
|
375
|
-
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
376
|
-
}
|
|
377
|
-
const storeQuery = inputData.clientId.length? { 'edge.firstFile': true, 'clientId': { $in: inputData. clientId } } : { 'edge.firstFile': true };
|
|
378
|
-
temp.installedStores = await countDocumentsStore( storeQuery );
|
|
379
|
-
// const auditClientDataQuery =[
|
|
380
|
-
// {
|
|
381
|
-
// $match: {
|
|
382
|
-
// $and: filters,
|
|
383
|
-
// },
|
|
384
|
-
|
|
385
|
-
// },
|
|
386
|
-
// {
|
|
387
|
-
// $group: {
|
|
388
|
-
// _id: null,
|
|
389
|
-
// totalFilesCount: { $sum: '$totalFilesCount' },
|
|
390
|
-
// },
|
|
391
|
-
// },
|
|
392
|
-
// ];
|
|
393
|
-
const auditClientData = [];// await aggregateAuditClientData( auditClientDataQuery );
|
|
394
|
-
if ( auditClientData.length >0 ) {
|
|
395
|
-
temp.auditStores = auditClientData[0].totalFilesCount;
|
|
396
|
-
}
|
|
397
|
-
const storeAuditQuery =[
|
|
398
|
-
{
|
|
399
|
-
$match: {
|
|
400
|
-
$and: filters,
|
|
401
|
-
},
|
|
402
|
-
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
$project: {
|
|
406
|
-
completedStores: { $cond: [ { $eq: [ '$status', 'completed' ] }, 1, 0 ] },
|
|
407
|
-
auditInprogress: { $cond: [ { $and: [ { $in: [ '$status', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
|
|
408
|
-
reAuditInprogress: { $cond: [ { $and: [ { $in: [ '$status', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
|
|
409
|
-
draft: { $cond: [ { $eq: [ '$status', 'drafted' ] }, 1, 0 ] },
|
|
410
|
-
assigned: { $cond: [ { $eq: [ '$status', 'drafted' ] }, 1, 0 ] },
|
|
411
|
-
exceptNoAssigned: { $cond: [ { $in: [ '$status', [ 'skipped', 'not_assign' ] ] }, 1, 0 ] },
|
|
412
|
-
auditCompleted: { $cond: [ { $and: [ { $in: [ '$status', [ 'completed' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
|
|
413
|
-
reAuditCompleted: { $cond: [ { $and: [ { $in: [ '$status', [ 'completed' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
$group: {
|
|
420
|
-
_id: null,
|
|
421
|
-
completedStores: { $sum: '$completedStores' },
|
|
422
|
-
auditInprogress: { $sum: '$auditInprogress' },
|
|
423
|
-
reAuditInprogress: { $sum: '$reAuditInprogress' },
|
|
424
|
-
draft: { $sum: '$draft' },
|
|
425
|
-
assigned: { $sum: '$assigned' },
|
|
426
|
-
exceptNoAssigned: { $sum: '$exceptNoAssigned' },
|
|
427
|
-
auditCompleted: { $sum: '$auditCompleted' },
|
|
428
|
-
reAuditCompleted: { $sum: '$reAuditCompleted' },
|
|
429
|
-
},
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
$project: {
|
|
433
|
-
completedStores: 1,
|
|
434
|
-
inprogressStores: { $subtract: [ temp.auditStores, '$completedStores' ] },
|
|
435
|
-
auditInprogress: 1,
|
|
436
|
-
reAuditInprogress: 1,
|
|
437
|
-
draft: 1,
|
|
438
|
-
assigned: 1,
|
|
439
|
-
exceptNoAssigned: { $subtract: [ temp.auditStores, '$exceptNoAssigned' ] },
|
|
440
|
-
auditCompleted: 1,
|
|
441
|
-
reAuditCompleted: 1,
|
|
442
|
-
},
|
|
443
|
-
},
|
|
444
|
-
];
|
|
445
|
-
const storeAudit = await aggregateStoreAudit( storeAuditQuery );
|
|
446
|
-
if ( storeAudit.length > 0 ) {
|
|
447
|
-
temp.inprogreseStores= storeAudit[0].inprogreseStores;
|
|
448
|
-
temp.completedStores = storeAudit[0].completedStores;
|
|
449
|
-
temp.auditInprogress = storeAudit[0].auditInprogress;
|
|
450
|
-
temp.reAuditInprogress = storeAudit[0].reAuditInprogress;
|
|
451
|
-
temp.draft = storeAudit[0].draft;
|
|
452
|
-
temp.assigned = storeAudit[0].assigned;
|
|
453
|
-
temp.notAssigned = storeAudit[0].exceptNoAssigned;
|
|
454
|
-
temp.auditCompleted = storeAudit[0].auditCompleted;
|
|
455
|
-
temp.reAuditCompleted = storeAudit[0].reAuditCompleted;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
return res.sendSuccess( { result: temp } );
|
|
459
|
-
} catch ( error ) {
|
|
460
|
-
const err = error.message || 'Internal Server Error';
|
|
461
|
-
logger.error( { error: error, message: req.body, function: 'summarySplit' } );
|
|
462
|
-
return res.sendError( err, 500 );
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
14
|
export async function reTrigger( req, res ) {
|
|
467
15
|
try {
|
|
468
16
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
package/src/docs/audit.docs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { auditStoreSchema, clientMetricsSchema, clientSchema, getDraftedDataSchema, getFileSchema, saveDraftSchema, saveSchema, storeMetricsSchema, userAuditHistorySchema, userMetricsSchema, userSchema, workSpaceSchema } from '../dtos/audit.dtos.js';
|
|
1
|
+
import { auditStoreSchema, clientMetricsSchema, clientSchema, getDraftedDataSchema, getFileSchema, overAllAuditSummarySchema, overViewCardSchema, overViewTableSchema, saveDraftSchema, saveSchema, storeMetricsSchema, summarySplitSchema, userAuditHistorySchema, userMetricsSchema, userSchema, workSpaceSchema } from '../dtos/audit.dtos.js';
|
|
2
2
|
import j2s from 'joi-to-swagger';
|
|
3
3
|
|
|
4
4
|
export const auditDocs = {
|
|
@@ -268,7 +268,7 @@ export const auditDocs = {
|
|
|
268
268
|
post: {
|
|
269
269
|
tags: [ 'Audit Metrics' ],
|
|
270
270
|
description: `Get list of user wise audit user details with date range`,
|
|
271
|
-
operationId: 'user-audit-history',
|
|
271
|
+
operationId: 'metrics/user-audit-history',
|
|
272
272
|
parameters: {},
|
|
273
273
|
requestBody: {
|
|
274
274
|
content: {
|
|
@@ -290,7 +290,7 @@ export const auditDocs = {
|
|
|
290
290
|
post: {
|
|
291
291
|
tags: [ 'Audit Metrics' ],
|
|
292
292
|
description: `Get list of client wise details with date range`,
|
|
293
|
-
operationId: 'client-metrics',
|
|
293
|
+
operationId: 'metrics/client-metrics',
|
|
294
294
|
parameters: {},
|
|
295
295
|
requestBody: {
|
|
296
296
|
content: {
|
|
@@ -312,7 +312,7 @@ export const auditDocs = {
|
|
|
312
312
|
post: {
|
|
313
313
|
tags: [ 'Audit Metrics' ],
|
|
314
314
|
description: `Get list of store wise details with date range and client Id`,
|
|
315
|
-
operationId: 'store-metrics',
|
|
315
|
+
operationId: 'metrics/store-metrics',
|
|
316
316
|
parameters: {},
|
|
317
317
|
requestBody: {
|
|
318
318
|
content: {
|
|
@@ -335,7 +335,7 @@ export const auditDocs = {
|
|
|
335
335
|
post: {
|
|
336
336
|
tags: [ 'Audit Metrics' ],
|
|
337
337
|
description: `Get list of file wise details with date range and users`,
|
|
338
|
-
operationId: 'user-metrics',
|
|
338
|
+
operationId: 'metrics/user-metrics',
|
|
339
339
|
parameters: {},
|
|
340
340
|
requestBody: {
|
|
341
341
|
content: {
|
|
@@ -353,5 +353,94 @@ export const auditDocs = {
|
|
|
353
353
|
},
|
|
354
354
|
},
|
|
355
355
|
},
|
|
356
|
+
'/v3/audit/metrics/overview-table': {
|
|
357
|
+
post: {
|
|
358
|
+
tags: [ 'Audit Metrics' ],
|
|
359
|
+
description: `Get overall user taken data with some filters `,
|
|
360
|
+
operationId: 'metrics/overview-table',
|
|
361
|
+
parameters: {},
|
|
362
|
+
requestBody: {
|
|
363
|
+
content: {
|
|
364
|
+
'application/json': {
|
|
365
|
+
schema: j2s( overViewTableSchema ).swagger,
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
responses: {
|
|
370
|
+
200: { description: 'Successful' },
|
|
371
|
+
401: { description: 'Unauthorized User' },
|
|
372
|
+
422: { description: 'Field Error' },
|
|
373
|
+
500: { description: 'Server Error' },
|
|
374
|
+
204: { description: 'Not Found' },
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
'/v3/audit/metrics/overall-audit-summary': {
|
|
379
|
+
post: {
|
|
380
|
+
tags: [ 'Audit Metrics' ],
|
|
381
|
+
description: `Get overall user taken data with some filters `,
|
|
382
|
+
operationId: 'metrics/overall-audit-summary',
|
|
383
|
+
parameters: {},
|
|
384
|
+
requestBody: {
|
|
385
|
+
content: {
|
|
386
|
+
'application/json': {
|
|
387
|
+
schema: j2s( overAllAuditSummarySchema ).swagger,
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
responses: {
|
|
392
|
+
200: { description: 'Successful' },
|
|
393
|
+
401: { description: 'Unauthorized User' },
|
|
394
|
+
422: { description: 'Field Error' },
|
|
395
|
+
500: { description: 'Server Error' },
|
|
396
|
+
204: { description: 'Not Found' },
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
},
|
|
356
400
|
|
|
401
|
+
'/v3/audit/metrics/overview-card': {
|
|
402
|
+
post: {
|
|
403
|
+
tags: [ 'Audit Metrics' ],
|
|
404
|
+
description: `Get overall high level audited files count`,
|
|
405
|
+
operationId: 'metrics/overview-card',
|
|
406
|
+
parameters: {},
|
|
407
|
+
requestBody: {
|
|
408
|
+
content: {
|
|
409
|
+
'application/json': {
|
|
410
|
+
schema: j2s( overViewCardSchema ).swagger,
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
responses: {
|
|
415
|
+
200: { description: 'Successful' },
|
|
416
|
+
401: { description: 'Unauthorized User' },
|
|
417
|
+
422: { description: 'Field Error' },
|
|
418
|
+
500: { description: 'Server Error' },
|
|
419
|
+
204: { description: 'Not Found' },
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
|
|
424
|
+
'/v3/audit/metrics/summary-split-up': {
|
|
425
|
+
post: {
|
|
426
|
+
tags: [ 'Audit Metrics' ],
|
|
427
|
+
description: `Get overall high level audited files count splitup`,
|
|
428
|
+
operationId: 'metrics/summary-split-up',
|
|
429
|
+
parameters: {},
|
|
430
|
+
requestBody: {
|
|
431
|
+
content: {
|
|
432
|
+
'application/json': {
|
|
433
|
+
schema: j2s( summarySplitSchema ).swagger,
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
responses: {
|
|
438
|
+
200: { description: 'Successful' },
|
|
439
|
+
401: { description: 'Unauthorized User' },
|
|
440
|
+
422: { description: 'Field Error' },
|
|
441
|
+
500: { description: 'Server Error' },
|
|
442
|
+
204: { description: 'Not Found' },
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
},
|
|
357
446
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
|
-
import { auditImageValidSchema, getAuditImagesSchema,
|
|
2
|
+
import { auditImageValidSchema, getAuditImagesSchema, reTriggerValidSchema } from '../dtos/auditMetrics.dtos.js';
|
|
3
3
|
|
|
4
4
|
export const auditMetricsDocs = {
|
|
5
5
|
|
|
@@ -27,94 +27,6 @@ export const auditMetricsDocs = {
|
|
|
27
27
|
},
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
'/v3/audit-metrics/overview-card': {
|
|
31
|
-
post: {
|
|
32
|
-
tags: [ 'Audit Metrics' ],
|
|
33
|
-
description: `Get overall high level audited files count`,
|
|
34
|
-
operationId: 'overview-card',
|
|
35
|
-
parameters: {},
|
|
36
|
-
requestBody: {
|
|
37
|
-
content: {
|
|
38
|
-
'application/json': {
|
|
39
|
-
schema: j2s( overViewCardSchema ).swagger,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
responses: {
|
|
44
|
-
200: { description: 'Successful' },
|
|
45
|
-
401: { description: 'Unauthorized User' },
|
|
46
|
-
422: { description: 'Field Error' },
|
|
47
|
-
500: { description: 'Server Error' },
|
|
48
|
-
204: { description: 'Not Found' },
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
'/v3/audit-metrics/summary-split-up': {
|
|
53
|
-
post: {
|
|
54
|
-
tags: [ 'Audit Metrics' ],
|
|
55
|
-
description: `Get overall high level audited files count splitup`,
|
|
56
|
-
operationId: 'summary-split-up',
|
|
57
|
-
parameters: {},
|
|
58
|
-
requestBody: {
|
|
59
|
-
content: {
|
|
60
|
-
'application/json': {
|
|
61
|
-
schema: j2s( summarySplitSchema ).swagger,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
responses: {
|
|
66
|
-
200: { description: 'Successful' },
|
|
67
|
-
401: { description: 'Unauthorized User' },
|
|
68
|
-
422: { description: 'Field Error' },
|
|
69
|
-
500: { description: 'Server Error' },
|
|
70
|
-
204: { description: 'Not Found' },
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
'/v3/audit-metrics/overview-table': {
|
|
75
|
-
post: {
|
|
76
|
-
tags: [ 'Audit Metrics' ],
|
|
77
|
-
description: `Get overall user taken data with some filters `,
|
|
78
|
-
operationId: 'overview-table',
|
|
79
|
-
parameters: {},
|
|
80
|
-
requestBody: {
|
|
81
|
-
content: {
|
|
82
|
-
'application/json': {
|
|
83
|
-
schema: j2s( overViewTableSchema ).swagger,
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
responses: {
|
|
88
|
-
200: { description: 'Successful' },
|
|
89
|
-
401: { description: 'Unauthorized User' },
|
|
90
|
-
422: { description: 'Field Error' },
|
|
91
|
-
500: { description: 'Server Error' },
|
|
92
|
-
204: { description: 'Not Found' },
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
'/v3/audit-metrics/overall-audit-summary': {
|
|
97
|
-
post: {
|
|
98
|
-
tags: [ 'Audit Metrics' ],
|
|
99
|
-
description: `Get overall user taken data with some filters `,
|
|
100
|
-
operationId: 'overall-audit-summary',
|
|
101
|
-
parameters: {},
|
|
102
|
-
requestBody: {
|
|
103
|
-
content: {
|
|
104
|
-
'application/json': {
|
|
105
|
-
schema: j2s( overAllAuditSummarySchema ).swagger,
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
responses: {
|
|
110
|
-
200: { description: 'Successful' },
|
|
111
|
-
401: { description: 'Unauthorized User' },
|
|
112
|
-
422: { description: 'Field Error' },
|
|
113
|
-
500: { description: 'Server Error' },
|
|
114
|
-
204: { description: 'Not Found' },
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
30
|
'/v3/audit-metrics/re-trigger': {
|
|
119
31
|
post: {
|
|
120
32
|
tags: [ 'Audit Metrics' ],
|
package/src/dtos/audit.dtos.js
CHANGED
|
@@ -226,3 +226,61 @@ export const userMetricsSchema = joi.object(
|
|
|
226
226
|
export const userMetricsValid = {
|
|
227
227
|
body: userMetricsSchema,
|
|
228
228
|
};
|
|
229
|
+
|
|
230
|
+
export const overViewTableSchema = joi.object(
|
|
231
|
+
{
|
|
232
|
+
fromDate: joi.string().required(),
|
|
233
|
+
toDate: joi.string().required(),
|
|
234
|
+
clientId: joi.array().optional(),
|
|
235
|
+
limit: joi.number().optional(),
|
|
236
|
+
offset: joi.number().optional(),
|
|
237
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
238
|
+
filterByStatus: joi.array().required(),
|
|
239
|
+
filterByModuleType: joi.array().optional(),
|
|
240
|
+
filterByAuditType: joi.array().optional(),
|
|
241
|
+
sortColumnName: joi.string().optional(),
|
|
242
|
+
sortBy: joi.number().optional(),
|
|
243
|
+
isExport: joi.boolean().optional(),
|
|
244
|
+
},
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
export const overViewTableValid = {
|
|
248
|
+
body: overViewTableSchema,
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export const overAllAuditSummarySchema = joi.object(
|
|
252
|
+
{
|
|
253
|
+
fromDate: joi.string().required(),
|
|
254
|
+
toDate: joi.string().required(),
|
|
255
|
+
clientId: joi.array().optional(),
|
|
256
|
+
moduleType: joi.array().required(),
|
|
257
|
+
},
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
export const overAllAuditSummaryValid = {
|
|
261
|
+
body: overAllAuditSummarySchema,
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
export const overViewCardSchema = joi.object(
|
|
265
|
+
{
|
|
266
|
+
fromDate: joi.string().required(),
|
|
267
|
+
toDate: joi.string().required(),
|
|
268
|
+
clientId: joi.array().optional(),
|
|
269
|
+
},
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
export const overViewCardValid = {
|
|
273
|
+
body: overViewCardSchema,
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export const summarySplitSchema = joi.object(
|
|
277
|
+
{
|
|
278
|
+
fromDate: joi.string().required(),
|
|
279
|
+
toDate: joi.string().required(),
|
|
280
|
+
clientId: joi.array().optional(),
|
|
281
|
+
},
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
export const summarySplitValid = {
|
|
285
|
+
body: summarySplitSchema,
|
|
286
|
+
};
|
|
@@ -14,64 +14,6 @@ export const getAuditImagesValid = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
export const overViewCardSchema = joi.object(
|
|
18
|
-
{
|
|
19
|
-
fromDate: joi.string().required(),
|
|
20
|
-
toDate: joi.string().required(),
|
|
21
|
-
clientId: joi.array().optional(),
|
|
22
|
-
},
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
export const overViewCardValid = {
|
|
26
|
-
body: overViewCardSchema,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const summarySplitSchema = joi.object(
|
|
30
|
-
{
|
|
31
|
-
fromDate: joi.string().required(),
|
|
32
|
-
toDate: joi.string().required(),
|
|
33
|
-
clientId: joi.array().optional(),
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
export const summarySplitValid = {
|
|
38
|
-
body: summarySplitSchema,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const overViewTableSchema = joi.object(
|
|
42
|
-
{
|
|
43
|
-
fromDate: joi.string().required(),
|
|
44
|
-
toDate: joi.string().required(),
|
|
45
|
-
clientId: joi.array().optional(),
|
|
46
|
-
limit: joi.number().optional(),
|
|
47
|
-
offset: joi.number().optional(),
|
|
48
|
-
searchValue: joi.string().optional().allow( '' ),
|
|
49
|
-
filterByStatus: joi.array().required(),
|
|
50
|
-
filterByType: joi.array().optional(),
|
|
51
|
-
filterByAuditType: joi.array().required(),
|
|
52
|
-
sortColumnName: joi.string().optional(),
|
|
53
|
-
sortBy: joi.number().optional(),
|
|
54
|
-
isExport: joi.boolean().optional(),
|
|
55
|
-
},
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
export const overViewTableValid = {
|
|
59
|
-
body: overViewTableSchema,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const overAllAuditSummarySchema = joi.object(
|
|
63
|
-
{
|
|
64
|
-
fromDate: joi.string().required(),
|
|
65
|
-
toDate: joi.string().required(),
|
|
66
|
-
clientId: joi.array().optional(),
|
|
67
|
-
moduleType: joi.string().required(),
|
|
68
|
-
},
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
export const overAllAuditSummaryValid = {
|
|
72
|
-
body: overAllAuditSummarySchema,
|
|
73
|
-
};
|
|
74
|
-
|
|
75
17
|
export const reTriggerValidSchema = joi.object(
|
|
76
18
|
{
|
|
77
19
|
fileDate: joi.string().required(),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { isExistsQueue, validateUserAudit } from '../validation/audit.validation.js';
|
|
3
3
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
4
|
-
import { auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, save, saveDraft, storeMetrics, userAuditHistory, userMetrics, workSpace } from '../controllers/audit.controllers.js';
|
|
5
|
-
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, saveDraftValid, saveValid, storeMetricsValid, userAuditHistoryValid, userMetricsValid, workSpaceValid } from '../dtos/audit.dtos.js';
|
|
4
|
+
import { auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard, overViewTable, save, saveDraft, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace } from '../controllers/audit.controllers.js';
|
|
5
|
+
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid, overViewTableValid, saveDraftValid, saveValid, storeMetricsValid, summarySplitValid, userAuditHistoryValid, userMetricsValid, workSpaceValid } from '../dtos/audit.dtos.js';
|
|
6
6
|
|
|
7
7
|
export const auditRouter = express.Router();
|
|
8
8
|
|
|
@@ -24,6 +24,12 @@ auditRouter.post( '/metrics/user-audit-history', isAllowedSessionHandler, valida
|
|
|
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/overview-table', isAllowedSessionHandler, validate( overViewTableValid ), overViewTable );
|
|
28
|
+
auditRouter.post( '/metrics/overall-audit-summary', isAllowedSessionHandler, validate( overAllAuditSummaryValid ), overAllAuditSummary );
|
|
27
29
|
|
|
28
30
|
|
|
31
|
+
// hold
|
|
32
|
+
auditRouter.post( '/metrics/overview-card', isAllowedSessionHandler, validate( overViewCardValid ), overViewCard );
|
|
33
|
+
auditRouter.post( '/metrics/summary-split-up', isAllowedSessionHandler, validate( summarySplitValid ), summarySplit );
|
|
34
|
+
|
|
29
35
|
export default auditRouter;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
4
|
-
import { auditImages,
|
|
5
|
-
import { auditImageValid,
|
|
4
|
+
import { auditImages, reTrigger } from '../controllers/auditMetrics.controllers.js';
|
|
5
|
+
import { auditImageValid, reTriggerValid, viewLogValid } from '../dtos/auditMetrics.dtos.js';
|
|
6
6
|
import { isAuditDocumentExist, isAuditInputFolderExist } from '../validation/audit.validation.js';
|
|
7
7
|
|
|
8
8
|
export const auditMetricsRouter = express.Router();
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
auditMetricsRouter.post( '/overview-card', isAllowedSessionHandler, validate( overViewCardValid ), overViewCard );
|
|
12
|
-
auditMetricsRouter.post( '/summary-split-up', isAllowedSessionHandler, validate( summarySplitValid ), summarySplit );
|
|
13
|
-
auditMetricsRouter.post( '/overview-table', isAllowedSessionHandler, validate( overViewTableValid ), overViewTable );
|
|
14
|
-
auditMetricsRouter.post( '/overall-audit-summary', isAllowedSessionHandler, validate( overAllAuditSummaryValid ), overAllAuditSummary );
|
|
15
11
|
auditMetricsRouter.post( '/re-trigger', isAllowedSessionHandler, validate( reTriggerValid ), isAuditDocumentExist, isAuditInputFolderExist, reTrigger );
|
|
16
12
|
auditMetricsRouter.get( '/audit-images', isAllowedSessionHandler, validate( auditImageValid ), isAuditInputFolderExist, auditImages );
|
|
17
13
|
auditMetricsRouter.post( '/view-log', isAllowedSessionHandler, validate( viewLogValid ), isAuditInputFolderExist, auditImages );
|