tango-app-api-audit 1.0.52 → 1.0.53
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 +1 -1
- package/src/controllers/audit.controllers.js +228 -4
- package/src/controllers/auditMetrics.controllers.js +0 -182
- package/src/docs/audit.docs.js +23 -1
- package/src/docs/auditMetrics.docs.js +2 -23
- package/src/dtos/audit.dtos.js +20 -0
- package/src/dtos/auditMetrics.dtos.js +0 -18
- package/src/routes/audit.routes.js +3 -2
- package/src/routes/auditMetrics.routes.js +3 -3
package/package.json
CHANGED
|
@@ -1022,7 +1022,7 @@ export async function workSpace( req, res ) {
|
|
|
1022
1022
|
);
|
|
1023
1023
|
let totalStores = 0;
|
|
1024
1024
|
for ( let i = 0; i < merge.length; i++ ) {
|
|
1025
|
-
totalStores = merge[i]?.
|
|
1025
|
+
totalStores = merge[i]?.totalCount || 0;
|
|
1026
1026
|
|
|
1027
1027
|
const pending = await listQueue( merge[i].queueName );
|
|
1028
1028
|
|
|
@@ -1041,7 +1041,7 @@ export async function workSpace( req, res ) {
|
|
|
1041
1041
|
Number( merge[i].clientAsignedCount ) :
|
|
1042
1042
|
0 ) :
|
|
1043
1043
|
0,
|
|
1044
|
-
totalCount: merge[i].
|
|
1044
|
+
totalCount: merge[i].totalCount,
|
|
1045
1045
|
queueName: merge[i].queueName,
|
|
1046
1046
|
isDraft: merge[i]?.isDrafted || false,
|
|
1047
1047
|
isEnable:
|
|
@@ -1051,11 +1051,11 @@ export async function workSpace( req, res ) {
|
|
|
1051
1051
|
( merge[i].userInprogressCount && merge[i].userInprogressCount > 0 ) ?
|
|
1052
1052
|
1 :
|
|
1053
1053
|
0,
|
|
1054
|
-
completedRatio: merge[i].
|
|
1054
|
+
completedRatio: merge[i].totalCount ?
|
|
1055
1055
|
merge[i].completedStoresCount ?
|
|
1056
1056
|
Math.round(
|
|
1057
1057
|
( Number( merge[i].completedStoresCount ) /
|
|
1058
|
-
Number( merge[i].
|
|
1058
|
+
Number( merge[i].totalCount ) ) *
|
|
1059
1059
|
100,
|
|
1060
1060
|
) :
|
|
1061
1061
|
0 :
|
|
@@ -1660,3 +1660,227 @@ export async function userAuditHistory( req, res ) {
|
|
|
1660
1660
|
return res.sendError( err, 500 );
|
|
1661
1661
|
}
|
|
1662
1662
|
}
|
|
1663
|
+
|
|
1664
|
+
export async function clientMetrics( req, res ) {
|
|
1665
|
+
try {
|
|
1666
|
+
const inputData = req.body;
|
|
1667
|
+
const limit = inputData.limit || 10;
|
|
1668
|
+
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
1669
|
+
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
1670
|
+
let filter = [
|
|
1671
|
+
{ fileDateISO: { $gte: dateRange.start } },
|
|
1672
|
+
{ fileDateISO: { $lte: dateRange.end } },
|
|
1673
|
+
];
|
|
1674
|
+
|
|
1675
|
+
let storeAuditFilter = [
|
|
1676
|
+
{ $eq: [ '$clientId', '$$clientId' ] },
|
|
1677
|
+
{ $eq: [ '$fileDate', '$$fileDate' ] },
|
|
1678
|
+
|
|
1679
|
+
];
|
|
1680
|
+
|
|
1681
|
+
if ( inputData?.filterByModuleType?.length> 0 ) {
|
|
1682
|
+
filter.push(
|
|
1683
|
+
{ moduleType: { $in: inputData.filterByModuleType } },
|
|
1684
|
+
);
|
|
1685
|
+
storeAuditFilter.push( {
|
|
1686
|
+
$in: [ '$moduleType', inputData.filterByModuleType ],
|
|
1687
|
+
} );
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
if ( inputData?.filterByClient?.length> 0 ) {
|
|
1691
|
+
filter.push(
|
|
1692
|
+
{ clientId: { $in: inputData.filterByClient } },
|
|
1693
|
+
);
|
|
1694
|
+
}
|
|
1695
|
+
const query = [
|
|
1696
|
+
{
|
|
1697
|
+
$match: {
|
|
1698
|
+
$and: filter,
|
|
1699
|
+
},
|
|
1700
|
+
},
|
|
1701
|
+
{
|
|
1702
|
+
$group: {
|
|
1703
|
+
_id: { clientId: '$clientId', fileDate: '$fileDate', moduleType: '$moduleType' },
|
|
1704
|
+
fileDate: { $last: '$fileDate' },
|
|
1705
|
+
clientId: { $last: '$clientId' },
|
|
1706
|
+
clientName: { $last: '$clientName' },
|
|
1707
|
+
moduleType: { $last: '$moduleType' },
|
|
1708
|
+
installedStore: { $last: '$installedStore' },
|
|
1709
|
+
queueName: { $last: '$queueName' },
|
|
1710
|
+
totalFilesCount: { $sum: 1 },
|
|
1711
|
+
},
|
|
1712
|
+
},
|
|
1713
|
+
{
|
|
1714
|
+
$project: {
|
|
1715
|
+
fileDate: 1,
|
|
1716
|
+
clientId: 1,
|
|
1717
|
+
clientName: 1,
|
|
1718
|
+
queueName: 1,
|
|
1719
|
+
installedStore: 1,
|
|
1720
|
+
totalFilesCount: 1,
|
|
1721
|
+
moduleType: 1,
|
|
1722
|
+
notAssignedCount: { $ifNull: [ 0, 0 ] },
|
|
1723
|
+
clientStatus: { $ifNull: [ '', '' ] },
|
|
1724
|
+
},
|
|
1725
|
+
},
|
|
1726
|
+
{
|
|
1727
|
+
$lookup: {
|
|
1728
|
+
'from': 'storeAudit',
|
|
1729
|
+
'let': { clientId: '$clientId', fileDate: '$fileDate', totalAuditFiles: '$totalFilesCount' },
|
|
1730
|
+
'pipeline': [
|
|
1731
|
+
|
|
1732
|
+
{
|
|
1733
|
+
$match: {
|
|
1734
|
+
$expr: {
|
|
1735
|
+
$and: storeAuditFilter,
|
|
1736
|
+
},
|
|
1737
|
+
},
|
|
1738
|
+
},
|
|
1739
|
+
{
|
|
1740
|
+
$project: {
|
|
1741
|
+
completedStores: { $cond: [ { $eq: [ '$status', 'completed' ] }, 1, 0 ] },
|
|
1742
|
+
notAssignedStores: { $cond: [ { $eq: [ '$status', 'not_assign' ] }, 1, 0 ] },
|
|
1743
|
+
inprogressStores: { $cond: [ { $in: [ '$status', [ 'inprogress', 'drafted', 'assigned' ] ] }, 1, 0 ] },
|
|
1744
|
+
},
|
|
1745
|
+
},
|
|
1746
|
+
{
|
|
1747
|
+
$group: {
|
|
1748
|
+
_id: { clientId: '$clientId', fileDate: '$fileDate' },
|
|
1749
|
+
completedStores: { $sum: '$completedStores' },
|
|
1750
|
+
inprogressStores: { $sum: '$inprogressStores' },
|
|
1751
|
+
notAssignedStores: { $sum: '$notAssignedStores' },
|
|
1752
|
+
fileCount: { $sum: 1 },
|
|
1753
|
+
},
|
|
1754
|
+
},
|
|
1755
|
+
{
|
|
1756
|
+
$project: {
|
|
1757
|
+
_id: 0,
|
|
1758
|
+
completedStores: 1,
|
|
1759
|
+
inprogressStores: 1,
|
|
1760
|
+
notAssignedStores: 1,
|
|
1761
|
+
fileCount: 1,
|
|
1762
|
+
completionPercentage: { $ifNull: [
|
|
1763
|
+
{
|
|
1764
|
+
$round: [ {
|
|
1765
|
+
$multiply: [
|
|
1766
|
+
100, {
|
|
1767
|
+
$divide: [
|
|
1768
|
+
'$completedStores', '$$totalAuditFiles',
|
|
1769
|
+
],
|
|
1770
|
+
},
|
|
1771
|
+
],
|
|
1772
|
+
}, 1 ],
|
|
1773
|
+
|
|
1774
|
+
},
|
|
1775
|
+
0,
|
|
1776
|
+
],
|
|
1777
|
+
},
|
|
1778
|
+
},
|
|
1779
|
+
},
|
|
1780
|
+
], 'as': 'storeAudit',
|
|
1781
|
+
},
|
|
1782
|
+
},
|
|
1783
|
+
{
|
|
1784
|
+
$unwind: {
|
|
1785
|
+
path: '$storeAudit',
|
|
1786
|
+
preserveNullAndEmptyArrays: true,
|
|
1787
|
+
},
|
|
1788
|
+
},
|
|
1789
|
+
{
|
|
1790
|
+
$project: {
|
|
1791
|
+
_id: 0,
|
|
1792
|
+
fileDate: 1,
|
|
1793
|
+
clientId: 1,
|
|
1794
|
+
clientName: 1,
|
|
1795
|
+
totalFilesCount: 1,
|
|
1796
|
+
moduleType: 1,
|
|
1797
|
+
installedStore: 1,
|
|
1798
|
+
// notAssignedStores: '$storeAudit.notAssignedStores',
|
|
1799
|
+
inprogressStoresCount: '$storeAudit.inprogressStores',
|
|
1800
|
+
// fileCount: '$storeAudit.fileCount',
|
|
1801
|
+
notAssignedCount: 1,
|
|
1802
|
+
clientStatus: { $cond: [ { $eq: [ '$storeAudit.fileCount', 0 ] }, 'not-taken', { $cond: [ { $or: [ { $gt: [ '$notAssignedCount', 0 ] }, { $gt: [ '$storeAudit.notAssignedStores', 0 ] } ] }, 'pending', 'completed' ] } ] },
|
|
1803
|
+
completedStores: '$storeAudit.completedStores',
|
|
1804
|
+
completionPercentage: '$storeAudit.completionPercentage',
|
|
1805
|
+
|
|
1806
|
+
},
|
|
1807
|
+
},
|
|
1808
|
+
];
|
|
1809
|
+
|
|
1810
|
+
if ( inputData?.filterByStatus?.length> 0 ) {
|
|
1811
|
+
query.push(
|
|
1812
|
+
{
|
|
1813
|
+
$match: { clientStatus: { $in: inputData.filterByStatus } },
|
|
1814
|
+
},
|
|
1815
|
+
|
|
1816
|
+
);
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
1820
|
+
query.push( {
|
|
1821
|
+
$match: {
|
|
1822
|
+
$or: [
|
|
1823
|
+
{ clientId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1824
|
+
{ clientName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1825
|
+
{ moduleType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1826
|
+
{ clientStatus: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1827
|
+
],
|
|
1828
|
+
|
|
1829
|
+
},
|
|
1830
|
+
} );
|
|
1831
|
+
}
|
|
1832
|
+
if ( inputData.sortColumnName ) {
|
|
1833
|
+
const sortBy = inputData.sortBy || -1;
|
|
1834
|
+
query.push( {
|
|
1835
|
+
$sort: { [inputData.sortColumnName]: sortBy },
|
|
1836
|
+
},
|
|
1837
|
+
);
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
const count = await aggregateAuditStoreDataSchema( query );
|
|
1841
|
+
if ( count.length == 0 ) {
|
|
1842
|
+
return res.sendError( 'No Data Found', 204 );
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
query.push(
|
|
1846
|
+
{ $skip: offset },
|
|
1847
|
+
{ $limit: limit },
|
|
1848
|
+
);
|
|
1849
|
+
if ( inputData.isExport ) {
|
|
1850
|
+
query.push(
|
|
1851
|
+
{
|
|
1852
|
+
$project: {
|
|
1853
|
+
'_id': 0,
|
|
1854
|
+
'File Date': '$fileDate',
|
|
1855
|
+
'Client Name': '$clientName',
|
|
1856
|
+
'Client Id': '$clientId',
|
|
1857
|
+
'Module Type': '$moduleType',
|
|
1858
|
+
'Completed Percentage': '$completionPercentage',
|
|
1859
|
+
'Installed Stores': '$installedStore',
|
|
1860
|
+
'Audit Stores': '$totalFilesCount',
|
|
1861
|
+
'Inprogress Stores': '$inprogressStoresCount',
|
|
1862
|
+
'Not Assigned': '$notAssignedCount',
|
|
1863
|
+
// 'Not Assigned Stores': '$notAssignedStores',
|
|
1864
|
+
'Completed': '$completedStores',
|
|
1865
|
+
'Status': '$clientStatus',
|
|
1866
|
+
},
|
|
1867
|
+
},
|
|
1868
|
+
);
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
logger.info( { query: query } );
|
|
1872
|
+
const result = await aggregateAuditStoreDataSchema( query );
|
|
1873
|
+
if ( result.length == 0 ) {
|
|
1874
|
+
return res.sendError( 'No Data Found', 204 );
|
|
1875
|
+
}
|
|
1876
|
+
if ( inputData.isExport ) {
|
|
1877
|
+
await download( result, res );
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
return res.sendSuccess( { result: result, count: count.length } );
|
|
1881
|
+
} catch ( error ) {
|
|
1882
|
+
const err = error.error || 'Internal Server Error';
|
|
1883
|
+
logger.info( { error: error, message: req.body, function: 'clientMetrics' } );
|
|
1884
|
+
return res.sendError( err, 500 );
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
@@ -271,188 +271,6 @@ export async function storeMetrics( req, res ) {
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
export async function clientMetrics( req, res ) {
|
|
275
|
-
try {
|
|
276
|
-
const inputData = req.body;
|
|
277
|
-
const limit = inputData.limit || 10;
|
|
278
|
-
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
279
|
-
const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
|
|
280
|
-
let filter = [
|
|
281
|
-
{ fileDateISO: { $gte: dateRange.start } },
|
|
282
|
-
{ fileDateISO: { $lte: dateRange.end } },
|
|
283
|
-
{ moduleType: { $eq: 'traffic' } },
|
|
284
|
-
|
|
285
|
-
];
|
|
286
|
-
if ( inputData?.filterByClient?.length> 0 ) {
|
|
287
|
-
filter.push(
|
|
288
|
-
{ clientId: { $in: inputData.filterByClient } },
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
const query = [
|
|
292
|
-
{
|
|
293
|
-
$match: {
|
|
294
|
-
$and: filter,
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
$project: {
|
|
299
|
-
fileDate: 1,
|
|
300
|
-
clientId: 1,
|
|
301
|
-
clientName: 1,
|
|
302
|
-
queueName: 1,
|
|
303
|
-
installedStore: 1,
|
|
304
|
-
totalFilesCount: 1,
|
|
305
|
-
notAssignedCount: { $ifNull: [ 0, 0 ] },
|
|
306
|
-
clientStatus: { $ifNull: [ '', '' ] },
|
|
307
|
-
},
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
$lookup: {
|
|
311
|
-
'from': 'storeAudit',
|
|
312
|
-
'let': { clientId: '$clientId', fileDate: '$fileDate', totalAuditFiles: '$totalAuditFiles' },
|
|
313
|
-
'pipeline': [
|
|
314
|
-
|
|
315
|
-
{
|
|
316
|
-
$match: {
|
|
317
|
-
$expr: {
|
|
318
|
-
$and: [
|
|
319
|
-
{ $eq: [ '$clientId', '$$clientId' ] },
|
|
320
|
-
{ $eq: [ '$fileDate', '$$fileDate' ] },
|
|
321
|
-
],
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
$project: {
|
|
327
|
-
completedStores: { $cond: [ { $eq: [ '$status', 'completed' ] }, 1, 0 ] },
|
|
328
|
-
notAssignedStores: { $cond: [ { $eq: [ '$status', 'not_assign' ] }, 1, 0 ] },
|
|
329
|
-
inprogressStores: { $cond: [ { $in: [ '$status', [ 'inprogress', 'drafted', 'assigned' ] ] }, 1, 0 ] },
|
|
330
|
-
},
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
$group: {
|
|
334
|
-
_id: { clientId: '$clientId', fileDate: '$fileDate' },
|
|
335
|
-
completedStores: { $sum: '$completedStores' },
|
|
336
|
-
inprogressStores: { $sum: '$inprogressStores' },
|
|
337
|
-
notAssignedStores: { $sum: '$notAssignedStores' },
|
|
338
|
-
fileCount: { $sum: 1 },
|
|
339
|
-
},
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
$project: {
|
|
343
|
-
_id: 0,
|
|
344
|
-
completedStores: 1,
|
|
345
|
-
inprogressStores: 1,
|
|
346
|
-
notAssignedStores: 1,
|
|
347
|
-
fileCount: 1,
|
|
348
|
-
completionPercentage: { $ifNull: [
|
|
349
|
-
{
|
|
350
|
-
$round: [ {
|
|
351
|
-
$multiply: [
|
|
352
|
-
100, {
|
|
353
|
-
$divide: [
|
|
354
|
-
'$completedStores', '$$totalAuditFiles',
|
|
355
|
-
],
|
|
356
|
-
},
|
|
357
|
-
],
|
|
358
|
-
}, 1 ],
|
|
359
|
-
|
|
360
|
-
},
|
|
361
|
-
0,
|
|
362
|
-
],
|
|
363
|
-
},
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
], 'as': 'storeAudit',
|
|
367
|
-
},
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
$unwind: {
|
|
371
|
-
path: '$storeAudit',
|
|
372
|
-
preserveNullAndEmptyArrays: true,
|
|
373
|
-
},
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
$project: {
|
|
377
|
-
fileDate: 1,
|
|
378
|
-
clientId: 1,
|
|
379
|
-
clientName: 1,
|
|
380
|
-
totalFilesCount: 1,
|
|
381
|
-
installedStore: 1,
|
|
382
|
-
notAssignedStores: '$storeAudit.notAssignedStores',
|
|
383
|
-
inprogressStoresCount: '$storeAudit.inprogressStores',
|
|
384
|
-
fileCount: '$storeAudit.fileCount',
|
|
385
|
-
notAssignedCount: 1,
|
|
386
|
-
clientStatus: { $cond: [ { $eq: [ '$storeAudit.fileCount', 0 ] }, 'not-taken', { $cond: [ { $or: [ { $gt: [ '$notAssignedCount', 0 ] }, { $gt: [ '$storeAudit.notAssignedStores', 0 ] } ] }, 'pending', 'completed' ] } ] },
|
|
387
|
-
completedStores: '$storeAudit.completedStores',
|
|
388
|
-
completionPercentage: '$storeAudit.completionPercentage',
|
|
389
|
-
|
|
390
|
-
},
|
|
391
|
-
},
|
|
392
|
-
];
|
|
393
|
-
|
|
394
|
-
if ( inputData.searchValue && inputData.searchValue!== '' ) {
|
|
395
|
-
query.push( {
|
|
396
|
-
$match: {
|
|
397
|
-
$or: [
|
|
398
|
-
{ clientId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
399
|
-
{ clientName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
400
|
-
],
|
|
401
|
-
|
|
402
|
-
},
|
|
403
|
-
} );
|
|
404
|
-
}
|
|
405
|
-
if ( inputData.sortColumnName ) {
|
|
406
|
-
const sortBy = inputData.sortBy || -1;
|
|
407
|
-
query.push( {
|
|
408
|
-
$sort: { [inputData.sortColumName]: sortBy },
|
|
409
|
-
},
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
|
-
logger.info( { query: query } );
|
|
413
|
-
const count = [];// await aggregateAuditClientData( query );
|
|
414
|
-
if ( count.length == 0 ) {
|
|
415
|
-
return res.sendError( 'No Data Found', 204 );
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
query.push(
|
|
419
|
-
{ $skip: offset },
|
|
420
|
-
{ $limit: limit },
|
|
421
|
-
);
|
|
422
|
-
if ( inputData.isExport ) {
|
|
423
|
-
query.push(
|
|
424
|
-
{
|
|
425
|
-
$project: {
|
|
426
|
-
'_id': 0,
|
|
427
|
-
'File Date': '$fileDate',
|
|
428
|
-
'Client Name': '$clientName',
|
|
429
|
-
'Client Id': '$clientId',
|
|
430
|
-
'Completed Percentage': '$completionPercentage',
|
|
431
|
-
'Installed Stores': '$installedStore',
|
|
432
|
-
'Audit Stores': '$totalFilesCount',
|
|
433
|
-
'Inprogress Stores': '$inprogressStoresCount',
|
|
434
|
-
'Not Assigned': '$notAssignedCount',
|
|
435
|
-
'Not Assigned Stores': '$notAssignedStores',
|
|
436
|
-
'Completed': '$completedStores',
|
|
437
|
-
'Status': '$clientStatus',
|
|
438
|
-
},
|
|
439
|
-
},
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
logger.info( { query: query } );
|
|
444
|
-
const result = [];// await aggregateAuditClientData( query );
|
|
445
|
-
if ( inputData.isExport ) {
|
|
446
|
-
await download( result, res );
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
return res.sendSuccess( { result: result, count: count.length } );
|
|
450
|
-
} catch ( error ) {
|
|
451
|
-
const err = error.error || 'Internal Server Error';
|
|
452
|
-
logger.info( { error: error, message: req.body, function: 'clientMetrics' } );
|
|
453
|
-
return res.sendError( err, 500 );
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
274
|
|
|
457
275
|
export async function userMetrics( req, res ) {
|
|
458
276
|
try {
|
package/src/docs/audit.docs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { auditStoreSchema, clientSchema, getDraftedDataSchema, getFileSchema, saveDraftSchema, saveSchema, userAuditHistorySchema, userSchema, workSpaceSchema } from '../dtos/audit.dtos.js';
|
|
1
|
+
import { auditStoreSchema, clientMetricsSchema, clientSchema, getDraftedDataSchema, getFileSchema, saveDraftSchema, saveSchema, userAuditHistorySchema, userSchema, workSpaceSchema } from '../dtos/audit.dtos.js';
|
|
2
2
|
import j2s from 'joi-to-swagger';
|
|
3
3
|
|
|
4
4
|
export const auditDocs = {
|
|
@@ -286,5 +286,27 @@ export const auditDocs = {
|
|
|
286
286
|
},
|
|
287
287
|
},
|
|
288
288
|
},
|
|
289
|
+
'/v3/audit/metrics/client-metrics': {
|
|
290
|
+
post: {
|
|
291
|
+
tags: [ 'Audit Metrics' ],
|
|
292
|
+
description: `Get list of client wise details with date range`,
|
|
293
|
+
operationId: 'client-metrics',
|
|
294
|
+
parameters: {},
|
|
295
|
+
requestBody: {
|
|
296
|
+
content: {
|
|
297
|
+
'application/json': {
|
|
298
|
+
schema: j2s( clientMetricsSchema ).swagger,
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
responses: {
|
|
303
|
+
200: { description: 'Successful' },
|
|
304
|
+
401: { description: 'Unauthorized User' },
|
|
305
|
+
422: { description: 'Field Error' },
|
|
306
|
+
500: { description: 'Server Error' },
|
|
307
|
+
204: { description: 'Not Found' },
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
},
|
|
289
311
|
|
|
290
312
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
|
-
import { auditImageValidSchema,
|
|
2
|
+
import { auditImageValidSchema, getAuditImagesSchema, overAllAuditSummarySchema, overViewCardSchema, overViewTableSchema, reTriggerValidSchema, storeMetricsSchema, summarySplitSchema, userMetricsSchema } from '../dtos/auditMetrics.dtos.js';
|
|
3
3
|
|
|
4
4
|
export const auditMetricsDocs = {
|
|
5
5
|
|
|
@@ -25,28 +25,7 @@ export const auditMetricsDocs = {
|
|
|
25
25
|
},
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
|
-
|
|
29
|
-
post: {
|
|
30
|
-
tags: [ 'Audit Metrics' ],
|
|
31
|
-
description: `Get list of client wise details with date range`,
|
|
32
|
-
operationId: 'client-metrics',
|
|
33
|
-
parameters: {},
|
|
34
|
-
requestBody: {
|
|
35
|
-
content: {
|
|
36
|
-
'application/json': {
|
|
37
|
-
schema: j2s( clientMetricsSchema ).swagger,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
responses: {
|
|
42
|
-
200: { description: 'Successful' },
|
|
43
|
-
401: { description: 'Unauthorized User' },
|
|
44
|
-
422: { description: 'Field Error' },
|
|
45
|
-
500: { description: 'Server Error' },
|
|
46
|
-
204: { description: 'Not Found' },
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
28
|
+
|
|
50
29
|
|
|
51
30
|
'/v3/audit-metrics/store-metrics': {
|
|
52
31
|
post: {
|
package/src/dtos/audit.dtos.js
CHANGED
|
@@ -162,3 +162,23 @@ export const userAuditHistorySchema = joi.object(
|
|
|
162
162
|
export const userAuditHistoryValid = {
|
|
163
163
|
body: userAuditHistorySchema,
|
|
164
164
|
};
|
|
165
|
+
|
|
166
|
+
export const clientMetricsSchema = joi.object(
|
|
167
|
+
{
|
|
168
|
+
fromDate: joi.string().required(),
|
|
169
|
+
toDate: joi.string().required(),
|
|
170
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
171
|
+
filterByModuleType: joi.array().optional(),
|
|
172
|
+
filterByClient: joi.array().required(),
|
|
173
|
+
filterByStatus: joi.array().optional(),
|
|
174
|
+
sortColumnName: joi.string().optional(),
|
|
175
|
+
sortBy: joi.number().optional(),
|
|
176
|
+
limit: joi.number().optional(),
|
|
177
|
+
offset: joi.number().optional(),
|
|
178
|
+
isExport: joi.boolean().optional(),
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
export const clientMetricsValid = {
|
|
183
|
+
body: clientMetricsSchema,
|
|
184
|
+
};
|
|
@@ -35,24 +35,6 @@ export const storeMetricsValid = {
|
|
|
35
35
|
body: storeMetricsSchema,
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
export const clientMetricsSchema = joi.object(
|
|
39
|
-
{
|
|
40
|
-
fromDate: joi.string().required(),
|
|
41
|
-
toDate: joi.string().required(),
|
|
42
|
-
searchValue: joi.string().optional().allow( '' ),
|
|
43
|
-
filterByClient: joi.array().required(),
|
|
44
|
-
filterByStatus: joi.array().optional(),
|
|
45
|
-
sortColumnName: joi.string().optional(),
|
|
46
|
-
sortBy: joi.number().optional(),
|
|
47
|
-
limit: joi.number().optional(),
|
|
48
|
-
offset: joi.number().optional(),
|
|
49
|
-
isExport: joi.boolean().optional(),
|
|
50
|
-
},
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
export const clientMetricsValid = {
|
|
54
|
-
body: clientMetricsSchema,
|
|
55
|
-
};
|
|
56
38
|
|
|
57
39
|
export const userMetricsSchema = joi.object(
|
|
58
40
|
{
|
|
@@ -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, clients, getAuditFile, getDraftedData, save, saveDraft, userAuditHistory, workSpace } from '../controllers/audit.controllers.js';
|
|
5
|
-
import { auditStoreValid, clientValid, getDraftedDataValid, getFileValid, saveDraftValid, saveValid, userAuditHistoryValid, workSpaceValid } from '../dtos/audit.dtos.js';
|
|
4
|
+
import { auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, save, saveDraft, userAuditHistory, workSpace } from '../controllers/audit.controllers.js';
|
|
5
|
+
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, saveDraftValid, saveValid, userAuditHistoryValid, workSpaceValid } from '../dtos/audit.dtos.js';
|
|
6
6
|
|
|
7
7
|
export const auditRouter = express.Router();
|
|
8
8
|
|
|
@@ -21,6 +21,7 @@ auditRouter.get( '/work-space', isAllowedSessionHandler, validate( workSpaceVali
|
|
|
21
21
|
|
|
22
22
|
// Audit Metrics
|
|
23
23
|
auditRouter.post( '/metrics/user-audit-history', isAllowedSessionHandler, validate( userAuditHistoryValid ), userAuditHistory );
|
|
24
|
+
auditRouter.post( '/metrics/client-metrics', isAllowedSessionHandler, validate( clientMetricsValid ), clientMetrics );
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
export default auditRouter;
|
|
@@ -1,15 +1,15 @@
|
|
|
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, overAllAuditSummary, overViewCard, overViewTable, reTrigger, storeMetrics, summarySplit, userMetrics } from '../controllers/auditMetrics.controllers.js';
|
|
5
|
+
import { auditImageValid, overAllAuditSummaryValid, overViewCardValid, overViewTableValid, reTriggerValid, storeMetricsValid, summarySplitValid, userMetricsValid, 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
11
|
auditMetricsRouter.post( '/store-metrics', isAllowedSessionHandler, validate( storeMetricsValid ), storeMetrics );
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
auditMetricsRouter.post( '/user-metrics', isAllowedSessionHandler, validate( userMetricsValid ), userMetrics );
|
|
14
14
|
auditMetricsRouter.post( '/overview-card', isAllowedSessionHandler, validate( overViewCardValid ), overViewCard );
|
|
15
15
|
auditMetricsRouter.post( '/summary-split-up', isAllowedSessionHandler, validate( summarySplitValid ), summarySplit );
|