tango-app-api-audit 3.4.0-alpha.2 → 3.4.0-alpha.4
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
|
@@ -1159,6 +1159,7 @@ export async function saveBinary( req, res ) {
|
|
|
1159
1159
|
let update={
|
|
1160
1160
|
auditStatus: 'completed',
|
|
1161
1161
|
answer: inputData.answer,
|
|
1162
|
+
userCommands: inputData.userComments || '',
|
|
1162
1163
|
};
|
|
1163
1164
|
let updatDataunattended= await updateOneBinaryAuditModel( unattendedquery, update );
|
|
1164
1165
|
if ( updatDataunattended.modifiedCount==0 ) {
|
|
@@ -1480,3 +1481,1135 @@ export async function userAuditHistory( req, res ) {
|
|
|
1480
1481
|
return res.sendError( err, 500 );
|
|
1481
1482
|
}
|
|
1482
1483
|
}
|
|
1484
|
+
|
|
1485
|
+
export async function clientMetrics( req, res ) {
|
|
1486
|
+
try {
|
|
1487
|
+
const inputData = req.body;
|
|
1488
|
+
const limit = inputData.limit || 10;
|
|
1489
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
1490
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
1491
|
+
let filter = [
|
|
1492
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
1493
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
1494
|
+
{ moduleType: { $eq: inputData.moduleType } },
|
|
1495
|
+
];
|
|
1496
|
+
|
|
1497
|
+
let storeAuditFilter = [
|
|
1498
|
+
{ $eq: [ '$clientId', '$$clientId' ] },
|
|
1499
|
+
{ $eq: [ '$fileDate', '$$fileDate' ] },
|
|
1500
|
+
{ $eq: [ '$moduleType', inputData.moduleType ] },
|
|
1501
|
+
|
|
1502
|
+
];
|
|
1503
|
+
|
|
1504
|
+
if ( inputData?.filterByClient?.length> 0 ) {
|
|
1505
|
+
filter.push(
|
|
1506
|
+
{ clientId: { $in: inputData.filterByClient } },
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
const query = [
|
|
1510
|
+
{
|
|
1511
|
+
$match: {
|
|
1512
|
+
$and: filter,
|
|
1513
|
+
},
|
|
1514
|
+
},
|
|
1515
|
+
{
|
|
1516
|
+
$group: {
|
|
1517
|
+
_id: { clientId: '$clientId', fileDate: '$fileDate', moduleType: '$moduleType' },
|
|
1518
|
+
fileDate: { $last: '$fileDate' },
|
|
1519
|
+
clientId: { $last: '$clientId' },
|
|
1520
|
+
clientName: { $last: '$clientName' },
|
|
1521
|
+
moduleType: { $last: '$moduleType' },
|
|
1522
|
+
installedStore: { $last: '$installedStore' },
|
|
1523
|
+
queueName: { $last: '$queueName' },
|
|
1524
|
+
totalFilesCount: { $sum: 1 },
|
|
1525
|
+
},
|
|
1526
|
+
},
|
|
1527
|
+
{
|
|
1528
|
+
$project: {
|
|
1529
|
+
fileDate: 1,
|
|
1530
|
+
clientId: 1,
|
|
1531
|
+
clientName: 1,
|
|
1532
|
+
queueName: 1,
|
|
1533
|
+
installedStore: 1,
|
|
1534
|
+
totalFilesCount: 1,
|
|
1535
|
+
moduleType: 1,
|
|
1536
|
+
notAssignedCount: { $ifNull: [ 0, 0 ] },
|
|
1537
|
+
clientStatus: { $ifNull: [ '', '' ] },
|
|
1538
|
+
},
|
|
1539
|
+
},
|
|
1540
|
+
{
|
|
1541
|
+
$lookup: {
|
|
1542
|
+
'from': 'binaryAudit',
|
|
1543
|
+
'let': { clientId: '$clientId', fileDate: '$fileDate', totalAuditFiles: '$totalFilesCount' },
|
|
1544
|
+
'pipeline': [
|
|
1545
|
+
|
|
1546
|
+
{
|
|
1547
|
+
$match: {
|
|
1548
|
+
$expr: {
|
|
1549
|
+
$and: storeAuditFilter,
|
|
1550
|
+
},
|
|
1551
|
+
},
|
|
1552
|
+
},
|
|
1553
|
+
{
|
|
1554
|
+
$project: {
|
|
1555
|
+
completedStores: { $cond: [ { $eq: [ '$status', 'completed' ] }, 1, 0 ] },
|
|
1556
|
+
notAssignedStores: { $cond: [ { $eq: [ '$status', 'not_assign' ] }, 1, 0 ] },
|
|
1557
|
+
inprogressStores: { $cond: [ { $in: [ '$status', [ 'inprogress', 'drafted', 'assigned' ] ] }, 1, 0 ] },
|
|
1558
|
+
},
|
|
1559
|
+
},
|
|
1560
|
+
{
|
|
1561
|
+
$group: {
|
|
1562
|
+
_id: { clientId: '$clientId', fileDate: '$fileDate' },
|
|
1563
|
+
completedStores: { $sum: '$completedStores' },
|
|
1564
|
+
inprogressStores: { $sum: '$inprogressStores' },
|
|
1565
|
+
notAssignedStores: { $sum: '$notAssignedStores' },
|
|
1566
|
+
fileCount: { $sum: 1 },
|
|
1567
|
+
},
|
|
1568
|
+
},
|
|
1569
|
+
{
|
|
1570
|
+
$project: {
|
|
1571
|
+
_id: 0,
|
|
1572
|
+
completedStores: 1,
|
|
1573
|
+
inprogressStores: 1,
|
|
1574
|
+
notAssignedStores: 1,
|
|
1575
|
+
fileCount: { $ifNull: [ '$fileCount', 0 ] },
|
|
1576
|
+
completionPercentage: { $ifNull: [
|
|
1577
|
+
{
|
|
1578
|
+
$round: [ {
|
|
1579
|
+
$multiply: [
|
|
1580
|
+
100, {
|
|
1581
|
+
$divide: [
|
|
1582
|
+
'$completedStores', '$$totalAuditFiles',
|
|
1583
|
+
],
|
|
1584
|
+
},
|
|
1585
|
+
],
|
|
1586
|
+
}, 1 ],
|
|
1587
|
+
|
|
1588
|
+
},
|
|
1589
|
+
0,
|
|
1590
|
+
],
|
|
1591
|
+
},
|
|
1592
|
+
},
|
|
1593
|
+
},
|
|
1594
|
+
], 'as': 'binaryAudit',
|
|
1595
|
+
},
|
|
1596
|
+
},
|
|
1597
|
+
{
|
|
1598
|
+
$unwind: {
|
|
1599
|
+
path: '$binaryAudit',
|
|
1600
|
+
preserveNullAndEmptyArrays: true,
|
|
1601
|
+
},
|
|
1602
|
+
},
|
|
1603
|
+
{
|
|
1604
|
+
$project: {
|
|
1605
|
+
_id: 0,
|
|
1606
|
+
fileDate: 1,
|
|
1607
|
+
clientId: 1,
|
|
1608
|
+
clientName: 1,
|
|
1609
|
+
totalFilesCount: 1,
|
|
1610
|
+
moduleType: 1,
|
|
1611
|
+
installedStore: 1,
|
|
1612
|
+
// notAssignedStores: '$binaryAudit.notAssignedStores',
|
|
1613
|
+
inprogressStoresCount: '$binaryAudit.inprogressStores',
|
|
1614
|
+
// fileCount: '$binaryAudit.fileCount',
|
|
1615
|
+
notAssignedCount: { $subtract: [ '$totalFilesCount', { $subtract: [ { $ifNull: [ '$binaryAudit.fileCount', 0 ] }, { $ifNull: [ '$binaryAudit.notAssignedStores', 0 ] } ] } ] },
|
|
1616
|
+
clientStatus: { $cond: [ { $eq: [ { $ifNull: [ '$binaryAudit.fileCount', 0 ] }, 0 ] }, 'not-taken', { $cond: [ { $gte: [ '$binaryAudit.completedStores', '$totalFilesCount' ] }, 'completed', 'pending' ] } ] }, // { $cond: [ { $or: [ { $gt: [ '$notAssignedCount', 0 ] }, { $gt: [ '$binaryAudit.notAssignedStores', 0 ] } ] }
|
|
1617
|
+
completedStores: '$binaryAudit.completedStores',
|
|
1618
|
+
completionPercentage: '$binaryAudit.completionPercentage',
|
|
1619
|
+
|
|
1620
|
+
},
|
|
1621
|
+
},
|
|
1622
|
+
];
|
|
1623
|
+
|
|
1624
|
+
if ( inputData?.filterByStatus?.length> 0 ) {
|
|
1625
|
+
query.push(
|
|
1626
|
+
{
|
|
1627
|
+
$match: { clientStatus: { $in: inputData.filterByStatus } },
|
|
1628
|
+
},
|
|
1629
|
+
|
|
1630
|
+
);
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
1634
|
+
query.push( {
|
|
1635
|
+
$match: {
|
|
1636
|
+
$or: [
|
|
1637
|
+
{ clientId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1638
|
+
{ clientName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1639
|
+
{ moduleType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1640
|
+
{ clientStatus: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1641
|
+
],
|
|
1642
|
+
|
|
1643
|
+
},
|
|
1644
|
+
} );
|
|
1645
|
+
}
|
|
1646
|
+
if ( inputData.sortColumnName ) {
|
|
1647
|
+
const sortBy = inputData.sortBy || -1;
|
|
1648
|
+
const sortColumn = inputData.sortColumnName;
|
|
1649
|
+
query.push( {
|
|
1650
|
+
$sort: { [sortColumn]: sortBy },
|
|
1651
|
+
},
|
|
1652
|
+
);
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
const count = await aggregateTraxAuditData( query );
|
|
1656
|
+
logger.info( { count: count } );
|
|
1657
|
+
if ( count.length == 0 ) {
|
|
1658
|
+
return res.sendError( 'No Data Found', 204 );
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
query.push(
|
|
1662
|
+
{ $skip: offset },
|
|
1663
|
+
{ $limit: limit },
|
|
1664
|
+
);
|
|
1665
|
+
if ( inputData.isExport ) {
|
|
1666
|
+
query.push(
|
|
1667
|
+
{
|
|
1668
|
+
$project: {
|
|
1669
|
+
'_id': 0,
|
|
1670
|
+
'File Date': '$fileDate',
|
|
1671
|
+
'Client Name': '$clientName',
|
|
1672
|
+
'Client Id': '$clientId',
|
|
1673
|
+
'Product Type': '$moduleType',
|
|
1674
|
+
'Completed Percentage': '$completionPercentage',
|
|
1675
|
+
'Installed Stores': '$installedStore',
|
|
1676
|
+
'Audit Stores': '$totalFilesCount',
|
|
1677
|
+
'Inprogress Stores': '$inprogressStoresCount',
|
|
1678
|
+
'Not Assigned': '$notAssignedCount',
|
|
1679
|
+
// 'Not Assigned Stores': '$notAssignedStores',
|
|
1680
|
+
'Completed': '$completedStores',
|
|
1681
|
+
'Status': '$clientStatus',
|
|
1682
|
+
},
|
|
1683
|
+
},
|
|
1684
|
+
);
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
logger.info( { query: query } );
|
|
1688
|
+
const result = await aggregateTraxAuditData( query );
|
|
1689
|
+
if ( result.length == 0 ) {
|
|
1690
|
+
return res.sendError( 'No Data Found', 204 );
|
|
1691
|
+
}
|
|
1692
|
+
if ( inputData.isExport ) {
|
|
1693
|
+
await download( result, res );
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
1697
|
+
} catch ( error ) {
|
|
1698
|
+
const err = error.error || 'Internal Server Error';
|
|
1699
|
+
logger.info( { error: error, message: req.body, function: 'clientMetrics' } );
|
|
1700
|
+
return res.sendError( err, 500 );
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
export async function storeMetrics( req, res ) {
|
|
1705
|
+
try {
|
|
1706
|
+
const inputData = req.body;
|
|
1707
|
+
const limit = inputData.limit || 10;
|
|
1708
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
1709
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
1710
|
+
let filter = [
|
|
1711
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
1712
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
1713
|
+
{ moduleType: { $eq: inputData.moduleType } },
|
|
1714
|
+
|
|
1715
|
+
];
|
|
1716
|
+
if ( inputData.filterByClientId && inputData.filterByClientId?.length > 0 ) {
|
|
1717
|
+
filter.push( { clientId: { $in: inputData.filterByClientId } } );
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
if ( inputData.filterByStoreId && inputData.filterByStoreId?.length > 0 ) {
|
|
1721
|
+
filter.push( { storeId: { $in: inputData.filterByStoreId } } );
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
if ( inputData.filterByStatus && inputData.filterByStatus?.length > 0 ) {
|
|
1725
|
+
filter.push( { status: { $in: inputData.filterByStatus } } );
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
if ( inputData.filterByAuditType && inputData.filterByAuditType?.length > 0 ) {
|
|
1729
|
+
filter.push( { auditType: { $in: inputData.filterByAuditType } } );
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
|
|
1733
|
+
const query = [
|
|
1734
|
+
{
|
|
1735
|
+
$match: {
|
|
1736
|
+
$and: filter,
|
|
1737
|
+
},
|
|
1738
|
+
},
|
|
1739
|
+
|
|
1740
|
+
{
|
|
1741
|
+
$lookup: {
|
|
1742
|
+
from: 'stores',
|
|
1743
|
+
let: { storeId: '$storeId' },
|
|
1744
|
+
pipeline: [
|
|
1745
|
+
{
|
|
1746
|
+
$match: {
|
|
1747
|
+
$expr: {
|
|
1748
|
+
$eq: [ '$storeId', '$$storeId' ],
|
|
1749
|
+
},
|
|
1750
|
+
},
|
|
1751
|
+
},
|
|
1752
|
+
{
|
|
1753
|
+
$project: {
|
|
1754
|
+
_id: 0,
|
|
1755
|
+
storeName: 1,
|
|
1756
|
+
},
|
|
1757
|
+
},
|
|
1758
|
+
], as: 'stores',
|
|
1759
|
+
},
|
|
1760
|
+
},
|
|
1761
|
+
{
|
|
1762
|
+
$unwind: {
|
|
1763
|
+
path: '$stores',
|
|
1764
|
+
preserveNullAndEmptyArrays: true,
|
|
1765
|
+
},
|
|
1766
|
+
},
|
|
1767
|
+
{
|
|
1768
|
+
$project: {
|
|
1769
|
+
_id: 0,
|
|
1770
|
+
fileDate: 1,
|
|
1771
|
+
storeId: 1,
|
|
1772
|
+
storeName: '$stores.storeName',
|
|
1773
|
+
clientName: '',
|
|
1774
|
+
clientId: 1,
|
|
1775
|
+
moduleType: 1,
|
|
1776
|
+
tempId: 1,
|
|
1777
|
+
streamName: 1,
|
|
1778
|
+
question: 1,
|
|
1779
|
+
answer: 1,
|
|
1780
|
+
// userId: {
|
|
1781
|
+
// $arrayElemAt: [ '$userId', { $subtract: [ { $size: '$userId' }, 1 ] } ], //need to check if no data
|
|
1782
|
+
// },
|
|
1783
|
+
auditType: 1,
|
|
1784
|
+
beforeCount: 1,
|
|
1785
|
+
afterCount: { $ifNull: [ '$afterCount', null ] },
|
|
1786
|
+
accuracy: { $cond: [ { $eq: [ '$status', 'completed' ] }, { $round: [
|
|
1787
|
+
{
|
|
1788
|
+
$multiply: [ { $divide: [ '$afterCount', '$beforeCount' ] }, 100 ],
|
|
1789
|
+
}, 1,
|
|
1790
|
+
],
|
|
1791
|
+
}, null ] },
|
|
1792
|
+
timeSpent: 1,
|
|
1793
|
+
status: 1,
|
|
1794
|
+
},
|
|
1795
|
+
},
|
|
1796
|
+
{
|
|
1797
|
+
$lookup: {
|
|
1798
|
+
from: 'users',
|
|
1799
|
+
let: { userId: '$userId' },
|
|
1800
|
+
pipeline: [
|
|
1801
|
+
{
|
|
1802
|
+
$match: {
|
|
1803
|
+
$expr: {
|
|
1804
|
+
$eq: [ '$_id', '$$userId' ],
|
|
1805
|
+
},
|
|
1806
|
+
},
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
$project: {
|
|
1810
|
+
_id: 0,
|
|
1811
|
+
userName: 1,
|
|
1812
|
+
userEmail: '$email',
|
|
1813
|
+
},
|
|
1814
|
+
},
|
|
1815
|
+
], as: 'users',
|
|
1816
|
+
},
|
|
1817
|
+
},
|
|
1818
|
+
{
|
|
1819
|
+
$unwind: {
|
|
1820
|
+
path: '$users',
|
|
1821
|
+
preserveNullAndEmptyArrays: true,
|
|
1822
|
+
},
|
|
1823
|
+
},
|
|
1824
|
+
{
|
|
1825
|
+
$lookup: {
|
|
1826
|
+
from: 'clients',
|
|
1827
|
+
let: { clientId: '$clientId' },
|
|
1828
|
+
pipeline: [
|
|
1829
|
+
{
|
|
1830
|
+
$match: {
|
|
1831
|
+
$expr: {
|
|
1832
|
+
$eq: [ '$clientId', '$$clientId' ],
|
|
1833
|
+
},
|
|
1834
|
+
},
|
|
1835
|
+
},
|
|
1836
|
+
{
|
|
1837
|
+
$project: {
|
|
1838
|
+
_id: 0,
|
|
1839
|
+
clientName: 1,
|
|
1840
|
+
},
|
|
1841
|
+
},
|
|
1842
|
+
], as: 'client',
|
|
1843
|
+
},
|
|
1844
|
+
},
|
|
1845
|
+
{
|
|
1846
|
+
$unwind: {
|
|
1847
|
+
path: '$client',
|
|
1848
|
+
preserveNullAndEmptyArrays: true,
|
|
1849
|
+
},
|
|
1850
|
+
},
|
|
1851
|
+
{
|
|
1852
|
+
$project: {
|
|
1853
|
+
_id: 0,
|
|
1854
|
+
fileDate: 1,
|
|
1855
|
+
storeId: 1,
|
|
1856
|
+
storeName: 1,
|
|
1857
|
+
userName: '$users.userName',
|
|
1858
|
+
userEmail: '$users.userEmail',
|
|
1859
|
+
clientId: 1,
|
|
1860
|
+
clientName: '$client.clientName',
|
|
1861
|
+
tempId: 1,
|
|
1862
|
+
streamName: 1,
|
|
1863
|
+
question: 1,
|
|
1864
|
+
answer: 1,
|
|
1865
|
+
moduleType: 1,
|
|
1866
|
+
auditType: 1,
|
|
1867
|
+
beforeCount: 1,
|
|
1868
|
+
afterCount: { $ifNull: [ '$afterCount', null ] },
|
|
1869
|
+
accuracy: { $cond: [ { $eq: [ '$status', 'completed' ] }, { $round: [
|
|
1870
|
+
{
|
|
1871
|
+
$multiply: [ { $divide: [ '$afterCount', '$beforeCount' ] }, 100 ],
|
|
1872
|
+
}, 1,
|
|
1873
|
+
],
|
|
1874
|
+
}, null ] },
|
|
1875
|
+
timeSpent: {
|
|
1876
|
+
|
|
1877
|
+
$cond: [
|
|
1878
|
+
{ $lt: [ '$timeSpent', 60 ] }, // Case 1: If less than 60 seconds
|
|
1879
|
+
{ $concat: [ { $toString: '$timeSpent' }, ' sec' ] },
|
|
1880
|
+
{
|
|
1881
|
+
$cond: [
|
|
1882
|
+
{ $lt: [ '$timeSpent', 3600 ] }, // Case 2: If less than 60 minutes (3600 seconds)
|
|
1883
|
+
{
|
|
1884
|
+
$concat: [
|
|
1885
|
+
{ $toString: { $round: [ { $divide: [ '$timeSpent', 60 ] }, 1 ] } }, // Convert to minutes
|
|
1886
|
+
' min',
|
|
1887
|
+
],
|
|
1888
|
+
},
|
|
1889
|
+
{
|
|
1890
|
+
$concat: [
|
|
1891
|
+
{ $toString: { $round: [ { $divide: [ '$timeSpent', 3600 ] }, 1 ] } }, // Convert to hours
|
|
1892
|
+
' hr',
|
|
1893
|
+
],
|
|
1894
|
+
},
|
|
1895
|
+
],
|
|
1896
|
+
},
|
|
1897
|
+
],
|
|
1898
|
+
|
|
1899
|
+
},
|
|
1900
|
+
status: 1,
|
|
1901
|
+
},
|
|
1902
|
+
},
|
|
1903
|
+
|
|
1904
|
+
];
|
|
1905
|
+
|
|
1906
|
+
if ( inputData.searchValue && inputData.searchValue !== '' ) {
|
|
1907
|
+
query.push( {
|
|
1908
|
+
$match: {
|
|
1909
|
+
$or: [
|
|
1910
|
+
{ clientId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1911
|
+
{ clientName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1912
|
+
{ storeId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1913
|
+
{ storeName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1914
|
+
{ userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1915
|
+
{ status: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1916
|
+
{ auditType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1917
|
+
{ moduleType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1918
|
+
{ tempId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1919
|
+
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1920
|
+
{ answer: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1921
|
+
],
|
|
1922
|
+
},
|
|
1923
|
+
} );
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
if ( inputData.sortColumnName ) {
|
|
1927
|
+
const sortBy = inputData.sortBy || -1;
|
|
1928
|
+
const sortColumn = inputData.sortColumnName;
|
|
1929
|
+
query.push( {
|
|
1930
|
+
$sort: { [sortColumn]: sortBy },
|
|
1931
|
+
},
|
|
1932
|
+
);
|
|
1933
|
+
}
|
|
1934
|
+
const count = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
1935
|
+
|
|
1936
|
+
if ( count.length == 0 ) {
|
|
1937
|
+
return res.sendError( 'No data Found', 204 );
|
|
1938
|
+
}
|
|
1939
|
+
if ( !inputData.isExport ) {
|
|
1940
|
+
query.push( {
|
|
1941
|
+
$skip: offset,
|
|
1942
|
+
},
|
|
1943
|
+
{
|
|
1944
|
+
$limit: limit,
|
|
1945
|
+
} );
|
|
1946
|
+
} else {
|
|
1947
|
+
query.push( { $limit: 10000 } );
|
|
1948
|
+
}
|
|
1949
|
+
const result = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
1950
|
+
if ( inputData.isExport ) {
|
|
1951
|
+
const exportdata = [];
|
|
1952
|
+
result.forEach( ( element ) => {
|
|
1953
|
+
if ( element.moduleType == 'zone' ) {
|
|
1954
|
+
exportdata.push( {
|
|
1955
|
+
'File Date': element.fileDate,
|
|
1956
|
+
'Store ID': element.storeId,
|
|
1957
|
+
'Store Name': element.storeName,
|
|
1958
|
+
'Client Id': element.clientId,
|
|
1959
|
+
'Client Name': element.clientName,
|
|
1960
|
+
'Customer Id': element.tempId,
|
|
1961
|
+
'Question': element.question,
|
|
1962
|
+
'Answer': element.answer,
|
|
1963
|
+
'User Name': element.userName,
|
|
1964
|
+
'User Email': element.userEmail,
|
|
1965
|
+
'Audit Type': element.auditType,
|
|
1966
|
+
'Accuracy': element.accuracy,
|
|
1967
|
+
'Time Spent': element.timeSpent,
|
|
1968
|
+
'Status': element.status,
|
|
1969
|
+
} );
|
|
1970
|
+
} else {
|
|
1971
|
+
exportdata.push( {
|
|
1972
|
+
'File Date': element.fileDate,
|
|
1973
|
+
'Store ID': element.storeId,
|
|
1974
|
+
'Store Name': element.storeName,
|
|
1975
|
+
'Client Id': element.clientId,
|
|
1976
|
+
'Client Name': element.clientName,
|
|
1977
|
+
'User Name': element.userName,
|
|
1978
|
+
'Customer Id': element.tempId,
|
|
1979
|
+
'Question': element.question,
|
|
1980
|
+
'Answer': element.answer,
|
|
1981
|
+
'User Email': element.userEmail,
|
|
1982
|
+
'Audit Type': element.auditType,
|
|
1983
|
+
'Accuracy': element.accuracy,
|
|
1984
|
+
'Time Spent': element.timeSpent,
|
|
1985
|
+
'Status': element.status,
|
|
1986
|
+
} );
|
|
1987
|
+
}
|
|
1988
|
+
} );
|
|
1989
|
+
await download( exportdata, res );
|
|
1990
|
+
return;
|
|
1991
|
+
}
|
|
1992
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
1993
|
+
} catch ( error ) {
|
|
1994
|
+
const err = error.message || 'Internal Server Error';
|
|
1995
|
+
logger.error( { error: error, data: req.body, function: 'storeMetrics' } );
|
|
1996
|
+
return res.sendError( err, 500 );
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
export async function userMetrics( req, res ) {
|
|
2001
|
+
try {
|
|
2002
|
+
const inputData = req.body;
|
|
2003
|
+
const limit = inputData.limit || 10;
|
|
2004
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
2005
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
2006
|
+
const dateRangeUpdatedAt = await getDateWithCustomizeTime( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
2007
|
+
let filter = [
|
|
2008
|
+
{ moduleType: { $eq: inputData.moduleType } },
|
|
2009
|
+
];
|
|
2010
|
+
if ( inputData.dateType == 'auditedDate' ) {
|
|
2011
|
+
filter.push(
|
|
2012
|
+
{ updatedAt: { $gte: dateRangeUpdatedAt.start } },
|
|
2013
|
+
{ updatedAt: { $lte: dateRangeUpdatedAt.end } },
|
|
2014
|
+
|
|
2015
|
+
);
|
|
2016
|
+
} else {
|
|
2017
|
+
filter.push(
|
|
2018
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
2019
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
2020
|
+
|
|
2021
|
+
);
|
|
2022
|
+
}
|
|
2023
|
+
if ( inputData?.filterByStatus?.length> 0 ) {
|
|
2024
|
+
filter.push(
|
|
2025
|
+
{ auditStatus: { $in: inputData.filterByStatus } },
|
|
2026
|
+
);
|
|
2027
|
+
}
|
|
2028
|
+
if ( inputData?.filterByUser?.length> 0 ) {
|
|
2029
|
+
const temp = inputData.filterByUser.map( ( item ) => new mongoose.Types.ObjectId( item ) );
|
|
2030
|
+
logger.info( { temp: temp } );
|
|
2031
|
+
filter.push(
|
|
2032
|
+
{ userId: { $in: temp } },
|
|
2033
|
+
);
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
const query = [
|
|
2037
|
+
{
|
|
2038
|
+
$match: {
|
|
2039
|
+
$and: filter,
|
|
2040
|
+
},
|
|
2041
|
+
},
|
|
2042
|
+
{
|
|
2043
|
+
$project: {
|
|
2044
|
+
userId: 1,
|
|
2045
|
+
fileDate: 1,
|
|
2046
|
+
startTime: 1,
|
|
2047
|
+
endTime: 1,
|
|
2048
|
+
streamName: 1,
|
|
2049
|
+
tempId: 1,
|
|
2050
|
+
question: 1,
|
|
2051
|
+
answer: 1,
|
|
2052
|
+
totalCompletedFiles: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, 1, 0 ] },
|
|
2053
|
+
beforeCount: 1,
|
|
2054
|
+
afterCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$afterCount', 0 ] },
|
|
2055
|
+
},
|
|
2056
|
+
},
|
|
2057
|
+
{
|
|
2058
|
+
$group: {
|
|
2059
|
+
_id: { userId: '$userId', fileDate: '$fileDate' },
|
|
2060
|
+
userId: { $first: '$userId' },
|
|
2061
|
+
fileDate: { $first: '$fileDate' },
|
|
2062
|
+
totalCompletedFiles: { $sum: '$totalCompletedFiles' },
|
|
2063
|
+
beforeCount: { $sum: '$beforeCount' },
|
|
2064
|
+
afterCount: { $sum: '$afterCount' },
|
|
2065
|
+
checkIntime: { $first: '$startTime' },
|
|
2066
|
+
checkOutTime: { $last: '$endTime' },
|
|
2067
|
+
streamName: { $last: '$streamName' },
|
|
2068
|
+
tempId: { $last: '$tempId' },
|
|
2069
|
+
question: { $last: '$question' },
|
|
2070
|
+
answer: { $last: '$answer' },
|
|
2071
|
+
|
|
2072
|
+
},
|
|
2073
|
+
},
|
|
2074
|
+
{
|
|
2075
|
+
$project: {
|
|
2076
|
+
_id: 0,
|
|
2077
|
+
userId: 1,
|
|
2078
|
+
fileDate: 1,
|
|
2079
|
+
totalCompletedFiles: 1,
|
|
2080
|
+
beforeCount: 1,
|
|
2081
|
+
afterCount: 1,
|
|
2082
|
+
streamName: 1,
|
|
2083
|
+
tempId: 1,
|
|
2084
|
+
question: 1,
|
|
2085
|
+
answer: 1,
|
|
2086
|
+
// mappingPerc: { $round: [
|
|
2087
|
+
// { $multiply: [
|
|
2088
|
+
// { $divide: [ '$afterCount', '$beforeCount' ] }, 100,
|
|
2089
|
+
// ] }, 2,
|
|
2090
|
+
// ] },
|
|
2091
|
+
checkIntime: 1,
|
|
2092
|
+
checkOutTime: 1,
|
|
2093
|
+
differenceInSeconds: {
|
|
2094
|
+
$divide: [ { $subtract: [ '$checkOutTime', '$checkIntime' ] }, 1000 ],
|
|
2095
|
+
},
|
|
2096
|
+
},
|
|
2097
|
+
},
|
|
2098
|
+
{
|
|
2099
|
+
$project: {
|
|
2100
|
+
userId: 1,
|
|
2101
|
+
fileDate: 1,
|
|
2102
|
+
totalCompletedFiles: 1,
|
|
2103
|
+
beforeCount: 1,
|
|
2104
|
+
afterCount: 1,
|
|
2105
|
+
checkIntime: 1,
|
|
2106
|
+
checkOutTime: 1,
|
|
2107
|
+
// mappingPerc: 1,
|
|
2108
|
+
streamName: 1,
|
|
2109
|
+
tempId: 1,
|
|
2110
|
+
question: 1,
|
|
2111
|
+
answer: 1,
|
|
2112
|
+
hours: { $floor: { $divide: [ '$differenceInSeconds', 3600 ] } },
|
|
2113
|
+
minutes: { $floor: { $divide: [ { $mod: [ '$differenceInSeconds', 3600 ] }, 60 ] } },
|
|
2114
|
+
seconds: { $mod: [ '$differenceInSeconds', 60 ] },
|
|
2115
|
+
},
|
|
2116
|
+
},
|
|
2117
|
+
{
|
|
2118
|
+
$project: {
|
|
2119
|
+
event: 1,
|
|
2120
|
+
userId: 1,
|
|
2121
|
+
fileDate: 1,
|
|
2122
|
+
totalCompletedFiles: 1,
|
|
2123
|
+
beforeCount: 1,
|
|
2124
|
+
afterCount: 1,
|
|
2125
|
+
checkIntime: 1,
|
|
2126
|
+
checkOutTime: 1,
|
|
2127
|
+
// mappingPerc: 1,
|
|
2128
|
+
streamName: 1,
|
|
2129
|
+
tempId: 1,
|
|
2130
|
+
question: 1,
|
|
2131
|
+
answer: 1,
|
|
2132
|
+
hours: {
|
|
2133
|
+
$cond: {
|
|
2134
|
+
if: { $lt: [ '$hours', 10 ] },
|
|
2135
|
+
then: { $concat: [ '0', { $toString: { $round: [ '$hours', 0 ] } } ] },
|
|
2136
|
+
else: { $toString: { $round: [ '$hours', 0 ] } },
|
|
2137
|
+
},
|
|
2138
|
+
},
|
|
2139
|
+
minutes: {
|
|
2140
|
+
$cond: {
|
|
2141
|
+
if: { $lt: [ '$minutes', 10 ] },
|
|
2142
|
+
then: { $concat: [ '0', { $toString: { $round: [ '$minutes', 0 ] } } ] },
|
|
2143
|
+
else: { $toString: { $round: [ '$minutes', 0 ] } },
|
|
2144
|
+
},
|
|
2145
|
+
},
|
|
2146
|
+
seconds: {
|
|
2147
|
+
$cond: {
|
|
2148
|
+
if: { $lt: [ '$seconds', 10 ] },
|
|
2149
|
+
then: { $concat: [ '0', { $toString: { $round: [ '$seconds', 0 ] } } ] },
|
|
2150
|
+
else: { $toString: { $round: [ '$seconds', 0 ] } },
|
|
2151
|
+
},
|
|
2152
|
+
},
|
|
2153
|
+
|
|
2154
|
+
},
|
|
2155
|
+
},
|
|
2156
|
+
{
|
|
2157
|
+
$project: {
|
|
2158
|
+
event: 1,
|
|
2159
|
+
userId: 1,
|
|
2160
|
+
fileDate: 1,
|
|
2161
|
+
totalCompletedFiles: 1,
|
|
2162
|
+
beforeCount: 1,
|
|
2163
|
+
afterCount: 1,
|
|
2164
|
+
checkIntime: 1,
|
|
2165
|
+
zoneName: 1,
|
|
2166
|
+
checkOutTime: 1,
|
|
2167
|
+
// mappingPerc: 1,
|
|
2168
|
+
streamName: 1,
|
|
2169
|
+
tempId: 1,
|
|
2170
|
+
question: 1,
|
|
2171
|
+
answer: 1,
|
|
2172
|
+
workingHours: {
|
|
2173
|
+
$concat: [ '$hours', ':', '$minutes', ':', '$seconds' ],
|
|
2174
|
+
},
|
|
2175
|
+
},
|
|
2176
|
+
},
|
|
2177
|
+
{
|
|
2178
|
+
$lookup: {
|
|
2179
|
+
from: 'users',
|
|
2180
|
+
let: { userId: '$userId' },
|
|
2181
|
+
pipeline: [
|
|
2182
|
+
{
|
|
2183
|
+
$match: {
|
|
2184
|
+
$expr: {
|
|
2185
|
+
$eq: [ '$_id', '$$userId' ],
|
|
2186
|
+
},
|
|
2187
|
+
},
|
|
2188
|
+
},
|
|
2189
|
+
{
|
|
2190
|
+
$project: {
|
|
2191
|
+
_id: 0,
|
|
2192
|
+
userName: 1,
|
|
2193
|
+
},
|
|
2194
|
+
},
|
|
2195
|
+
], as: 'userInfo',
|
|
2196
|
+
},
|
|
2197
|
+
},
|
|
2198
|
+
{
|
|
2199
|
+
$unwind: {
|
|
2200
|
+
path: '$userInfo', preserveNullAndEmptyArrays: true,
|
|
2201
|
+
},
|
|
2202
|
+
},
|
|
2203
|
+
{
|
|
2204
|
+
$project: {
|
|
2205
|
+
event: 1,
|
|
2206
|
+
userName: '$userInfo.userName',
|
|
2207
|
+
userId: 1,
|
|
2208
|
+
fileDate: 1,
|
|
2209
|
+
totalCompletedFiles: 1,
|
|
2210
|
+
beforeCount: 1,
|
|
2211
|
+
afterCount: 1,
|
|
2212
|
+
// mappingPerc: 1,
|
|
2213
|
+
streamName: 1,
|
|
2214
|
+
tempId: 1,
|
|
2215
|
+
question: 1,
|
|
2216
|
+
answer: 1,
|
|
2217
|
+
checkIntime: {
|
|
2218
|
+
$dateToString: {
|
|
2219
|
+
format: '%Y-%m-%d %H:%M:%S',
|
|
2220
|
+
date: '$checkIntime',
|
|
2221
|
+
timezone: 'Asia/Kolkata',
|
|
2222
|
+
},
|
|
2223
|
+
},
|
|
2224
|
+
checkOutTime: {
|
|
2225
|
+
$dateToString: {
|
|
2226
|
+
format: '%Y-%m-%d %H:%M:%S',
|
|
2227
|
+
date: '$checkOutTime',
|
|
2228
|
+
timezone: 'Asia/Kolkata',
|
|
2229
|
+
},
|
|
2230
|
+
},
|
|
2231
|
+
workingHours: 1,
|
|
2232
|
+
},
|
|
2233
|
+
},
|
|
2234
|
+
];
|
|
2235
|
+
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
2236
|
+
query.push( {
|
|
2237
|
+
$match: {
|
|
2238
|
+
$or: [
|
|
2239
|
+
{ userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2240
|
+
{ clientName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2241
|
+
],
|
|
2242
|
+
|
|
2243
|
+
},
|
|
2244
|
+
} );
|
|
2245
|
+
}
|
|
2246
|
+
if ( inputData.sortColumnName ) {
|
|
2247
|
+
const sortBy = inputData.sortBy || -1;
|
|
2248
|
+
const sortColumn = inputData.sortColumnName;
|
|
2249
|
+
query.push( {
|
|
2250
|
+
$sort: { [sortColumn]: sortBy },
|
|
2251
|
+
},
|
|
2252
|
+
);
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
const count = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2256
|
+
if ( count.length == 0 ) {
|
|
2257
|
+
return res.sendError( 'No Data Found', 204 );
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
query.push(
|
|
2261
|
+
{ $skip: offset },
|
|
2262
|
+
{ $limit: limit },
|
|
2263
|
+
);
|
|
2264
|
+
if ( inputData.isExport ) {
|
|
2265
|
+
query.push(
|
|
2266
|
+
{
|
|
2267
|
+
$project: {
|
|
2268
|
+
'_id': 0,
|
|
2269
|
+
'File Date': '$fileDate',
|
|
2270
|
+
'User Name': '$userName',
|
|
2271
|
+
'Total Completed Files Count': '$totalCompletedFiles',
|
|
2272
|
+
'Total Before Count': '$beforeCount',
|
|
2273
|
+
'Total After Count': '$afterCount',
|
|
2274
|
+
'check Intime': '$checkIntime',
|
|
2275
|
+
'check OutTime': '$checkOutTime',
|
|
2276
|
+
'working Hours': '$workingHours',
|
|
2277
|
+
'Mapping Percentage': '$mappingPerc',
|
|
2278
|
+
'Customer ID': '$tempId',
|
|
2279
|
+
'Stream Name': '$streamName',
|
|
2280
|
+
'Question': '$question',
|
|
2281
|
+
'Answer': '$answer',
|
|
2282
|
+
},
|
|
2283
|
+
},
|
|
2284
|
+
);
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
|
|
2288
|
+
const result = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2289
|
+
if ( inputData.isExport ) {
|
|
2290
|
+
await download( result, res );
|
|
2291
|
+
return;
|
|
2292
|
+
}
|
|
2293
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
2294
|
+
} catch ( error ) {
|
|
2295
|
+
const err = error.error || 'Internal Server Error';
|
|
2296
|
+
logger.info( { error: error, message: req.body, function: 'userMetrics' } );
|
|
2297
|
+
return res.sendError( err, 500 );
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
export async function pendingSummaryTable( req, res ) {
|
|
2302
|
+
try {
|
|
2303
|
+
const inputData = req.body;
|
|
2304
|
+
const limit = inputData.limit || 10;
|
|
2305
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
2306
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
2307
|
+
let filters =[
|
|
2308
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
2309
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
2310
|
+
{ auditStatus: { $ne: 'completed' } },
|
|
2311
|
+
{ moduleType: { $eq: inputData.moduleType } },
|
|
2312
|
+
|
|
2313
|
+
];
|
|
2314
|
+
|
|
2315
|
+
if ( inputData.clientId.length > 0 ) {
|
|
2316
|
+
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
if ( inputData.filterByAuditType.length > 0 ) {
|
|
2320
|
+
filters.push( { auditType: { $in: inputData.filterByAuditType } } );
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
if ( inputData.filterByStatus.length > 0 ) {
|
|
2324
|
+
filters.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
2325
|
+
}
|
|
2326
|
+
const query =[
|
|
2327
|
+
{
|
|
2328
|
+
$match: {
|
|
2329
|
+
$and: filters,
|
|
2330
|
+
},
|
|
2331
|
+
|
|
2332
|
+
},
|
|
2333
|
+
{
|
|
2334
|
+
$project: {
|
|
2335
|
+
_id: 0,
|
|
2336
|
+
storeId: 1,
|
|
2337
|
+
streamName: 1,
|
|
2338
|
+
tempId: 1,
|
|
2339
|
+
question: 1,
|
|
2340
|
+
answer: 1,
|
|
2341
|
+
userCommands: 1,
|
|
2342
|
+
fileDate: 1,
|
|
2343
|
+
moduleType: 1,
|
|
2344
|
+
beforeCount: 1,
|
|
2345
|
+
startTime: { $dateToString: {
|
|
2346
|
+
format: '%Y-%m-%d %H:%M:%S',
|
|
2347
|
+
date: '$startTime',
|
|
2348
|
+
timezone: 'Asia/Kolkata',
|
|
2349
|
+
},
|
|
2350
|
+
|
|
2351
|
+
},
|
|
2352
|
+
auditType: 1,
|
|
2353
|
+
auditStatus: 1,
|
|
2354
|
+
userId: 1,
|
|
2355
|
+
},
|
|
2356
|
+
},
|
|
2357
|
+
{
|
|
2358
|
+
$lookup: {
|
|
2359
|
+
from: 'users',
|
|
2360
|
+
let: { userId: '$userId' },
|
|
2361
|
+
pipeline: [
|
|
2362
|
+
{
|
|
2363
|
+
$match: {
|
|
2364
|
+
$expr: {
|
|
2365
|
+
$eq: [ '$_id', '$$userId' ],
|
|
2366
|
+
},
|
|
2367
|
+
},
|
|
2368
|
+
},
|
|
2369
|
+
{
|
|
2370
|
+
$project: {
|
|
2371
|
+
userName: 1,
|
|
2372
|
+
userEmail: '$email',
|
|
2373
|
+
},
|
|
2374
|
+
},
|
|
2375
|
+
], as: 'user',
|
|
2376
|
+
},
|
|
2377
|
+
},
|
|
2378
|
+
{
|
|
2379
|
+
$unwind: {
|
|
2380
|
+
path: '$user',
|
|
2381
|
+
preserveNullAndEmptyArrays: true,
|
|
2382
|
+
},
|
|
2383
|
+
},
|
|
2384
|
+
{
|
|
2385
|
+
$project: {
|
|
2386
|
+
storeId: 1,
|
|
2387
|
+
streamName: 1,
|
|
2388
|
+
tempId: 1,
|
|
2389
|
+
question: 1,
|
|
2390
|
+
answer: 1,
|
|
2391
|
+
userCommands: 1,
|
|
2392
|
+
fileDate: 1,
|
|
2393
|
+
moduleType: 1,
|
|
2394
|
+
beforeCount: 1,
|
|
2395
|
+
startTime: 1,
|
|
2396
|
+
endTime: 1,
|
|
2397
|
+
auditType: 1,
|
|
2398
|
+
auditStatus: 1,
|
|
2399
|
+
userName: '$user.userName',
|
|
2400
|
+
userEmail: '$user.userEmail',
|
|
2401
|
+
|
|
2402
|
+
},
|
|
2403
|
+
},
|
|
2404
|
+
];
|
|
2405
|
+
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
2406
|
+
query.push( {
|
|
2407
|
+
$match: {
|
|
2408
|
+
$or: [
|
|
2409
|
+
{ storeId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2410
|
+
{ fileDate: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2411
|
+
{ auditType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2412
|
+
{ auditStatus: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2413
|
+
{ userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2414
|
+
{ userEmail: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2415
|
+
],
|
|
2416
|
+
|
|
2417
|
+
},
|
|
2418
|
+
} );
|
|
2419
|
+
}
|
|
2420
|
+
if ( inputData.sortColumnName ) {
|
|
2421
|
+
const sortBy = inputData.sortBy || -1;
|
|
2422
|
+
const sortColumn = inputData.sortColumnName;
|
|
2423
|
+
query.push( {
|
|
2424
|
+
$sort: { [sortColumn]: sortBy },
|
|
2425
|
+
},
|
|
2426
|
+
);
|
|
2427
|
+
}
|
|
2428
|
+
const count = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2429
|
+
if ( count.length == 0 ) {
|
|
2430
|
+
return res.sendError( 'No Data Found', 204 );
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
if ( inputData.isExport ) {
|
|
2434
|
+
query.push( { $limit: 10000 } );
|
|
2435
|
+
} else {
|
|
2436
|
+
query.push( {
|
|
2437
|
+
$skip: offset,
|
|
2438
|
+
},
|
|
2439
|
+
{
|
|
2440
|
+
$limit: limit,
|
|
2441
|
+
} );
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
const result = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2445
|
+
if ( inputData.isExport ) {
|
|
2446
|
+
const exportdata = [];
|
|
2447
|
+
result.forEach( ( element ) => {
|
|
2448
|
+
if ( element.moduleType == 'zone' ) {
|
|
2449
|
+
exportdata.push( {
|
|
2450
|
+
'Store ID': element.storeId,
|
|
2451
|
+
'Stream Name': element.streamName,
|
|
2452
|
+
'Customer ID': element.tempId,
|
|
2453
|
+
'Question': question,
|
|
2454
|
+
'Answer': element.answer,
|
|
2455
|
+
'userComments': element.userCommands,
|
|
2456
|
+
'File Date': element.fileDate,
|
|
2457
|
+
'Product Type': element.moduleType,
|
|
2458
|
+
'Audit Type': element.auditType,
|
|
2459
|
+
'Before Count': element.beforeCount,
|
|
2460
|
+
'Start Time': element.startTime,
|
|
2461
|
+
'User Name': element.userName,
|
|
2462
|
+
'User Email': element.userEmail,
|
|
2463
|
+
'Status': element.auditStatus,
|
|
2464
|
+
} );
|
|
2465
|
+
} else {
|
|
2466
|
+
exportdata.push( {
|
|
2467
|
+
'Store ID': element.storeId,
|
|
2468
|
+
'Stream Name': element.streamName,
|
|
2469
|
+
'Customer ID': element.tempId,
|
|
2470
|
+
'Question': question,
|
|
2471
|
+
'Answer': element.answer,
|
|
2472
|
+
'userComments': element.userCommands,
|
|
2473
|
+
'File Date': element.fileDate,
|
|
2474
|
+
'Product Type': element.moduleType,
|
|
2475
|
+
'Audit Type': element.auditType,
|
|
2476
|
+
'Before Count': element.beforeCount,
|
|
2477
|
+
'Start Time': element.startTime,
|
|
2478
|
+
'User Name': element.userName,
|
|
2479
|
+
'User Email': element.userEmail,
|
|
2480
|
+
'Status': element.auditStatus,
|
|
2481
|
+
} );
|
|
2482
|
+
}
|
|
2483
|
+
} );
|
|
2484
|
+
await download( exportdata, res );
|
|
2485
|
+
return;
|
|
2486
|
+
}
|
|
2487
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
2488
|
+
} catch ( error ) {
|
|
2489
|
+
const err = error.message || 'Internal Server Error';
|
|
2490
|
+
logger.error( { error: error, message: req.body, function: 'pendingSummaryTable' } );
|
|
2491
|
+
return res.sendError( err, 500 );
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
export async function overAllAuditSummary( req, res ) {
|
|
2496
|
+
try {
|
|
2497
|
+
const inputData = req.body;
|
|
2498
|
+
let temp = {
|
|
2499
|
+
installedStores: 0,
|
|
2500
|
+
auditStores: 0,
|
|
2501
|
+
inprogressStores: 0,
|
|
2502
|
+
completedStores: 0,
|
|
2503
|
+
auditInprogress: 0,
|
|
2504
|
+
reAuditInprogress: 0,
|
|
2505
|
+
draft: 0,
|
|
2506
|
+
assigned: 0,
|
|
2507
|
+
notAssigned: 0,
|
|
2508
|
+
auditCompleted: 0,
|
|
2509
|
+
reAuditCompleted: 0,
|
|
2510
|
+
|
|
2511
|
+
};
|
|
2512
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
2513
|
+
let filters =[
|
|
2514
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
2515
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
2516
|
+
{ moduleType: { $eq: inputData.moduleType },
|
|
2517
|
+
},
|
|
2518
|
+
];
|
|
2519
|
+
if ( inputData.clientId.length > 0 ) {
|
|
2520
|
+
filters.push( { clientId: { $in: inputData.clientId } } );
|
|
2521
|
+
}
|
|
2522
|
+
const storeQuery = inputData.clientId.length? { 'edge.firstFile': true, 'clientId': { $in: inputData. clientId } } : { 'edge.firstFile': true };
|
|
2523
|
+
temp.installedStores = await countDocumentsStore( storeQuery );
|
|
2524
|
+
const auditClientDataQuery =[
|
|
2525
|
+
{
|
|
2526
|
+
$match: {
|
|
2527
|
+
$and: filters,
|
|
2528
|
+
},
|
|
2529
|
+
|
|
2530
|
+
},
|
|
2531
|
+
{
|
|
2532
|
+
$group: {
|
|
2533
|
+
_id: null,
|
|
2534
|
+
totalFilesCount: { $sum: 1 },
|
|
2535
|
+
},
|
|
2536
|
+
},
|
|
2537
|
+
{
|
|
2538
|
+
$project: {
|
|
2539
|
+
_id: 0,
|
|
2540
|
+
totalFilesCount: 1,
|
|
2541
|
+
},
|
|
2542
|
+
},
|
|
2543
|
+
];
|
|
2544
|
+
const auditClientData = await aggregateAuditStoreData( auditClientDataQuery );
|
|
2545
|
+
if ( auditClientData.length >0 ) {
|
|
2546
|
+
temp.auditStores = auditClientData[0].totalFilesCount;
|
|
2547
|
+
}
|
|
2548
|
+
const storeAuditQuery =[
|
|
2549
|
+
{
|
|
2550
|
+
$match: {
|
|
2551
|
+
$and: filters,
|
|
2552
|
+
},
|
|
2553
|
+
|
|
2554
|
+
},
|
|
2555
|
+
{
|
|
2556
|
+
$project: {
|
|
2557
|
+
completedStores: { $cond: [ { $eq: [ '$status', 'completed' ] }, 1, 0 ] },
|
|
2558
|
+
auditInprogress: { $cond: [ { $and: [ { $in: [ '$status', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
|
|
2559
|
+
reAuditInprogress: { $cond: [ { $and: [ { $in: [ '$status', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
|
|
2560
|
+
draft: { $cond: [ { $eq: [ '$status', 'drafted' ] }, 1, 0 ] },
|
|
2561
|
+
assigned: { $cond: [ { $eq: [ '$status', 'assigned' ] }, 1, 0 ] },
|
|
2562
|
+
exceptNoAssigned: { $cond: { if: { $not: { $in: [ '$status', [ 'skipped', 'not_assign' ] ] } }, then: 1, else: 0 } },
|
|
2563
|
+
auditCompleted: { $cond: [ { $and: [ { $in: [ '$status', [ 'completed' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
|
|
2564
|
+
reAuditCompleted: { $cond: [ { $and: [ { $in: [ '$status', [ 'completed' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
|
|
2565
|
+
|
|
2566
|
+
|
|
2567
|
+
},
|
|
2568
|
+
},
|
|
2569
|
+
{
|
|
2570
|
+
$group: {
|
|
2571
|
+
_id: null,
|
|
2572
|
+
completedStores: { $sum: '$completedStores' },
|
|
2573
|
+
auditInprogress: { $sum: '$auditInprogress' },
|
|
2574
|
+
reAuditInprogress: { $sum: '$reAuditInprogress' },
|
|
2575
|
+
draft: { $sum: '$draft' },
|
|
2576
|
+
assigned: { $sum: '$assigned' },
|
|
2577
|
+
exceptNoAssigned: { $sum: '$exceptNoAssigned' },
|
|
2578
|
+
auditCompleted: { $sum: '$auditCompleted' },
|
|
2579
|
+
reAuditCompleted: { $sum: '$reAuditCompleted' },
|
|
2580
|
+
},
|
|
2581
|
+
},
|
|
2582
|
+
{
|
|
2583
|
+
$project: {
|
|
2584
|
+
completedStores: 1,
|
|
2585
|
+
inprogressStores: { $subtract: [ temp.auditStores, '$completedStores' ] },
|
|
2586
|
+
auditInprogress: 1,
|
|
2587
|
+
reAuditInprogress: 1,
|
|
2588
|
+
draft: 1,
|
|
2589
|
+
assigned: 1,
|
|
2590
|
+
exceptNoAssigned: { $subtract: [ temp.auditStores, '$exceptNoAssigned' ] },
|
|
2591
|
+
auditCompleted: 1,
|
|
2592
|
+
reAuditCompleted: 1,
|
|
2593
|
+
},
|
|
2594
|
+
},
|
|
2595
|
+
];
|
|
2596
|
+
const storeAudit = await aggregateStoreAudit( storeAuditQuery );
|
|
2597
|
+
if ( storeAudit.length > 0 ) {
|
|
2598
|
+
temp.inprogressStores= storeAudit[0].inprogressStores;
|
|
2599
|
+
temp.completedStores = storeAudit[0].completedStores;
|
|
2600
|
+
temp.auditInprogress = storeAudit[0].auditInprogress;
|
|
2601
|
+
temp.reAuditInprogress = storeAudit[0].reAuditInprogress;
|
|
2602
|
+
temp.draft = storeAudit[0].draft;
|
|
2603
|
+
temp.assigned = storeAudit[0].assigned;
|
|
2604
|
+
temp.notAssigned = storeAudit[0].exceptNoAssigned;
|
|
2605
|
+
temp.auditCompleted = storeAudit[0].auditCompleted;
|
|
2606
|
+
temp.reAuditCompleted = storeAudit[0].reAuditCompleted;
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
return res.sendSuccess( { result: temp } );
|
|
2610
|
+
} catch ( error ) {
|
|
2611
|
+
const err = error.message || 'Internal Server Error';
|
|
2612
|
+
logger.error( { error: error, message: req.body, function: 'overAllAuditSummary' } );
|
|
2613
|
+
return res.sendError( err, 500 );
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
|
-
import { getFileSchema, userAuditHistorySchema, workSpaceSchema, saveSchema } from '../dtos/traxAudit.dtos.js';
|
|
2
|
+
import { getFileSchema, userAuditHistorySchema, workSpaceSchema, saveSchema, clientMetricsSchema, storeMetricsSchema, userMetricsSchema, pendingSummaryTableSchema } from '../dtos/traxAudit.dtos.js';
|
|
3
3
|
|
|
4
4
|
export const traxAuditDocs = {
|
|
5
5
|
|
|
@@ -111,4 +111,93 @@ export const traxAuditDocs = {
|
|
|
111
111
|
},
|
|
112
112
|
},
|
|
113
113
|
},
|
|
114
|
+
'/v3/trax-audit/metrics/client-metrics': {
|
|
115
|
+
post: {
|
|
116
|
+
tags: [ 'Trax Audit' ],
|
|
117
|
+
description: `Get list of client wise details with date range`,
|
|
118
|
+
operationId: 'metrics/client-metrics',
|
|
119
|
+
parameters: {},
|
|
120
|
+
requestBody: {
|
|
121
|
+
content: {
|
|
122
|
+
'application/json': {
|
|
123
|
+
schema: j2s( clientMetricsSchema ).swagger,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
responses: {
|
|
128
|
+
200: { description: 'Successful' },
|
|
129
|
+
401: { description: 'Unauthorized User' },
|
|
130
|
+
422: { description: 'Field Error' },
|
|
131
|
+
500: { description: 'Server Error' },
|
|
132
|
+
204: { description: 'Not Found' },
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
'/v3/trax-audit/metrics/store-metrics': {
|
|
138
|
+
post: {
|
|
139
|
+
tags: [ 'Trax Audit' ],
|
|
140
|
+
description: `Get list of store wise details with date range and client Id`,
|
|
141
|
+
operationId: 'metrics/store-metrics',
|
|
142
|
+
parameters: {},
|
|
143
|
+
requestBody: {
|
|
144
|
+
content: {
|
|
145
|
+
'application/json': {
|
|
146
|
+
schema: j2s( storeMetricsSchema ).swagger,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
responses: {
|
|
151
|
+
200: { description: 'Successful' },
|
|
152
|
+
401: { description: 'Unauthorized User' },
|
|
153
|
+
422: { description: 'Field Error' },
|
|
154
|
+
500: { description: 'Server Error' },
|
|
155
|
+
204: { description: 'Not Found' },
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
'/v3/trax-audit/metrics/user-metrics': {
|
|
160
|
+
post: {
|
|
161
|
+
tags: [ 'Trax Audit' ],
|
|
162
|
+
description: `Get list of file wise details with date range and users`,
|
|
163
|
+
operationId: 'metrics/user-metrics',
|
|
164
|
+
parameters: {},
|
|
165
|
+
requestBody: {
|
|
166
|
+
content: {
|
|
167
|
+
'application/json': {
|
|
168
|
+
schema: j2s( userMetricsSchema ).swagger,
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
responses: {
|
|
173
|
+
200: { description: 'Successful' },
|
|
174
|
+
401: { description: 'Unauthorized User' },
|
|
175
|
+
422: { description: 'Field Error' },
|
|
176
|
+
500: { description: 'Server Error' },
|
|
177
|
+
204: { description: 'Not Found' },
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
'/v3/trax-audit/metrics/pending-summary-table': {
|
|
182
|
+
post: {
|
|
183
|
+
tags: [ 'Trax Audit' ],
|
|
184
|
+
description: `Get overall user taken data with some filters `,
|
|
185
|
+
operationId: 'metrics/pending-summary-table',
|
|
186
|
+
parameters: {},
|
|
187
|
+
requestBody: {
|
|
188
|
+
content: {
|
|
189
|
+
'application/json': {
|
|
190
|
+
schema: j2s( pendingSummaryTableSchema ).swagger,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
responses: {
|
|
195
|
+
200: { description: 'Successful' },
|
|
196
|
+
401: { description: 'Unauthorized User' },
|
|
197
|
+
422: { description: 'Field Error' },
|
|
198
|
+
500: { description: 'Server Error' },
|
|
199
|
+
204: { description: 'Not Found' },
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
},
|
|
114
203
|
};
|
|
@@ -73,6 +73,7 @@ export const saveSchema = joi.object(
|
|
|
73
73
|
question: joi.string().optional(),
|
|
74
74
|
streamName: joi.string().optional(),
|
|
75
75
|
answer: joi.string().required(),
|
|
76
|
+
userComments: joi.string().required(),
|
|
76
77
|
},
|
|
77
78
|
);
|
|
78
79
|
|
|
@@ -121,3 +122,99 @@ export const userAuditHistorySchema = joi.object(
|
|
|
121
122
|
export const userAuditHistoryValid = {
|
|
122
123
|
body: userAuditHistorySchema,
|
|
123
124
|
};
|
|
125
|
+
|
|
126
|
+
export const clientMetricsSchema = joi.object(
|
|
127
|
+
{
|
|
128
|
+
fromDate: joi.string().required(),
|
|
129
|
+
toDate: joi.string().required(),
|
|
130
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
131
|
+
moduleType: joi.string().required(),
|
|
132
|
+
filterByClient: joi.array().required(),
|
|
133
|
+
filterByStatus: joi.array().optional(),
|
|
134
|
+
sortColumnName: joi.string().optional(),
|
|
135
|
+
sortBy: joi.number().optional(),
|
|
136
|
+
limit: joi.number().optional(),
|
|
137
|
+
offset: joi.number().optional(),
|
|
138
|
+
isExport: joi.boolean().optional(),
|
|
139
|
+
},
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
export const clientMetricsValid = {
|
|
143
|
+
body: clientMetricsSchema,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const storeMetricsSchema = joi.object(
|
|
147
|
+
{
|
|
148
|
+
fromDate: joi.string().required(),
|
|
149
|
+
toDate: joi.string().required(),
|
|
150
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
151
|
+
filterByClientId: joi.array().required(),
|
|
152
|
+
filterByStoreId: joi.array().optional(),
|
|
153
|
+
filterByStatus: joi.array().optional(),
|
|
154
|
+
filterByAuditType: joi.array().optional(),
|
|
155
|
+
moduleType: joi.string().required(),
|
|
156
|
+
sortColumnName: joi.string().optional(),
|
|
157
|
+
sortBy: joi.number().optional(),
|
|
158
|
+
limit: joi.number().optional(),
|
|
159
|
+
offset: joi.number().optional(),
|
|
160
|
+
isExport: joi.boolean().optional(),
|
|
161
|
+
},
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
export const storeMetricsValid = {
|
|
165
|
+
body: storeMetricsSchema,
|
|
166
|
+
};
|
|
167
|
+
export const userMetricsSchema = joi.object(
|
|
168
|
+
{
|
|
169
|
+
fromDate: joi.string().required(),
|
|
170
|
+
toDate: joi.string().required(),
|
|
171
|
+
dateType: joi.string().required(),
|
|
172
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
173
|
+
filterByUser: joi.array().optional(),
|
|
174
|
+
moduleType: joi.string().optional(),
|
|
175
|
+
filterByStatus: joi.array().optional(),
|
|
176
|
+
sortColumnName: joi.string().optional(),
|
|
177
|
+
sortBy: joi.number().optional(),
|
|
178
|
+
limit: joi.number().optional(),
|
|
179
|
+
offset: joi.number().optional(),
|
|
180
|
+
isExport: joi.boolean().optional(),
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
export const userMetricsValid = {
|
|
185
|
+
body: userMetricsSchema,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export const pendingSummaryTableSchema = joi.object(
|
|
189
|
+
{
|
|
190
|
+
fromDate: joi.string().required(),
|
|
191
|
+
toDate: joi.string().required(),
|
|
192
|
+
clientId: joi.array().optional(),
|
|
193
|
+
limit: joi.number().optional(),
|
|
194
|
+
offset: joi.number().optional(),
|
|
195
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
196
|
+
filterByStatus: joi.array().required(),
|
|
197
|
+
moduleType: joi.string().required(),
|
|
198
|
+
filterByAuditType: joi.array().optional(),
|
|
199
|
+
sortColumnName: joi.string().optional(),
|
|
200
|
+
sortBy: joi.number().optional(),
|
|
201
|
+
isExport: joi.boolean().optional(),
|
|
202
|
+
},
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
export const pendingSummaryTableValid = {
|
|
206
|
+
body: pendingSummaryTableSchema,
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export const overAllAuditSummarySchema = joi.object(
|
|
210
|
+
{
|
|
211
|
+
fromDate: joi.string().required(),
|
|
212
|
+
toDate: joi.string().required(),
|
|
213
|
+
clientId: joi.array().optional(),
|
|
214
|
+
moduleType: joi.string().required(),
|
|
215
|
+
},
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
export const overAllAuditSummaryValid = {
|
|
219
|
+
body: overAllAuditSummarySchema,
|
|
220
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
3
|
-
import { getDetectionFileValid, getFileValid, userAuditHistoryValid, workSpaceValid, saveValid } from '../dtos/traxAudit.dtos.js';
|
|
3
|
+
import { getDetectionFileValid, getFileValid, userAuditHistoryValid, workSpaceValid, saveValid, clientMetricsValid, storeMetricsValid, userMetricsValid, pendingSummaryTableValid, overAllAuditSummaryValid } from '../dtos/traxAudit.dtos.js';
|
|
4
4
|
import { isExistsQueue } from '../validation/audit.validation.js';
|
|
5
|
-
import { getAuditFile, getDetectionAuditFile, saveBinary, userAuditHistory, workSpace } from '../controllers/traxAudit.controllers.js';
|
|
5
|
+
import { clientMetrics, getAuditFile, getDetectionAuditFile, overAllAuditSummary, pendingSummaryTable, saveBinary, storeMetrics, userAuditHistory, userMetrics, workSpace } from '../controllers/traxAudit.controllers.js';
|
|
6
6
|
import { validateBinaryAudit } from '../validation/traxAuditValidation.js';
|
|
7
7
|
|
|
8
8
|
export const traxAuditRouter = Router();
|
|
@@ -17,10 +17,15 @@ traxAuditRouter.post( '/work-space', isAllowedSessionHandler, validate( workSpac
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
// Y/n
|
|
20
|
-
traxAuditRouter.get( '/get-file', isAllowedSessionHandler, validate( getFileValid ), isExistsQueue, getAuditFile );
|
|
21
|
-
traxAuditRouter.post( '/save-binary-audit', isAllowedSessionHandler, validate( saveValid ), validateBinaryAudit, saveBinary );
|
|
22
|
-
|
|
23
|
-
export default traxAuditRouter;
|
|
20
|
+
traxAuditRouter.get( '/get-file', isAllowedSessionHandler, validate( getFileValid ), isExistsQueue, getAuditFile );
|
|
21
|
+
traxAuditRouter.post( '/save-binary-audit', isAllowedSessionHandler, validate( saveValid ), validateBinaryAudit, saveBinary );
|
|
24
22
|
|
|
25
23
|
// metrcis
|
|
26
24
|
traxAuditRouter.post( '/metrics/user-audit-history', isAllowedSessionHandler, validate( userAuditHistoryValid ), userAuditHistory );
|
|
25
|
+
traxAuditRouter.post( '/metrics/client-metrics', isAllowedSessionHandler, validate( clientMetricsValid ), clientMetrics );
|
|
26
|
+
traxAuditRouter.post( '/metrics/store-metrics', isAllowedSessionHandler, validate( storeMetricsValid ), storeMetrics );
|
|
27
|
+
traxAuditRouter.post( '/metrics/user-metrics', isAllowedSessionHandler, validate( userMetricsValid ), userMetrics );
|
|
28
|
+
traxAuditRouter.post( '/metrics/pending-summary-table', isAllowedSessionHandler, validate( pendingSummaryTableValid ), pendingSummaryTable );
|
|
29
|
+
traxAuditRouter.post( '/metrics/overall-audit-summary', isAllowedSessionHandler, validate( overAllAuditSummaryValid ), overAllAuditSummary );
|
|
30
|
+
|
|
31
|
+
export default traxAuditRouter;
|