tango-app-api-audit 3.3.0-alpha.21 → 3.3.0-alpha.23

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.21",
3
+ "version": "3.3.0-alpha.23",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1647,14 +1647,14 @@ export async function userAuditHistory( req, res ) {
1647
1647
  const exportData = [];
1648
1648
  chunk.forEach( ( element ) => {
1649
1649
  exportData.push( {
1650
-
1650
+ 'File Date': element.fileDate,
1651
1651
  'Brand ID': element.clientId,
1652
1652
  'Brand Name': element.clientName,
1653
1653
  'Store ID': element.storeId,
1654
1654
  'Store Name': element.storeName,
1655
- 'Zone Name': element.zoneName,
1655
+ 'Zone Name': element.moduleType == 'zone'? element.zoneName : '',
1656
1656
  'Audit Type': element.auditType,
1657
- 'Module Type': element.moduleType,
1657
+ 'Product Type': element.moduleType,
1658
1658
  'Before Count': element.beforeCount,
1659
1659
  'After Count': element.afterCount || '',
1660
1660
  'Accuracy': element.accuracy || '',
@@ -1662,7 +1662,7 @@ export async function userAuditHistory( req, res ) {
1662
1662
  'End Time': element.endTime || '',
1663
1663
  'Time Spent': element.timeSpent,
1664
1664
  'Audit Status': element.auditStatus,
1665
- 'CreatedAt': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
1665
+ 'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
1666
1666
 
1667
1667
  } );
1668
1668
  } );
@@ -1788,7 +1788,7 @@ export async function clientMetrics( req, res ) {
1788
1788
  completedStores: 1,
1789
1789
  inprogressStores: 1,
1790
1790
  notAssignedStores: 1,
1791
- fileCount: 1,
1791
+ fileCount: { $ifNull: [ '$fileCount', 0 ] },
1792
1792
  completionPercentage: { $ifNull: [
1793
1793
  {
1794
1794
  $round: [ {
@@ -1828,8 +1828,8 @@ export async function clientMetrics( req, res ) {
1828
1828
  // notAssignedStores: '$storeAudit.notAssignedStores',
1829
1829
  inprogressStoresCount: '$storeAudit.inprogressStores',
1830
1830
  // 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' ] } ] },
1831
+ notAssignedCount: { $subtract: [ '$totalFilesCount', { $subtract: [ { $ifNull: [ '$storeAudit.fileCount', 0 ] }, { $ifNull: [ '$storeAudit.notAssignedStores', 0 ] } ] } ] },
1832
+ 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
1833
  completedStores: '$storeAudit.completedStores',
1834
1834
  completionPercentage: '$storeAudit.completionPercentage',
1835
1835
 
@@ -1885,7 +1885,7 @@ export async function clientMetrics( req, res ) {
1885
1885
  'File Date': '$fileDate',
1886
1886
  'Client Name': '$clientName',
1887
1887
  'Client Id': '$clientId',
1888
- 'Module Type': '$moduleType',
1888
+ 'Product Type': '$moduleType',
1889
1889
  'Completed Percentage': '$completionPercentage',
1890
1890
  'Installed Stores': '$installedStore',
1891
1891
  'Audit Stores': '$totalFilesCount',
@@ -2127,6 +2127,7 @@ export async function storeMetrics( req, res ) {
2127
2127
  { status: { $regex: inputData.searchValue, $options: 'i' } },
2128
2128
  { auditType: { $regex: inputData.searchValue, $options: 'i' } },
2129
2129
  { moduleType: { $regex: inputData.searchValue, $options: 'i' } },
2130
+ { zoneName: { $regex: inputData.searchValue, $options: 'i' } },
2130
2131
  ],
2131
2132
  },
2132
2133
  } );
@@ -2159,19 +2160,36 @@ export async function storeMetrics( req, res ) {
2159
2160
  if ( inputData.isExport ) {
2160
2161
  const exportdata = [];
2161
2162
  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
- } );
2163
+ if ( element.moduleType == 'zone' ) {
2164
+ exportdata.push( {
2165
+ 'File Date': element.fileDate,
2166
+ 'Store ID': element.storeId,
2167
+ 'Store Name': element.storeName,
2168
+ 'Client Id': element.clientId,
2169
+ 'Client Name': element.clientName,
2170
+ 'Zone Name': element.zoneName,
2171
+ 'User Name': element.userName,
2172
+ 'User Email': element.userEmail,
2173
+ 'Audit Type': element.auditType,
2174
+ 'Accuracy': element.accuracy,
2175
+ 'Time Spent': element.timeSpent,
2176
+ 'Status': element.status,
2177
+ } );
2178
+ } else {
2179
+ exportdata.push( {
2180
+ 'File Date': element.fileDate,
2181
+ 'Store ID': element.storeId,
2182
+ 'Store Name': element.storeName,
2183
+ 'Client Id': element.clientId,
2184
+ 'Client Name': element.clientName,
2185
+ 'User Name': element.userName,
2186
+ 'User Email': element.userEmail,
2187
+ 'Audit Type': element.auditType,
2188
+ 'Accuracy': element.accuracy,
2189
+ 'Time Spent': element.timeSpent,
2190
+ 'Status': element.status,
2191
+ } );
2192
+ }
2175
2193
  } );
2176
2194
  await download( exportdata, res );
2177
2195
  return;
@@ -2597,18 +2615,32 @@ export async function pendingSummaryTable( req, res ) {
2597
2615
  if ( inputData.isExport ) {
2598
2616
  const exportdata = [];
2599
2617
  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
- } );
2618
+ if ( element.moduleType == 'zone' ) {
2619
+ exportdata.push( {
2620
+ 'Store ID': element.storeId,
2621
+ 'zoneName': element.zoneName,
2622
+ 'File Date': element.fileDate,
2623
+ 'Product Type': element.moduleType,
2624
+ 'Audit Type': element.auditType,
2625
+ 'Before Count': element.beforeCount,
2626
+ 'Start Time': element.startTime,
2627
+ 'User Name': element.userName,
2628
+ 'User Email': element.userEmail,
2629
+ 'Status': element.auditStatus,
2630
+ } );
2631
+ } else {
2632
+ exportdata.push( {
2633
+ 'Store ID': element.storeId,
2634
+ 'File Date': element.fileDate,
2635
+ 'Product Type': element.moduleType,
2636
+ 'Audit Type': element.auditType,
2637
+ 'Before Count': element.beforeCount,
2638
+ 'Start Time': element.startTime,
2639
+ 'User Name': element.userName,
2640
+ 'User Email': element.userEmail,
2641
+ 'Status': element.auditStatus,
2642
+ } );
2643
+ }
2612
2644
  } );
2613
2645
  await download( exportdata, res );
2614
2646
  return;
@@ -2883,7 +2915,7 @@ export async function reTrigger( req, res ) {
2883
2915
  await insertOpenSearchData( openSearch.auditLog, logData );
2884
2916
  }
2885
2917
 
2886
- return res.sendSuccess( { result: 'The File has been Re Trigger Succesfully' } );
2918
+ return res.sendSuccess( { result: 'The File has been Re-Triggered Succesfully' } );
2887
2919
  } catch ( error ) {
2888
2920
  const err = error.message;
2889
2921
  logger.error( { error: error, message: req.body, function: 'reTrigger' } );
@@ -3239,19 +3271,34 @@ export async function overviewTable( req, res ) {
3239
3271
  if ( inputData.isExport ) {
3240
3272
  const exportdata = [];
3241
3273
  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
- } );
3274
+ if ( element.moduleType == 'zone' ) {
3275
+ exportdata.push( {
3276
+ 'Store ID': element.storeId,
3277
+ 'Brand ID': element.clientId,
3278
+ 'Zone Name': element.zoneName,
3279
+ 'File Date': element.fileDate,
3280
+ 'Product Type': element.moduleType,
3281
+ 'Audit Type': element.auditType,
3282
+ 'Before Count': element.beforeCount,
3283
+ 'After Count': element.afterCount,
3284
+ // 'User Name': element.userName,
3285
+ // 'User Email': element.userEmail,
3286
+ 'Status': element.status,
3287
+ } );
3288
+ } else {
3289
+ exportdata.push( {
3290
+ 'Store ID': element.storeId,
3291
+ 'Brand ID': element.clientId,
3292
+ 'File Date': element.fileDate,
3293
+ 'Product Type': element.moduleType,
3294
+ 'Audit Type': element.auditType,
3295
+ 'Before Count': element.beforeCount,
3296
+ 'After Count': element.afterCount,
3297
+ // 'User Name': element.userName,
3298
+ // 'User Email': element.userEmail,
3299
+ 'Status': element.status,
3300
+ } );
3301
+ }
3255
3302
  } );
3256
3303
  await download( exportdata, res );
3257
3304
  return;