tango-app-api-audit 3.4.0-alpha.5 → 3.4.0-alpha.7

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.4.0-alpha.5",
3
+ "version": "3.4.0-alpha.7",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1450,6 +1450,9 @@ export async function userAuditHistory( req, res ) {
1450
1450
  const dateRangeCreatedAt = await getDateWithCustomizeTime( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
1451
1451
  let filter = [
1452
1452
  { userId: { $eq: userId } },
1453
+ {
1454
+ moduleType: { $eq: inputData.moduleType },
1455
+ },
1453
1456
  ];
1454
1457
 
1455
1458
  if ( inputData.dateType == 'fileDate' ) {
@@ -1464,12 +1467,6 @@ export async function userAuditHistory( req, res ) {
1464
1467
  );
1465
1468
  }
1466
1469
 
1467
- if ( inputData.filterByModuleType?.length > 0 ) {
1468
- filter.push( {
1469
- moduleType: { $in: inputData.filterByModuleType },
1470
- } );
1471
- }
1472
-
1473
1470
  if ( inputData.filterByAuditType?.length > 0 ) {
1474
1471
  filter.push( {
1475
1472
  auditType: { $in: inputData.filterByAuditType },
@@ -1705,23 +1702,18 @@ export async function clientMetrics( req, res ) {
1705
1702
  let filter = [
1706
1703
  { fileDateISO: { $gte: dateRange.start } },
1707
1704
  { fileDateISO: { $lte: dateRange.end } },
1705
+ { moduleType: { $eq: inputData.moduleType } },
1708
1706
  ];
1709
1707
 
1710
1708
  let storeAuditFilter = [
1711
1709
  { $eq: [ '$clientId', '$$clientId' ] },
1712
1710
  { $eq: [ '$fileDate', '$$fileDate' ] },
1711
+ {
1712
+ $eq: [ '$moduleType', inputData.moduleType ],
1713
+ },
1713
1714
 
1714
1715
  ];
1715
1716
 
1716
- if ( inputData?.filterByModuleType?.length> 0 ) {
1717
- filter.push(
1718
- { moduleType: { $in: inputData.filterByModuleType } },
1719
- );
1720
- storeAuditFilter.push( {
1721
- $in: [ '$moduleType', inputData.filterByModuleType ],
1722
- } );
1723
- }
1724
-
1725
1717
  if ( inputData?.filterByClient?.length> 0 ) {
1726
1718
  filter.push(
1727
1719
  { clientId: { $in: inputData.filterByClient } },
@@ -1930,6 +1922,7 @@ export async function storeMetrics( req, res ) {
1930
1922
  let filter = [
1931
1923
  { fileDateISO: { $gte: dateRange.start } },
1932
1924
  { fileDateISO: { $lte: dateRange.end } },
1925
+ { moduleType: { $eq: inputData.moduleType } },
1933
1926
 
1934
1927
  ];
1935
1928
  if ( inputData.filterByClientId && inputData.filterByClientId?.length > 0 ) {
@@ -1948,11 +1941,6 @@ export async function storeMetrics( req, res ) {
1948
1941
  filter.push( { auditType: { $in: inputData.filterByAuditType } } );
1949
1942
  }
1950
1943
 
1951
- if ( inputData.filterByModuleType && inputData.filterByModuleType?.length > 0 ) {
1952
- filter.push( { moduleType: { $in: inputData.filterByModuleType } } );
1953
- }
1954
-
1955
-
1956
1944
  const query = [
1957
1945
  {
1958
1946
  $match: {
@@ -2175,6 +2163,8 @@ export async function storeMetrics( req, res ) {
2175
2163
  'Zone Name': element.zoneName,
2176
2164
  'User Name': element.userName,
2177
2165
  'User Email': element.userEmail,
2166
+ 'Before Count': element.beforeCount,
2167
+ 'After Count': element.afterCount,
2178
2168
  'Audit Type': element.auditType,
2179
2169
  'Accuracy': element.accuracy,
2180
2170
  'Time Spent': element.timeSpent,
@@ -2189,6 +2179,8 @@ export async function storeMetrics( req, res ) {
2189
2179
  'Client Name': element.clientName,
2190
2180
  'User Name': element.userName,
2191
2181
  'User Email': element.userEmail,
2182
+ 'Before Count': element.beforeCount,
2183
+ 'After Count': element.afterCount,
2192
2184
  'Audit Type': element.auditType,
2193
2185
  'Accuracy': element.accuracy,
2194
2186
  'Time Spent': element.timeSpent,
@@ -2219,20 +2211,17 @@ export async function userMetrics( req, res ) {
2219
2211
  filter.push(
2220
2212
  { updatedAt: { $gte: dateRangeUpdatedAt.start } },
2221
2213
  { updatedAt: { $lte: dateRangeUpdatedAt.end } },
2214
+ { moduleType: { $eq: inputData.moduleType } },
2222
2215
 
2223
2216
  );
2224
2217
  } else {
2225
2218
  filter.push(
2226
2219
  { fileDateISO: { $gte: dateRange.start } },
2227
2220
  { fileDateISO: { $lte: dateRange.end } },
2221
+ { moduleType: { $eq: inputData.moduleType } },
2228
2222
 
2229
2223
  );
2230
2224
  }
2231
- if ( inputData?.filterByModuleType?.length> 0 ) {
2232
- filter.push(
2233
- { moduleType: { $in: inputData.filterByModuleType } },
2234
- );
2235
- }
2236
2225
  if ( inputData?.filterByStatus?.length> 0 ) {
2237
2226
  filter.push(
2238
2227
  { auditStatus: { $in: inputData.filterByStatus } },
@@ -2489,6 +2478,7 @@ export async function pendingSummaryTable( req, res ) {
2489
2478
  { fileDateISO: { $gte: dateRange.start } },
2490
2479
  { fileDateISO: { $lte: dateRange.end } },
2491
2480
  { auditStatus: { $ne: 'completed' } },
2481
+ { moduleType: { $eq: inputData.moduleType } },
2492
2482
 
2493
2483
  ];
2494
2484
 
@@ -2496,10 +2486,6 @@ export async function pendingSummaryTable( req, res ) {
2496
2486
  filters.push( { clientId: { $in: inputData.clientId } } );
2497
2487
  }
2498
2488
 
2499
- if ( inputData.filterByModuleType.length > 0 ) {
2500
- filters.push( { moduleType: { $in: inputData.filterByModuleType } } );
2501
- }
2502
-
2503
2489
  if ( inputData.filterByAuditType.length > 0 ) {
2504
2490
  filters.push( { auditType: { $in: inputData.filterByAuditType } } );
2505
2491
  }
@@ -2680,7 +2666,7 @@ export async function overAllAuditSummary( req, res ) {
2680
2666
  let filters =[
2681
2667
  { fileDateISO: { $gte: dateRange.start } },
2682
2668
  { fileDateISO: { $lte: dateRange.end } },
2683
- { moduleType: { $in: inputData.moduleType },
2669
+ { moduleType: { $eq: inputData.moduleType },
2684
2670
  },
2685
2671
  ];
2686
2672
  if ( inputData.clientId.length > 0 ) {
@@ -3030,13 +3016,11 @@ export async function summarySplit( req, res ) {
3030
3016
  let filters =[
3031
3017
  { fileDateISO: { $gte: dateRange.start } },
3032
3018
  { fileDateISO: { $lte: dateRange.end } },
3019
+ { moduleType: { $eq: inputData.moduleType } },
3033
3020
  ];
3034
3021
  if ( inputData.clientId.length > 0 ) {
3035
3022
  filters.push( { clientId: { $in: inputData.clientId } } );
3036
3023
  }
3037
- if ( inputData?.moduleType?.length > 0 ) {
3038
- filters.push( { moduleType: { $in: inputData.moduleType } } );
3039
- }
3040
3024
  const query =[
3041
3025
  {
3042
3026
  $match: {
@@ -3146,6 +3130,7 @@ export async function overviewTable( req, res ) {
3146
3130
  let filters =[
3147
3131
  { fileDateISO: { $gte: dateRange.start } },
3148
3132
  { fileDateISO: { $lte: dateRange.end } },
3133
+ { moduleType: { $eq: inputData.moduleType } },
3149
3134
 
3150
3135
  ];
3151
3136
 
@@ -3153,10 +3138,6 @@ export async function overviewTable( req, res ) {
3153
3138
  filters.push( { clientId: { $in: inputData.clientId } } );
3154
3139
  }
3155
3140
 
3156
- if ( inputData.filterByModuleType.length > 0 ) {
3157
- filters.push( { moduleType: { $in: inputData.filterByModuleType } } );
3158
- }
3159
-
3160
3141
  if ( inputData.filterByAuditType.length > 0 ) {
3161
3142
  filters.push( { auditType: { $in: inputData.filterByAuditType } } );
3162
3143
  }
@@ -10,6 +10,7 @@ import { aggregateAssignAudit } from '../service/assignAudit.service.js';
10
10
  import { aggregateStoreEmpDetection } from '../service/storeEmpDetection.service.js';
11
11
  import { listQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
12
12
  import _ from 'lodash';
13
+ import mongoose from 'mongoose';
13
14
 
14
15
 
15
16
  export async function getDetectionAuditFile( req, res ) {
@@ -1071,6 +1072,7 @@ export async function getAuditFile( req, res ) {
1071
1072
  fileDate: msg.fileDate,
1072
1073
  queueName: inputData.queueName,
1073
1074
  auditStatus: 'inprogress',
1075
+ AuditType: 'Audit',
1074
1076
  fileDateISO: start,
1075
1077
  timeSpent: 0,
1076
1078
  startTime: new Date(),
@@ -1145,7 +1147,10 @@ export async function getAuditFile( req, res ) {
1145
1147
  export async function saveBinary( req, res ) {
1146
1148
  try {
1147
1149
  const inputData = req.body;
1148
-
1150
+ const isoDate = req.userAudit?.startTime;
1151
+ const currentTime = dayjs();
1152
+ const isoDateTime = dayjs( isoDate );
1153
+ const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
1149
1154
  switch ( inputData.moduleType ) {
1150
1155
  case 'unattended-customer':
1151
1156
  let unattendedquery ={
@@ -1159,7 +1164,9 @@ export async function saveBinary( req, res ) {
1159
1164
  let update={
1160
1165
  auditStatus: 'completed',
1161
1166
  answer: inputData.answer,
1162
- userCommands: inputData.userComments || '',
1167
+ userComments: inputData.userComments || '',
1168
+ endTime: new Date(),
1169
+ timeSpent: timeDifferenceInMinutes,
1163
1170
  };
1164
1171
  let updatDataunattended= await updateOneBinaryAuditModel( unattendedquery, update );
1165
1172
  if ( updatDataunattended.modifiedCount==0 ) {
@@ -1181,7 +1188,9 @@ export async function saveBinary( req, res ) {
1181
1188
  let leftupdate={
1182
1189
  auditStatus: 'completed',
1183
1190
  answer: inputData.answer,
1184
- userCommands: inputData.userComments || '',
1191
+ userComments: inputData.userComments || '',
1192
+ endTime: new Date(),
1193
+ timeSpent: timeDifferenceInMinutes,
1185
1194
  };
1186
1195
  let updatDataleft= await updateOneBinaryAuditModel( leftquery, leftupdate );
1187
1196
  if ( updatDataleft.modifiedCount==0 ) {
@@ -1203,7 +1212,9 @@ export async function saveBinary( req, res ) {
1203
1212
  let cameraupdate={
1204
1213
  auditStatus: 'completed',
1205
1214
  answer: inputData.answer,
1206
- userCommands: inputData.userComments || '',
1215
+ userComments: inputData.userComments || '',
1216
+ endTime: new Date(),
1217
+ timeSpent: timeDifferenceInMinutes,
1207
1218
  };
1208
1219
  let updatDatacamera= await updateOneBinaryAuditModel( cameraquery, cameraupdate );
1209
1220
  if ( updatDatacamera.modifiedCount==0 ) {
@@ -1336,14 +1347,18 @@ export async function userAuditHistory( req, res ) {
1336
1347
  tempId: 1,
1337
1348
  streamName: 1,
1338
1349
  question: 1,
1350
+ questionType: 1,
1339
1351
  answer: 1,
1352
+ userComments: 1,
1340
1353
  storeName: '$store.storeName',
1341
1354
  clientId: 1,
1342
1355
  clientName: '$client.clientName',
1343
1356
  fileDate: 1,
1344
1357
  auditType: 1,
1345
- zoneName: 1,
1346
1358
  moduleType: 1,
1359
+ value: {
1360
+ $replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
1361
+ },
1347
1362
  beforeCount: 1,
1348
1363
  afterCount: 1,
1349
1364
  accuracy: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, { $round: [
@@ -1410,11 +1425,12 @@ export async function userAuditHistory( req, res ) {
1410
1425
  { storeId: { $regex: inputData.searchValue, $options: 'i' } },
1411
1426
  { storeName: { $regex: inputData.searchValue, $options: 'i' } },
1412
1427
  { streamName: { $regex: inputData.searchValue, $options: 'i' } },
1413
- { moduleType: { $regex: inputData.searchValue, $options: 'i' } },
1428
+ { value: { $regex: inputData.searchValue, $options: 'i' } },
1414
1429
  { auditType: { $regex: inputData.searchValue, $options: 'i' } },
1415
1430
  { auditStatus: { $regex: inputData.searchValue, $options: 'i' } },
1416
1431
  { tempId: { $regex: inputData.searchValue, $options: 'i' } },
1417
1432
  { question: { $regex: inputData.searchValue, $options: 'i' } },
1433
+ { userComments: { $regex: inputData.searchValue, $options: 'i' } },
1418
1434
  ],
1419
1435
 
1420
1436
  },
@@ -1439,25 +1455,50 @@ export async function userAuditHistory( req, res ) {
1439
1455
  const promises = chunkedMappingData.map( async ( chunk ) => {
1440
1456
  const exportData = [];
1441
1457
  chunk.forEach( ( element ) => {
1442
- exportData.push( {
1458
+ const temp ={
1459
+
1443
1460
  'File Date': element.fileDate,
1444
1461
  'Brand ID': element.clientId,
1445
1462
  'Brand Name': element.clientName,
1446
1463
  'Store ID': element.storeId,
1447
1464
  'Store Name': element.storeName,
1448
- 'Stream Name': element.moduleType == 'camera-angle-change'? element.zoneName : '',
1449
1465
  'Audit Type': element.auditType,
1450
- 'Product Type': element.moduleType,
1451
- 'Before Count': element.beforeCount,
1452
- 'After Count': element.afterCount || '',
1453
- 'Accuracy': element.accuracy || '',
1466
+ 'Product Type': element.value,
1454
1467
  'Start Time': element.startTime,
1455
1468
  'End Time': element.endTime || '',
1456
1469
  'Time Spent': element.timeSpent,
1457
- 'Audit Status': element.auditStatus,
1470
+ 'Status': element.auditStatus,
1458
1471
  'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
1472
+ 'Result': element.answer,
1459
1473
 
1460
- } );
1474
+
1475
+ };
1476
+ switch ( inputData.moduleType ) {
1477
+ case 'camera-angle-change':
1478
+ temp['stream Name'] = element.streamName;
1479
+ temp['User Comments'] = element.userCommands;
1480
+ break;
1481
+ case 'unattended-customer':
1482
+ temp['Customer ID'] = element.tempId;
1483
+ temp['Question'] = element.question;
1484
+ temp['User Comments'] = element.userCommands;
1485
+ break;
1486
+ case 'left-in-middle':
1487
+ temp['Question'] = element.question;
1488
+ temp['User Comments'] = element.userCommands;
1489
+ break;
1490
+ case 'uniform-detection':
1491
+ temp['Before Count'] = element.beforeCount;
1492
+ temp['After Count'] = element.afterCount;
1493
+ temp['Accuracy'] = element.accuracy || '';
1494
+ break;
1495
+ case 'mobile-detection':
1496
+ temp['Before Count'] = element.beforeCount;
1497
+ temp['After Count'] = element.afterCount;
1498
+ temp['Accuracy'] = element.accuracy || '';
1499
+ break;
1500
+ }
1501
+ exportData.push( temp );
1461
1502
  } );
1462
1503
  return exportData;
1463
1504
  } );
@@ -1610,6 +1651,9 @@ export async function clientMetrics( req, res ) {
1610
1651
  clientName: 1,
1611
1652
  totalFilesCount: 1,
1612
1653
  moduleType: 1,
1654
+ value: {
1655
+ $replaceAll: { input: '$moduleType', find: '-', replacement: ' ' }, // Replacing "-" with " "
1656
+ },
1613
1657
  installedStore: 1,
1614
1658
  // notAssignedStores: '$binaryAudit.notAssignedStores',
1615
1659
  inprogressStoresCount: '$binaryAudit.inprogressStores',
@@ -1672,7 +1716,7 @@ export async function clientMetrics( req, res ) {
1672
1716
  'File Date': '$fileDate',
1673
1717
  'Client Name': '$clientName',
1674
1718
  'Client Id': '$clientId',
1675
- 'Product Type': '$moduleType',
1719
+ 'Product Type': '$value',
1676
1720
  'Completed Percentage': '$completionPercentage',
1677
1721
  'Installed Stores': '$installedStore',
1678
1722
  'Audit Stores': '$totalFilesCount',
@@ -1768,6 +1812,7 @@ export async function storeMetrics( req, res ) {
1768
1812
  },
1769
1813
  {
1770
1814
  $project: {
1815
+ auditId: '$_id',
1771
1816
  _id: 0,
1772
1817
  fileDate: 1,
1773
1818
  storeId: 1,
@@ -1775,13 +1820,18 @@ export async function storeMetrics( req, res ) {
1775
1820
  clientName: '',
1776
1821
  clientId: 1,
1777
1822
  moduleType: 1,
1823
+ value: {
1824
+ $replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
1825
+ },
1778
1826
  tempId: 1,
1779
1827
  streamName: 1,
1780
1828
  question: 1,
1829
+ questionType: 1,
1781
1830
  answer: 1,
1782
1831
  // userId: {
1783
1832
  // $arrayElemAt: [ '$userId', { $subtract: [ { $size: '$userId' }, 1 ] } ], //need to check if no data
1784
1833
  // },
1834
+ userId: 1,
1785
1835
  auditType: 1,
1786
1836
  beforeCount: 1,
1787
1837
  afterCount: { $ifNull: [ '$afterCount', null ] },
@@ -1793,6 +1843,7 @@ export async function storeMetrics( req, res ) {
1793
1843
  }, null ] },
1794
1844
  timeSpent: 1,
1795
1845
  status: 1,
1846
+ auditStatus: 1,
1796
1847
  },
1797
1848
  },
1798
1849
  {
@@ -1852,7 +1903,7 @@ export async function storeMetrics( req, res ) {
1852
1903
  },
1853
1904
  {
1854
1905
  $project: {
1855
- _id: 0,
1906
+ auditId: 1,
1856
1907
  fileDate: 1,
1857
1908
  storeId: 1,
1858
1909
  storeName: 1,
@@ -1863,8 +1914,10 @@ export async function storeMetrics( req, res ) {
1863
1914
  tempId: 1,
1864
1915
  streamName: 1,
1865
1916
  question: 1,
1917
+ questionType: 1,
1866
1918
  answer: 1,
1867
1919
  moduleType: 1,
1920
+ value: 1,
1868
1921
  auditType: 1,
1869
1922
  beforeCount: 1,
1870
1923
  afterCount: { $ifNull: [ '$afterCount', null ] },
@@ -1900,6 +1953,7 @@ export async function storeMetrics( req, res ) {
1900
1953
 
1901
1954
  },
1902
1955
  status: 1,
1956
+ auditStatus: 1,
1903
1957
  },
1904
1958
  },
1905
1959
 
@@ -1916,10 +1970,11 @@ export async function storeMetrics( req, res ) {
1916
1970
  { userName: { $regex: inputData.searchValue, $options: 'i' } },
1917
1971
  { status: { $regex: inputData.searchValue, $options: 'i' } },
1918
1972
  { auditType: { $regex: inputData.searchValue, $options: 'i' } },
1919
- { moduleType: { $regex: inputData.searchValue, $options: 'i' } },
1973
+ { value: { $regex: inputData.searchValue, $options: 'i' } },
1920
1974
  { tempId: { $regex: inputData.searchValue, $options: 'i' } },
1921
1975
  { question: { $regex: inputData.searchValue, $options: 'i' } },
1922
1976
  { answer: { $regex: inputData.searchValue, $options: 'i' } },
1977
+ { auditStatus: { $regex: inputData.searchValue, $options: 'i' } },
1923
1978
  ],
1924
1979
  },
1925
1980
  } );
@@ -1952,41 +2007,47 @@ export async function storeMetrics( req, res ) {
1952
2007
  if ( inputData.isExport ) {
1953
2008
  const exportdata = [];
1954
2009
  result.forEach( ( element ) => {
1955
- if ( element.moduleType == 'zone' ) {
1956
- exportdata.push( {
1957
- 'File Date': element.fileDate,
1958
- 'Store ID': element.storeId,
1959
- 'Store Name': element.storeName,
1960
- 'Client Id': element.clientId,
1961
- 'Client Name': element.clientName,
1962
- 'Customer Id': element.tempId,
1963
- 'Question': element.question,
1964
- 'Answer': element.answer,
1965
- 'User Name': element.userName,
1966
- 'User Email': element.userEmail,
1967
- 'Audit Type': element.auditType,
1968
- 'Accuracy': element.accuracy,
1969
- 'Time Spent': element.timeSpent,
1970
- 'Status': element.status,
1971
- } );
1972
- } else {
1973
- exportdata.push( {
1974
- 'File Date': element.fileDate,
1975
- 'Store ID': element.storeId,
1976
- 'Store Name': element.storeName,
1977
- 'Client Id': element.clientId,
1978
- 'Client Name': element.clientName,
1979
- 'User Name': element.userName,
1980
- 'Customer Id': element.tempId,
1981
- 'Question': element.question,
1982
- 'Answer': element.answer,
1983
- 'User Email': element.userEmail,
1984
- 'Audit Type': element.auditType,
1985
- 'Accuracy': element.accuracy,
1986
- 'Time Spent': element.timeSpent,
1987
- 'Status': element.status,
1988
- } );
2010
+ const temp ={
2011
+ 'File Date': element.fileDate,
2012
+ 'Store ID': element.storeId,
2013
+ 'Store Name': element.storeName,
2014
+ 'Client Id': element.clientId,
2015
+ 'Client Name': element.clientName,
2016
+ 'User Name': element.userName,
2017
+ 'User Email': element.userEmail,
2018
+ 'Audit Type': element.auditType,
2019
+ 'Time Spent': element.timeSpent,
2020
+ 'Result': element.answer,
2021
+ };
2022
+ switch ( inputData.moduleType ) {
2023
+ case 'camera-angle-change':
2024
+ temp['stream Name'] = element.streamName;
2025
+ temp['User Comments'] = element.auditStatus;
2026
+ break;
2027
+ case 'unattended-customer':
2028
+ temp['Customer ID'] = element.tempId;
2029
+ temp['Question'] = element.question;
2030
+ temp['User Comments'] = element.auditStatus;
2031
+ break;
2032
+ case 'left-in-middle':
2033
+ temp['Question'] = element.question;
2034
+ temp['User Comments'] = element.userCommands;
2035
+ temp['Status'] = element.auditStatus;
2036
+ break;
2037
+ case 'mobile-detection':
2038
+ temp['Before Count'] = element.beforeCount;
2039
+ temp['After Count'] = element.afterCount;
2040
+ temp['Status'] = element.status;
2041
+ temp['Accuracy'] = element.accuracy;
2042
+ break;
2043
+ case 'uniform-detection':
2044
+ temp['Before Count'] = element.beforeCount;
2045
+ temp['After Count'] = element.afterCount;
2046
+ temp['Status'] = element.status;
2047
+ temp['Accuracy'] = element.accuracy;
2048
+ break;
1989
2049
  }
2050
+ exportdata.push( temp );
1990
2051
  } );
1991
2052
  await download( exportdata, res );
1992
2053
  return;
@@ -2046,15 +2107,18 @@ export async function userMetrics( req, res ) {
2046
2107
  userId: 1,
2047
2108
  fileDate: 1,
2048
2109
  startTime: 1,
2049
- endTime: 1,
2050
- streamName: 1,
2051
- tempId: 1,
2052
- question: 1,
2053
- answer: 1,
2110
+ beforeCount: 1,
2111
+ moduleType: 1,
2112
+ afterCount: 1,
2113
+ checkIntime: 1,
2114
+ checkOutTime: 1,
2054
2115
  totalCompletedFiles: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, 1, 0 ] },
2055
2116
  beforeCount: 1,
2056
2117
  afterCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$afterCount', 0 ] },
2057
- },
2118
+
2119
+ value: {
2120
+ $replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
2121
+ } },
2058
2122
  },
2059
2123
  {
2060
2124
  $group: {
@@ -2066,11 +2130,8 @@ export async function userMetrics( req, res ) {
2066
2130
  afterCount: { $sum: '$afterCount' },
2067
2131
  checkIntime: { $first: '$startTime' },
2068
2132
  checkOutTime: { $last: '$endTime' },
2069
- streamName: { $last: '$streamName' },
2070
- tempId: { $last: '$tempId' },
2071
- question: { $last: '$question' },
2072
- answer: { $last: '$answer' },
2073
-
2133
+ moduleType: { $last: '$moduleType' },
2134
+ value: { $last: '$value' },
2074
2135
  },
2075
2136
  },
2076
2137
  {
@@ -2079,12 +2140,10 @@ export async function userMetrics( req, res ) {
2079
2140
  userId: 1,
2080
2141
  fileDate: 1,
2081
2142
  totalCompletedFiles: 1,
2143
+ moduleType: 1,
2144
+ value: 1,
2082
2145
  beforeCount: 1,
2083
2146
  afterCount: 1,
2084
- streamName: 1,
2085
- tempId: 1,
2086
- question: 1,
2087
- answer: 1,
2088
2147
  // mappingPerc: { $round: [
2089
2148
  // { $multiply: [
2090
2149
  // { $divide: [ '$afterCount', '$beforeCount' ] }, 100,
@@ -2106,11 +2165,9 @@ export async function userMetrics( req, res ) {
2106
2165
  afterCount: 1,
2107
2166
  checkIntime: 1,
2108
2167
  checkOutTime: 1,
2168
+ moduleType: 1,
2169
+ value: 1,
2109
2170
  // mappingPerc: 1,
2110
- streamName: 1,
2111
- tempId: 1,
2112
- question: 1,
2113
- answer: 1,
2114
2171
  hours: { $floor: { $divide: [ '$differenceInSeconds', 3600 ] } },
2115
2172
  minutes: { $floor: { $divide: [ { $mod: [ '$differenceInSeconds', 3600 ] }, 60 ] } },
2116
2173
  seconds: { $mod: [ '$differenceInSeconds', 60 ] },
@@ -2126,11 +2183,9 @@ export async function userMetrics( req, res ) {
2126
2183
  afterCount: 1,
2127
2184
  checkIntime: 1,
2128
2185
  checkOutTime: 1,
2186
+ moduleType: 1,
2187
+ value: 1,
2129
2188
  // mappingPerc: 1,
2130
- streamName: 1,
2131
- tempId: 1,
2132
- question: 1,
2133
- answer: 1,
2134
2189
  hours: {
2135
2190
  $cond: {
2136
2191
  if: { $lt: [ '$hours', 10 ] },
@@ -2152,7 +2207,6 @@ export async function userMetrics( req, res ) {
2152
2207
  else: { $toString: { $round: [ '$seconds', 0 ] } },
2153
2208
  },
2154
2209
  },
2155
-
2156
2210
  },
2157
2211
  },
2158
2212
  {
@@ -2164,13 +2218,12 @@ export async function userMetrics( req, res ) {
2164
2218
  beforeCount: 1,
2165
2219
  afterCount: 1,
2166
2220
  checkIntime: 1,
2167
- zoneName: 1,
2168
2221
  checkOutTime: 1,
2222
+ moduleType: 1,
2223
+ value: {
2224
+ $replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
2225
+ },
2169
2226
  // mappingPerc: 1,
2170
- streamName: 1,
2171
- tempId: 1,
2172
- question: 1,
2173
- answer: 1,
2174
2227
  workingHours: {
2175
2228
  $concat: [ '$hours', ':', '$minutes', ':', '$seconds' ],
2176
2229
  },
@@ -2211,11 +2264,11 @@ export async function userMetrics( req, res ) {
2211
2264
  totalCompletedFiles: 1,
2212
2265
  beforeCount: 1,
2213
2266
  afterCount: 1,
2267
+ moduleType: 1,
2268
+ value: {
2269
+ $replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
2270
+ },
2214
2271
  // mappingPerc: 1,
2215
- streamName: 1,
2216
- tempId: 1,
2217
- question: 1,
2218
- answer: 1,
2219
2272
  checkIntime: {
2220
2273
  $dateToString: {
2221
2274
  format: '%Y-%m-%d %H:%M:%S',
@@ -2264,24 +2317,39 @@ export async function userMetrics( req, res ) {
2264
2317
  { $limit: limit },
2265
2318
  );
2266
2319
  if ( inputData.isExport ) {
2320
+ const detection = {
2321
+ '_id': 0,
2322
+ 'File Date': '$fileDate',
2323
+ 'User Name': '$userName',
2324
+ 'Total Completed Files Count': '$totalCompletedFiles',
2325
+ 'Total Before Count': '$beforeCount',
2326
+ 'Total After Count': '$afterCount',
2327
+ 'check Intime': '$checkIntime',
2328
+ 'check OutTime': '$checkOutTime',
2329
+ 'working Hours': '$workingHours',
2330
+ 'Product Type': '$value',
2331
+ // 'Mapping Percentage': '$mappingPerc',
2332
+ };
2333
+ const YesNo = {
2334
+ '_id': 0,
2335
+ 'File Date': '$fileDate',
2336
+ 'User Name': '$userName',
2337
+ 'Total Completed Files Count': '$totalCompletedFiles',
2338
+ 'check Intime': '$checkIntime',
2339
+ 'check OutTime': '$checkOutTime',
2340
+ 'working Hours': '$workingHours',
2341
+ 'Product Type': '$value',
2342
+ // 'Mapping Percentage': '$mappingPerc',
2343
+ };
2344
+ inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )?
2267
2345
  query.push(
2268
2346
  {
2269
- $project: {
2270
- '_id': 0,
2271
- 'File Date': '$fileDate',
2272
- 'User Name': '$userName',
2273
- 'Total Completed Files Count': '$totalCompletedFiles',
2274
- 'Total Before Count': '$beforeCount',
2275
- 'Total After Count': '$afterCount',
2276
- 'check Intime': '$checkIntime',
2277
- 'check OutTime': '$checkOutTime',
2278
- 'working Hours': '$workingHours',
2279
- 'Mapping Percentage': '$mappingPerc',
2280
- 'Customer ID': '$tempId',
2281
- 'Stream Name': '$streamName',
2282
- 'Question': '$question',
2283
- 'Answer': '$answer',
2284
- },
2347
+ $project: detection,
2348
+ },
2349
+ ) :
2350
+ query.push(
2351
+ {
2352
+ $project: YesNo,
2285
2353
  },
2286
2354
  );
2287
2355
  }
@@ -2339,10 +2407,14 @@ export async function pendingSummaryTable( req, res ) {
2339
2407
  streamName: 1,
2340
2408
  tempId: 1,
2341
2409
  question: 1,
2410
+ questionType: 1,
2342
2411
  answer: 1,
2343
- userCommands: 1,
2412
+ userComments: 1,
2344
2413
  fileDate: 1,
2345
2414
  moduleType: 1,
2415
+ value: {
2416
+ $replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
2417
+ },
2346
2418
  beforeCount: 1,
2347
2419
  startTime: { $dateToString: {
2348
2420
  format: '%Y-%m-%d %H:%M:%S',
@@ -2389,10 +2461,12 @@ export async function pendingSummaryTable( req, res ) {
2389
2461
  streamName: 1,
2390
2462
  tempId: 1,
2391
2463
  question: 1,
2464
+ questionType: 1,
2392
2465
  answer: 1,
2393
- userCommands: 1,
2466
+ userComments: 1,
2394
2467
  fileDate: 1,
2395
2468
  moduleType: 1,
2469
+ value: 1,
2396
2470
  beforeCount: 1,
2397
2471
  startTime: 1,
2398
2472
  endTime: 1,
@@ -2414,6 +2488,7 @@ export async function pendingSummaryTable( req, res ) {
2414
2488
  { auditStatus: { $regex: inputData.searchValue, $options: 'i' } },
2415
2489
  { userName: { $regex: inputData.searchValue, $options: 'i' } },
2416
2490
  { userEmail: { $regex: inputData.searchValue, $options: 'i' } },
2491
+ { value: { $regex: inputData.searchValue, $options: 'i' } },
2417
2492
  ],
2418
2493
 
2419
2494
  },
@@ -2447,41 +2522,40 @@ export async function pendingSummaryTable( req, res ) {
2447
2522
  if ( inputData.isExport ) {
2448
2523
  const exportdata = [];
2449
2524
  result.forEach( ( element ) => {
2450
- if ( element.moduleType == 'zone' ) {
2451
- exportdata.push( {
2452
- 'Store ID': element.storeId,
2453
- 'Stream Name': element.streamName,
2454
- 'Customer ID': element.tempId,
2455
- 'Question': question,
2456
- 'Answer': element.answer,
2457
- 'userComments': element.userCommands,
2458
- 'File Date': element.fileDate,
2459
- 'Product Type': element.moduleType,
2460
- 'Audit Type': element.auditType,
2461
- 'Before Count': element.beforeCount,
2462
- 'Start Time': element.startTime,
2463
- 'User Name': element.userName,
2464
- 'User Email': element.userEmail,
2465
- 'Status': element.auditStatus,
2466
- } );
2467
- } else {
2468
- exportdata.push( {
2469
- 'Store ID': element.storeId,
2470
- 'Stream Name': element.streamName,
2471
- 'Customer ID': element.tempId,
2472
- 'Question': question,
2473
- 'Answer': element.answer,
2474
- 'userComments': element.userCommands,
2475
- 'File Date': element.fileDate,
2476
- 'Product Type': element.moduleType,
2477
- 'Audit Type': element.auditType,
2478
- 'Before Count': element.beforeCount,
2479
- 'Start Time': element.startTime,
2480
- 'User Name': element.userName,
2481
- 'User Email': element.userEmail,
2482
- 'Status': element.auditStatus,
2483
- } );
2525
+ const temp = {
2526
+ 'Store ID': element.storeId,
2527
+ 'Result': element.answer,
2528
+ 'userComments': element.userComments,
2529
+ 'File Date': element.fileDate,
2530
+ 'Product Type': element.value,
2531
+ 'Audit Type': element.auditType,
2532
+ 'Start Time': element.startTime,
2533
+ 'User Name': element.userName,
2534
+ 'User Email': element.userEmail,
2535
+ 'Status': element.auditStatus,
2536
+ };
2537
+ switch ( inputData.moduleType ) {
2538
+ case 'camera-angle-change':
2539
+ temp['stream Name'] = element.streamName;
2540
+ temp['User Comments'] = element.userCommands;
2541
+ break;
2542
+ case 'unattended-customer':
2543
+ temp['Customer ID'] = element.tempId;
2544
+ temp['Question'] = element.question;
2545
+ temp['User Comments'] = element.userCommands;
2546
+ break;
2547
+ case 'left-in-middle':
2548
+ temp['Question'] = element.question;
2549
+ temp['User Comments'] = element.userCommands;
2550
+ break;
2551
+ case 'mobile-detection':
2552
+ temp['Before Count'] = element.beforeCount;
2553
+ break;
2554
+ case 'uniform-detection':
2555
+ temp['Before Count'] = element.beforeCount;
2556
+ break;
2484
2557
  }
2558
+ exportdata.push( temp );
2485
2559
  } );
2486
2560
  await download( exportdata, res );
2487
2561
  return;
@@ -2616,90 +2690,6 @@ export async function overAllAuditSummary( req, res ) {
2616
2690
  }
2617
2691
  }
2618
2692
 
2619
- export async function overViewCard( req, res ) {
2620
- try {
2621
- const inputData = req.body;
2622
- const temp = {
2623
- totalCount: 0,
2624
- auditFileCount: 0,
2625
- ReAuditFileCount: 0,
2626
- inprogressCount: 0,
2627
- completedCount: 0,
2628
- pendingCount: 0,
2629
- };
2630
-
2631
- const dateRange = await getUTC( new Date( inputData.fromDate ), new Date( inputData.toDate ) );
2632
- let filters =[
2633
- { fileDateISO: { $gte: dateRange.start } },
2634
- { fileDateISO: { $lte: dateRange.end } },
2635
- ];
2636
- if ( inputData.clientId.length > 0 ) {
2637
- filters.push( { clientId: { $in: inputData.clientId } } );
2638
- }
2639
- const query =[
2640
- {
2641
- $match: {
2642
- $and: filters,
2643
- },
2644
-
2645
- },
2646
- {
2647
- $project: {
2648
- auditFileCount: {
2649
- $cond: [
2650
- { $eq: [ '$auditType', 'Audit' ] }, 1, 0,
2651
- ],
2652
- },
2653
- ReAuditFileCount: {
2654
- $cond: [
2655
- { $eq: [ '$auditType', 'ReAudit' ] }, 1, 0,
2656
- ],
2657
- },
2658
- inprogressCount: {
2659
- $cond: [
2660
- { $ne: [ '$status', 'completed' ] }, 1, 0,
2661
- ],
2662
- },
2663
- completedCount: {
2664
- $cond: [
2665
- { $eq: [ '$status', 'completed' ] }, 1, 0,
2666
- ],
2667
- },
2668
- },
2669
- },
2670
- {
2671
- $group: {
2672
- _id: { fileDate: '$fileDate', clientId: '$clientId' },
2673
- totalCount: { $sum: 1 },
2674
- auditFileCount: { $sum: '$auditFileCount' },
2675
- ReAuditFileCount: { $sum: '$ReAuditFileCount' },
2676
- inprogressCount: { $sum: '$inprogressCount' },
2677
- completedCount: { $sum: '$completedCount' },
2678
-
2679
- },
2680
- },
2681
- {
2682
- $project: {
2683
- _id: 0,
2684
- totalCount: 1,
2685
- auditFileCount: 1,
2686
- ReAuditFileCount: 1,
2687
- inprogressCount: 1,
2688
- completedCount: 1,
2689
- notAssigned: { $subtract: [ '$totalCount', { $add: [ '$inprogressCount', '$completedCount' ] } ] },
2690
- },
2691
- },
2692
- ];
2693
- const result = inputData.moduleType.includes( [ 'uniform-detection', 'mobile-detection' ] )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
2694
- logger.info( { result: result } );
2695
- return res.sendSuccess( { result: result.length> 0? result[0]: temp } );
2696
- } catch ( error ) {
2697
- const err = error.message || 'Internal Server Error';
2698
- logger.error( { error: error, message: req.body, function: 'overViewCard' } );
2699
- return res.sendError( err, 500 );
2700
- }
2701
- }
2702
-
2703
2693
  export async function summarySplit( req, res ) {
2704
2694
  try {
2705
2695
  const inputData = req.body;
@@ -2862,14 +2852,20 @@ export async function overviewTable( req, res ) {
2862
2852
  streamName: 1,
2863
2853
  tempId: 1,
2864
2854
  question: 1,
2855
+ questionType: 1,
2865
2856
  answer: 1,
2866
- userCommands: 1,
2857
+ userComments: 1,
2867
2858
  fileDate: 1,
2868
2859
  moduleType: 1,
2860
+
2861
+ value: {
2862
+ $replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
2863
+ },
2869
2864
  beforeCount: 1,
2870
2865
  afterCount: 1,
2871
2866
  auditType: 1,
2872
2867
  status: 1,
2868
+ auditStatus: 1,
2873
2869
  // userId: 1,
2874
2870
  },
2875
2871
  },
@@ -2907,14 +2903,17 @@ export async function overviewTable( req, res ) {
2907
2903
  streamName: 1,
2908
2904
  tempId: 1,
2909
2905
  question: 1,
2906
+ questionType: 1,
2910
2907
  answer: 1,
2911
- userCommands: 1,
2908
+ userComments: 1,
2912
2909
  fileDate: 1,
2913
2910
  moduleType: 1,
2911
+ value: 1,
2914
2912
  beforeCount: 1,
2915
2913
  afterCount: 1,
2916
2914
  auditType: 1,
2917
2915
  status: 1,
2916
+ auditStatus: 1,
2918
2917
  // userName: '$user.userName',
2919
2918
  // userEmail: '$user.userEmail',
2920
2919
 
@@ -2930,12 +2929,13 @@ export async function overviewTable( req, res ) {
2930
2929
  { fileDate: { $regex: inputData.searchValue, $options: 'i' } },
2931
2930
  { auditType: { $regex: inputData.searchValue, $options: 'i' } },
2932
2931
  { status: { $regex: inputData.searchValue, $options: 'i' } },
2933
- { moduleType: { $regex: inputData.searchValue, $options: 'i' } },
2932
+ { auditStatus: { $regex: inputData.searchValue, $options: 'i' } },
2933
+ { value: { $regex: inputData.searchValue, $options: 'i' } },
2934
2934
  { streamName: { $regex: inputData.searchValue, $options: 'i' } },
2935
2935
  { tempId: { $regex: inputData.searchValue, $options: 'i' } },
2936
2936
  { question: { $regex: inputData.searchValue, $options: 'i' } },
2937
2937
  { answer: { $regex: inputData.searchValue, $options: 'i' } },
2938
- { userCommands: { $regex: inputData.searchValue, $options: 'i' } },
2938
+ { userComments: { $regex: inputData.searchValue, $options: 'i' } },
2939
2939
  // { userName: { $regex: inputData.searchValue, $options: 'i' } },
2940
2940
  // { userEmail: { $regex: inputData.searchValue, $options: 'i' } },
2941
2941
  ],
@@ -2970,43 +2970,43 @@ export async function overviewTable( req, res ) {
2970
2970
  if ( inputData.isExport ) {
2971
2971
  const exportdata = [];
2972
2972
  result.forEach( ( element ) => {
2973
- if ( element.moduleType == 'zone' ) {
2974
- exportdata.push( {
2975
- 'Store ID': element.storeId,
2976
- 'Brand ID': element.clientId,
2977
- 'Stream Name': element.streamName,
2978
- 'Customer ID': element.tempId,
2979
- 'Question': element.question,
2980
- 'Answer': element.answer,
2981
- 'User Comments': element.userCommands,
2982
- 'File Date': element.fileDate,
2983
- 'Product Type': element.moduleType,
2984
- 'Audit Type': element.auditType,
2985
- 'Before Count': element.beforeCount,
2986
- 'After Count': element.afterCount,
2987
- // 'User Name': element.userName,
2988
- // 'User Email': element.userEmail,
2989
- 'Status': element.status,
2990
- } );
2991
- } else {
2992
- exportdata.push( {
2993
- 'Store ID': element.storeId,
2994
- 'Brand ID': element.clientId,
2995
- 'File Date': element.fileDate,
2996
- 'Stream Name': element.streamName,
2997
- 'Customer ID': element.tempId,
2998
- 'Question': element.question,
2999
- 'Answer': element.answer,
3000
- 'User Comments': element.userCommands,
3001
- 'Product Type': element.moduleType,
3002
- 'Audit Type': element.auditType,
3003
- 'Before Count': element.beforeCount,
3004
- 'After Count': element.afterCount,
3005
- // 'User Name': element.userName,
3006
- // 'User Email': element.userEmail,
3007
- 'Status': element.status,
3008
- } );
2973
+ const temp ={
2974
+ 'Store ID': element.storeId,
2975
+ 'Brand ID': element.clientId,
2976
+ 'File Date': element.fileDate,
2977
+ 'Result': element.answer,
2978
+ 'Product Type': element.value,
2979
+ 'Audit Type': element.auditType,
2980
+ // 'User Name': element.userName,
2981
+ // 'User Email': element.userEmail,
2982
+ 'Status': element.status,
2983
+ 'Audit Status': element.status,
2984
+ };
2985
+
2986
+ switch ( inputData.moduleType ) {
2987
+ case 'camera-angle-change':
2988
+ temp['stream Name'] = element.streamName;
2989
+ temp['User Comments'] = element.userCommands;
2990
+ break;
2991
+ case 'unattended-customer':
2992
+ temp['Customer ID'] = element.tempId;
2993
+ temp['Question'] = element.question;
2994
+ temp['User Comments'] = element.userCommands;
2995
+ break;
2996
+ case 'left-in-middle':
2997
+ temp['Question'] = element.question;
2998
+ temp['User Comments'] = element.userCommands;
2999
+ break;
3000
+ case 'mobile-detection':
3001
+ temp['Before Count'] = element.beforeCount;
3002
+ temp['After Count'] = element.afterCount;
3003
+ break;
3004
+ case 'uniform-detection':
3005
+ temp['Before Count'] = element.beforeCount;
3006
+ temp['After Count'] = element.afterCount;
3007
+ break;
3009
3008
  }
3009
+ exportdata.push( temp );
3010
3010
  } );
3011
3011
  await download( exportdata, res );
3012
3012
  return;
@@ -1,5 +1,5 @@
1
1
  import j2s from 'joi-to-swagger';
2
- import { getFileSchema, userAuditHistorySchema, workSpaceSchema, saveSchema, clientMetricsSchema, storeMetricsSchema, userMetricsSchema, pendingSummaryTableSchema, overAllAuditSummarySchema, overviewTableSchema, summarySplitSchema, overViewCardSchema } from '../dtos/traxAudit.dtos.js';
2
+ import { getFileSchema, userAuditHistorySchema, workSpaceSchema, saveSchema, clientMetricsSchema, storeMetricsSchema, userMetricsSchema, pendingSummaryTableSchema, overAllAuditSummarySchema, overviewTableSchema, summarySplitSchema } from '../dtos/traxAudit.dtos.js';
3
3
 
4
4
  export const traxAuditDocs = {
5
5
 
@@ -222,28 +222,6 @@ export const traxAuditDocs = {
222
222
  },
223
223
  },
224
224
  },
225
- '/v3/trax-audit/metrics/overview-card': {
226
- post: {
227
- tags: [ 'Trax Audit' ],
228
- description: `Get overall high level audited files count`,
229
- operationId: 'metrics/overview-card',
230
- parameters: {},
231
- requestBody: {
232
- content: {
233
- 'application/json': {
234
- schema: j2s( overViewCardSchema ).swagger,
235
- },
236
- },
237
- },
238
- responses: {
239
- 200: { description: 'Successful' },
240
- 401: { description: 'Unauthorized User' },
241
- 422: { description: 'Field Error' },
242
- 500: { description: 'Server Error' },
243
- 204: { description: 'Not Found' },
244
- },
245
- },
246
- },
247
225
 
248
226
  '/v3/trax-audit/metrics/summary-split-up': {
249
227
  post: {
@@ -148,7 +148,7 @@ export const userAuditHistorySchema = joi.object(
148
148
  dateType: joi.string().required(),
149
149
  clientId: joi.array().optional(),
150
150
  filterByStoreId: joi.array().required(),
151
- filterByModuleType: joi.array().optional(),
151
+ moduleType: joi.string().required(),
152
152
  filterByAuditType: joi.array().optional(),
153
153
  filterByStatus: joi.array().optional(),
154
154
  searchValue: joi.string().optional().allow( '' ),
@@ -170,7 +170,7 @@ export const clientMetricsSchema = joi.object(
170
170
  fromDate: joi.string().required(),
171
171
  toDate: joi.string().required(),
172
172
  searchValue: joi.string().optional().allow( '' ),
173
- filterByModuleType: joi.array().optional(),
173
+ moduleType: joi.string().required(),
174
174
  filterByClient: joi.array().required(),
175
175
  filterByStatus: joi.array().optional(),
176
176
  sortColumnName: joi.string().optional(),
@@ -195,7 +195,7 @@ export const storeMetricsSchema = joi.object(
195
195
  filterByStoreId: joi.array().optional(),
196
196
  filterByStatus: joi.array().optional(),
197
197
  filterByAuditType: joi.array().optional(),
198
- filterByModuleType: joi.array().optional(),
198
+ moduleType: joi.string().required(),
199
199
  sortColumnName: joi.string().optional(),
200
200
  sortBy: joi.number().optional(),
201
201
  limit: joi.number().optional(),
@@ -215,7 +215,7 @@ export const userMetricsSchema = joi.object(
215
215
  dateType: joi.string().required(),
216
216
  searchValue: joi.string().optional().allow( '' ),
217
217
  filterByUser: joi.array().optional(),
218
- filterByModuleType: joi.array().optional(),
218
+ moduleType: joi.string().required(),
219
219
  filterByStatus: joi.array().optional(),
220
220
  sortColumnName: joi.string().optional(),
221
221
  sortBy: joi.number().optional(),
@@ -238,7 +238,7 @@ export const pendingSummaryTableSchema = joi.object(
238
238
  offset: joi.number().optional(),
239
239
  searchValue: joi.string().optional().allow( '' ),
240
240
  filterByStatus: joi.array().required(),
241
- filterByModuleType: joi.array().optional(),
241
+ moduleType: joi.string().required(),
242
242
  filterByAuditType: joi.array().optional(),
243
243
  sortColumnName: joi.string().optional(),
244
244
  sortBy: joi.number().optional(),
@@ -259,7 +259,7 @@ export const overviewTableSchema = joi.object(
259
259
  offset: joi.number().optional(),
260
260
  searchValue: joi.string().optional().allow( '' ),
261
261
  filterByStatus: joi.array().optional(),
262
- filterByModuleType: joi.array().optional(),
262
+ moduleType: joi.string().required(),
263
263
  filterByAuditType: joi.array().optional(),
264
264
  sortColumnName: joi.string().optional(),
265
265
  sortBy: joi.number().optional(),
@@ -276,7 +276,7 @@ export const overAllAuditSummarySchema = joi.object(
276
276
  fromDate: joi.string().required(),
277
277
  toDate: joi.string().required(),
278
278
  clientId: joi.array().optional(),
279
- moduleType: joi.array().required(),
279
+ moduleType: joi.string().required(),
280
280
  },
281
281
  );
282
282
 
@@ -319,7 +319,7 @@ export const summarySplitSchema = joi.object(
319
319
  fromDate: joi.string().required(),
320
320
  toDate: joi.string().required(),
321
321
  clientId: joi.array().optional(),
322
- moduleType: joi.array().optional(),
322
+ moduleType: joi.string().required(),
323
323
  },
324
324
  );
325
325
 
@@ -219,20 +219,6 @@ export const overAllAuditSummaryValid = {
219
219
  body: overAllAuditSummarySchema,
220
220
  };
221
221
 
222
-
223
- export const overViewCardSchema = joi.object(
224
- {
225
- fromDate: joi.string().required(),
226
- toDate: joi.string().required(),
227
- clientId: joi.array().optional(),
228
- moduleType: joi.string().required(),
229
- },
230
- );
231
-
232
- export const overViewCardValid = {
233
- body: overViewCardSchema,
234
- };
235
-
236
222
  export const summarySplitSchema = joi.object(
237
223
  {
238
224
  fromDate: joi.string().required(),
@@ -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, clientMetricsValid, storeMetricsValid, userMetricsValid, pendingSummaryTableValid, overAllAuditSummaryValid, summarySplitValid, overviewTableValid, overViewCardValid } from '../dtos/traxAudit.dtos.js';
3
+ import { getDetectionFileValid, getFileValid, userAuditHistoryValid, workSpaceValid, saveValid, clientMetricsValid, storeMetricsValid, userMetricsValid, pendingSummaryTableValid, overAllAuditSummaryValid, summarySplitValid, overviewTableValid } from '../dtos/traxAudit.dtos.js';
4
4
  import { isExistsQueue } from '../validation/audit.validation.js';
5
- import { clientMetrics, getAuditFile, getDetectionAuditFile, overAllAuditSummary, overViewCard, overviewTable, pendingSummaryTable, saveBinary, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace } from '../controllers/traxAudit.controllers.js';
5
+ import { clientMetrics, getAuditFile, getDetectionAuditFile, overAllAuditSummary, overviewTable, pendingSummaryTable, saveBinary, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace } from '../controllers/traxAudit.controllers.js';
6
6
  import { validateBinaryAudit } from '../validation/traxAuditValidation.js';
7
7
 
8
8
  export const traxAuditRouter = Router();
@@ -30,7 +30,6 @@ traxAuditRouter.post( '/metrics/overall-audit-summary', isAllowedSessionHandler,
30
30
 
31
31
  // summary
32
32
 
33
- traxAuditRouter.post( '/metrics/overview-card', isAllowedSessionHandler, validate( overViewCardValid ), overViewCard );
34
33
  traxAuditRouter.post( '/metrics/summary-split-up', isAllowedSessionHandler, validate( summarySplitValid ), summarySplit );
35
34
  traxAuditRouter.post( '/metrics/overview-table', isAllowedSessionHandler, validate( overviewTableValid ), overviewTable );
36
35
 
@@ -27,7 +27,7 @@ export async function validateBinaryAudit( req, res, next ) {
27
27
  if ( !userAuditDetails ) {
28
28
  return res.sendError( 'No Data Available' );
29
29
  } else if ( userAuditDetails && userAuditDetails.auditStatus == 'completed' ) {
30
- return res.sendError( 'Forbidden to this action', 203 );
30
+ await updateOneBinaryAuditModel( { _id: inputData.auditId }, { auditType: 'ReAudit' } );
31
31
  }
32
32
  req.userAudit = userAuditDetails;
33
33
  next();