tango-app-api-audit 3.3.0-alpha.21 → 3.3.0-alpha.22
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 +128 -60
package/package.json
CHANGED
|
@@ -1646,25 +1646,46 @@ export async function userAuditHistory( req, res ) {
|
|
|
1646
1646
|
const promises = chunkedMappingData.map( async ( chunk ) => {
|
|
1647
1647
|
const exportData = [];
|
|
1648
1648
|
chunk.forEach( ( element ) => {
|
|
1649
|
-
|
|
1649
|
+
if ( element.moduleType == 'zone' ) {
|
|
1650
|
+
exportData.push( {
|
|
1651
|
+
'File Date': element.fileDate,
|
|
1652
|
+
'Brand ID': element.clientId,
|
|
1653
|
+
'Brand Name': element.clientName,
|
|
1654
|
+
'Store ID': element.storeId,
|
|
1655
|
+
'Store Name': element.storeName,
|
|
1656
|
+
'Zone Name': element.zoneName,
|
|
1657
|
+
'Audit Type': element.auditType,
|
|
1658
|
+
'Product Type': element.moduleType,
|
|
1659
|
+
'Before Count': element.beforeCount,
|
|
1660
|
+
'After Count': element.afterCount || '',
|
|
1661
|
+
'Accuracy': element.accuracy || '',
|
|
1662
|
+
'Start Time': element.startTime,
|
|
1663
|
+
'End Time': element.endTime || '',
|
|
1664
|
+
'Time Spent': element.timeSpent,
|
|
1665
|
+
'Audit Status': element.auditStatus,
|
|
1666
|
+
'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
|
|
1650
1667
|
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1668
|
+
} );
|
|
1669
|
+
} else {
|
|
1670
|
+
exportData.push( {
|
|
1671
|
+
'File Date': element.fileDate,
|
|
1672
|
+
'Brand ID': element.clientId,
|
|
1673
|
+
'Brand Name': element.clientName,
|
|
1674
|
+
'Store ID': element.storeId,
|
|
1675
|
+
'Store Name': element.storeName,
|
|
1676
|
+
'Audit Type': element.auditType,
|
|
1677
|
+
'Product Type': element.moduleType,
|
|
1678
|
+
'Before Count': element.beforeCount,
|
|
1679
|
+
'After Count': element.afterCount || '',
|
|
1680
|
+
'Accuracy': element.accuracy || '',
|
|
1681
|
+
'Start Time': element.startTime,
|
|
1682
|
+
'End Time': element.endTime || '',
|
|
1683
|
+
'Time Spent': element.timeSpent,
|
|
1684
|
+
'Audit Status': element.auditStatus,
|
|
1685
|
+
'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
|
|
1666
1686
|
|
|
1667
|
-
|
|
1687
|
+
} );
|
|
1688
|
+
}
|
|
1668
1689
|
} );
|
|
1669
1690
|
return exportData;
|
|
1670
1691
|
} );
|
|
@@ -1788,7 +1809,7 @@ export async function clientMetrics( req, res ) {
|
|
|
1788
1809
|
completedStores: 1,
|
|
1789
1810
|
inprogressStores: 1,
|
|
1790
1811
|
notAssignedStores: 1,
|
|
1791
|
-
fileCount:
|
|
1812
|
+
fileCount: { $ifNull: [ '$fileCount', 0 ] },
|
|
1792
1813
|
completionPercentage: { $ifNull: [
|
|
1793
1814
|
{
|
|
1794
1815
|
$round: [ {
|
|
@@ -1828,8 +1849,8 @@ export async function clientMetrics( req, res ) {
|
|
|
1828
1849
|
// notAssignedStores: '$storeAudit.notAssignedStores',
|
|
1829
1850
|
inprogressStoresCount: '$storeAudit.inprogressStores',
|
|
1830
1851
|
// fileCount: '$storeAudit.fileCount',
|
|
1831
|
-
notAssignedCount:
|
|
1832
|
-
clientStatus: { $cond: [ { $eq: [ '$storeAudit.fileCount', 0 ] }, 'not-taken', { $cond: [ { $or: [ { $gt: [ '$notAssignedCount', 0 ] }, { $gt: [ '$storeAudit.notAssignedStores', 0 ] } ] }
|
|
1852
|
+
notAssignedCount: { $subtract: [ '$totalFilesCount', { $subtract: [ { $ifNull: [ '$storeAudit.fileCount', 0 ] }, { $ifNull: [ '$storeAudit.notAssignedStores', 0 ] } ] } ] },
|
|
1853
|
+
clientStatus: { $cond: [ { $eq: [ { $ifNull: [ '$storeAudit.fileCount', 0 ] }, 0 ] }, 'not-taken', { $cond: [ { $gte: [ '$storeAudit.completedStores', '$totalFilesCount' ] }, 'completed', 'pending' ] } ] }, // { $cond: [ { $or: [ { $gt: [ '$notAssignedCount', 0 ] }, { $gt: [ '$storeAudit.notAssignedStores', 0 ] } ] }
|
|
1833
1854
|
completedStores: '$storeAudit.completedStores',
|
|
1834
1855
|
completionPercentage: '$storeAudit.completionPercentage',
|
|
1835
1856
|
|
|
@@ -1885,7 +1906,7 @@ export async function clientMetrics( req, res ) {
|
|
|
1885
1906
|
'File Date': '$fileDate',
|
|
1886
1907
|
'Client Name': '$clientName',
|
|
1887
1908
|
'Client Id': '$clientId',
|
|
1888
|
-
'
|
|
1909
|
+
'Product Type': '$moduleType',
|
|
1889
1910
|
'Completed Percentage': '$completionPercentage',
|
|
1890
1911
|
'Installed Stores': '$installedStore',
|
|
1891
1912
|
'Audit Stores': '$totalFilesCount',
|
|
@@ -2127,6 +2148,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2127
2148
|
{ status: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2128
2149
|
{ auditType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2129
2150
|
{ moduleType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2151
|
+
{ zoneName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2130
2152
|
],
|
|
2131
2153
|
},
|
|
2132
2154
|
} );
|
|
@@ -2159,19 +2181,36 @@ export async function storeMetrics( req, res ) {
|
|
|
2159
2181
|
if ( inputData.isExport ) {
|
|
2160
2182
|
const exportdata = [];
|
|
2161
2183
|
result.forEach( ( element ) => {
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2184
|
+
if ( element.moduleType == 'zone' ) {
|
|
2185
|
+
exportdata.push( {
|
|
2186
|
+
'File Date': element.fileDate,
|
|
2187
|
+
'Store ID': element.storeId,
|
|
2188
|
+
'Store Name': element.storeName,
|
|
2189
|
+
'Client Id': element.clientId,
|
|
2190
|
+
'Client Name': element.clientName,
|
|
2191
|
+
'Zone Name': element.zoneName,
|
|
2192
|
+
'User Name': element.userName,
|
|
2193
|
+
'User Email': element.userEmail,
|
|
2194
|
+
'Audit Type': element.auditType,
|
|
2195
|
+
'Accuracy': element.accuracy,
|
|
2196
|
+
'Time Spent': element.timeSpent,
|
|
2197
|
+
'Status': element.status,
|
|
2198
|
+
} );
|
|
2199
|
+
} else {
|
|
2200
|
+
exportdata.push( {
|
|
2201
|
+
'File Date': element.fileDate,
|
|
2202
|
+
'Store ID': element.storeId,
|
|
2203
|
+
'Store Name': element.storeName,
|
|
2204
|
+
'Client Id': element.clientId,
|
|
2205
|
+
'Client Name': element.clientName,
|
|
2206
|
+
'User Name': element.userName,
|
|
2207
|
+
'User Email': element.userEmail,
|
|
2208
|
+
'Audit Type': element.auditType,
|
|
2209
|
+
'Accuracy': element.accuracy,
|
|
2210
|
+
'Time Spent': element.timeSpent,
|
|
2211
|
+
'Status': element.status,
|
|
2212
|
+
} );
|
|
2213
|
+
}
|
|
2175
2214
|
} );
|
|
2176
2215
|
await download( exportdata, res );
|
|
2177
2216
|
return;
|
|
@@ -2597,18 +2636,32 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2597
2636
|
if ( inputData.isExport ) {
|
|
2598
2637
|
const exportdata = [];
|
|
2599
2638
|
result.forEach( ( element ) => {
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2639
|
+
if ( element.moduleType == 'zone' ) {
|
|
2640
|
+
exportdata.push( {
|
|
2641
|
+
'Store ID': element.storeId,
|
|
2642
|
+
'zoneName': element.zoneName,
|
|
2643
|
+
'File Date': element.fileDate,
|
|
2644
|
+
'Product Type': element.moduleType,
|
|
2645
|
+
'Audit Type': element.auditType,
|
|
2646
|
+
'Before Count': element.beforeCount,
|
|
2647
|
+
'Start Time': element.startTime,
|
|
2648
|
+
'User Name': element.userName,
|
|
2649
|
+
'User Email': element.userEmail,
|
|
2650
|
+
'Status': element.auditStatus,
|
|
2651
|
+
} );
|
|
2652
|
+
} else {
|
|
2653
|
+
exportdata.push( {
|
|
2654
|
+
'Store ID': element.storeId,
|
|
2655
|
+
'File Date': element.fileDate,
|
|
2656
|
+
'Product Type': element.moduleType,
|
|
2657
|
+
'Audit Type': element.auditType,
|
|
2658
|
+
'Before Count': element.beforeCount,
|
|
2659
|
+
'Start Time': element.startTime,
|
|
2660
|
+
'User Name': element.userName,
|
|
2661
|
+
'User Email': element.userEmail,
|
|
2662
|
+
'Status': element.auditStatus,
|
|
2663
|
+
} );
|
|
2664
|
+
}
|
|
2612
2665
|
} );
|
|
2613
2666
|
await download( exportdata, res );
|
|
2614
2667
|
return;
|
|
@@ -2883,7 +2936,7 @@ export async function reTrigger( req, res ) {
|
|
|
2883
2936
|
await insertOpenSearchData( openSearch.auditLog, logData );
|
|
2884
2937
|
}
|
|
2885
2938
|
|
|
2886
|
-
return res.sendSuccess( { result: 'The File has been Re
|
|
2939
|
+
return res.sendSuccess( { result: 'The File has been Re-Trigger Succesfully' } );
|
|
2887
2940
|
} catch ( error ) {
|
|
2888
2941
|
const err = error.message;
|
|
2889
2942
|
logger.error( { error: error, message: req.body, function: 'reTrigger' } );
|
|
@@ -3239,19 +3292,34 @@ export async function overviewTable( req, res ) {
|
|
|
3239
3292
|
if ( inputData.isExport ) {
|
|
3240
3293
|
const exportdata = [];
|
|
3241
3294
|
result.forEach( ( element ) => {
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3295
|
+
if ( element.moduleType == 'zone' ) {
|
|
3296
|
+
exportdata.push( {
|
|
3297
|
+
'Store ID': element.storeId,
|
|
3298
|
+
'Brand ID': element.clientId,
|
|
3299
|
+
'Zone Name': element.zoneName,
|
|
3300
|
+
'File Date': element.fileDate,
|
|
3301
|
+
'Product Type': element.moduleType,
|
|
3302
|
+
'Audit Type': element.auditType,
|
|
3303
|
+
'Before Count': element.beforeCount,
|
|
3304
|
+
'After Count': element.afterCount,
|
|
3305
|
+
// 'User Name': element.userName,
|
|
3306
|
+
// 'User Email': element.userEmail,
|
|
3307
|
+
'Status': element.status,
|
|
3308
|
+
} );
|
|
3309
|
+
} else {
|
|
3310
|
+
exportdata.push( {
|
|
3311
|
+
'Store ID': element.storeId,
|
|
3312
|
+
'Brand ID': element.clientId,
|
|
3313
|
+
'File Date': element.fileDate,
|
|
3314
|
+
'Product Type': element.moduleType,
|
|
3315
|
+
'Audit Type': element.auditType,
|
|
3316
|
+
'Before Count': element.beforeCount,
|
|
3317
|
+
'After Count': element.afterCount,
|
|
3318
|
+
// 'User Name': element.userName,
|
|
3319
|
+
// 'User Email': element.userEmail,
|
|
3320
|
+
'Status': element.status,
|
|
3321
|
+
} );
|
|
3322
|
+
}
|
|
3255
3323
|
} );
|
|
3256
3324
|
await download( exportdata, res );
|
|
3257
3325
|
return;
|