tango-app-api-audit 3.3.0-alpha.20 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-audit",
3
- "version": "3.3.0-alpha.20",
3
+ "version": "3.3.0-alpha.22",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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
- exportData.push( {
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
- 'Brand ID': element.clientId,
1652
- 'Brand Name': element.clientName,
1653
- 'Store ID': element.storeId,
1654
- 'Store Name': element.storeName,
1655
- 'Zone Name': element.zoneName,
1656
- 'Audit Type': element.auditType,
1657
- 'Module Type': element.moduleType,
1658
- 'Before Count': element.beforeCount,
1659
- 'After Count': element.afterCount || '',
1660
- 'Accuracy': element.accuracy || '',
1661
- 'Start Time': element.startTime,
1662
- 'End Time': element.endTime || '',
1663
- 'Time Spent': element.timeSpent,
1664
- 'Audit Status': element.auditStatus,
1665
- 'CreatedAt': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
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: 1,
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: 1,
1832
- clientStatus: { $cond: [ { $eq: [ '$storeAudit.fileCount', 0 ] }, 'not-taken', { $cond: [ { $or: [ { $gt: [ '$notAssignedCount', 0 ] }, { $gt: [ '$storeAudit.notAssignedStores', 0 ] } ] }, 'pending', 'completed' ] } ] },
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
- 'Module Type': '$moduleType',
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
- exportdata.push( {
2163
- 'File Date': element.fileDate,
2164
- 'Store ID': element.storeId,
2165
- 'Store Name': element.storeName,
2166
- 'Client Id': element.clientId,
2167
- 'Client Name': element.clientName,
2168
- 'User Name': element.userName,
2169
- 'User Email': element.userEmail,
2170
- 'Audit Type': element.auditType,
2171
- 'Accuracy': element.accuracy,
2172
- 'Time Spent': element.timeSpent,
2173
- 'Status': element.status,
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
- exportdata.push( {
2601
- 'Store ID': element.storeId,
2602
- 'zoneName': element.zoneName,
2603
- 'File Date': element.fileDate,
2604
- 'Module Type': element.moduleType,
2605
- 'Audit Type': element.auditType,
2606
- 'Before Count': element.beforeCount,
2607
- 'Start Time': element.startTime,
2608
- 'User Name': element.userName,
2609
- 'User Email': element.userEmail,
2610
- 'Status': element.auditStatus,
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;
@@ -2627,7 +2680,7 @@ export async function overAllAuditSummary( req, res ) {
2627
2680
  let temp = {
2628
2681
  installedStores: 0,
2629
2682
  auditStores: 0,
2630
- inprogreseStores: 0,
2683
+ inprogressStores: 0,
2631
2684
  completedStores: 0,
2632
2685
  auditInprogress: 0,
2633
2686
  reAuditInprogress: 0,
@@ -2724,7 +2777,7 @@ export async function overAllAuditSummary( req, res ) {
2724
2777
  ];
2725
2778
  const storeAudit = await aggregateStoreAudit( storeAuditQuery );
2726
2779
  if ( storeAudit.length > 0 ) {
2727
- temp.inprogreseStores= storeAudit[0].inprogreseStores;
2780
+ temp.inprogressStores= storeAudit[0].inprogressStores;
2728
2781
  temp.completedStores = storeAudit[0].completedStores;
2729
2782
  temp.auditInprogress = storeAudit[0].auditInprogress;
2730
2783
  temp.reAuditInprogress = storeAudit[0].reAuditInprogress;
@@ -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 Trigger Succesfully' } );
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
- exportdata.push( {
3243
- 'Store ID': element.storeId,
3244
- 'Client ID': element.clientId,
3245
- 'zoneName': element.zoneName,
3246
- 'File Date': element.fileDate,
3247
- 'Module Type': element.moduleType,
3248
- 'Audit Type': element.auditType,
3249
- 'Before Count': element.beforeCount,
3250
- 'After Count': element.afterCount,
3251
- // 'User Name': element.userName,
3252
- // 'User Email': element.userEmail,
3253
- 'Status': element.status,
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;