tango-app-api-audit 3.4.0-alpha.6 → 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
|
@@ -2163,6 +2163,8 @@ export async function storeMetrics( req, res ) {
|
|
|
2163
2163
|
'Zone Name': element.zoneName,
|
|
2164
2164
|
'User Name': element.userName,
|
|
2165
2165
|
'User Email': element.userEmail,
|
|
2166
|
+
'Before Count': element.beforeCount,
|
|
2167
|
+
'After Count': element.afterCount,
|
|
2166
2168
|
'Audit Type': element.auditType,
|
|
2167
2169
|
'Accuracy': element.accuracy,
|
|
2168
2170
|
'Time Spent': element.timeSpent,
|
|
@@ -2177,6 +2179,8 @@ export async function storeMetrics( req, res ) {
|
|
|
2177
2179
|
'Client Name': element.clientName,
|
|
2178
2180
|
'User Name': element.userName,
|
|
2179
2181
|
'User Email': element.userEmail,
|
|
2182
|
+
'Before Count': element.beforeCount,
|
|
2183
|
+
'After Count': element.afterCount,
|
|
2180
2184
|
'Audit Type': element.auditType,
|
|
2181
2185
|
'Accuracy': element.accuracy,
|
|
2182
2186
|
'Time Spent': element.timeSpent,
|
|
@@ -1072,6 +1072,7 @@ export async function getAuditFile( req, res ) {
|
|
|
1072
1072
|
fileDate: msg.fileDate,
|
|
1073
1073
|
queueName: inputData.queueName,
|
|
1074
1074
|
auditStatus: 'inprogress',
|
|
1075
|
+
AuditType: 'Audit',
|
|
1075
1076
|
fileDateISO: start,
|
|
1076
1077
|
timeSpent: 0,
|
|
1077
1078
|
startTime: new Date(),
|
|
@@ -1146,7 +1147,10 @@ export async function getAuditFile( req, res ) {
|
|
|
1146
1147
|
export async function saveBinary( req, res ) {
|
|
1147
1148
|
try {
|
|
1148
1149
|
const inputData = req.body;
|
|
1149
|
-
|
|
1150
|
+
const isoDate = req.userAudit?.startTime;
|
|
1151
|
+
const currentTime = dayjs();
|
|
1152
|
+
const isoDateTime = dayjs( isoDate );
|
|
1153
|
+
const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
|
|
1150
1154
|
switch ( inputData.moduleType ) {
|
|
1151
1155
|
case 'unattended-customer':
|
|
1152
1156
|
let unattendedquery ={
|
|
@@ -1160,7 +1164,9 @@ export async function saveBinary( req, res ) {
|
|
|
1160
1164
|
let update={
|
|
1161
1165
|
auditStatus: 'completed',
|
|
1162
1166
|
answer: inputData.answer,
|
|
1163
|
-
|
|
1167
|
+
userComments: inputData.userComments || '',
|
|
1168
|
+
endTime: new Date(),
|
|
1169
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1164
1170
|
};
|
|
1165
1171
|
let updatDataunattended= await updateOneBinaryAuditModel( unattendedquery, update );
|
|
1166
1172
|
if ( updatDataunattended.modifiedCount==0 ) {
|
|
@@ -1182,7 +1188,9 @@ export async function saveBinary( req, res ) {
|
|
|
1182
1188
|
let leftupdate={
|
|
1183
1189
|
auditStatus: 'completed',
|
|
1184
1190
|
answer: inputData.answer,
|
|
1185
|
-
|
|
1191
|
+
userComments: inputData.userComments || '',
|
|
1192
|
+
endTime: new Date(),
|
|
1193
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1186
1194
|
};
|
|
1187
1195
|
let updatDataleft= await updateOneBinaryAuditModel( leftquery, leftupdate );
|
|
1188
1196
|
if ( updatDataleft.modifiedCount==0 ) {
|
|
@@ -1204,7 +1212,9 @@ export async function saveBinary( req, res ) {
|
|
|
1204
1212
|
let cameraupdate={
|
|
1205
1213
|
auditStatus: 'completed',
|
|
1206
1214
|
answer: inputData.answer,
|
|
1207
|
-
|
|
1215
|
+
userComments: inputData.userComments || '',
|
|
1216
|
+
endTime: new Date(),
|
|
1217
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1208
1218
|
};
|
|
1209
1219
|
let updatDatacamera= await updateOneBinaryAuditModel( cameraquery, cameraupdate );
|
|
1210
1220
|
if ( updatDatacamera.modifiedCount==0 ) {
|
|
@@ -1337,14 +1347,18 @@ export async function userAuditHistory( req, res ) {
|
|
|
1337
1347
|
tempId: 1,
|
|
1338
1348
|
streamName: 1,
|
|
1339
1349
|
question: 1,
|
|
1350
|
+
questionType: 1,
|
|
1340
1351
|
answer: 1,
|
|
1352
|
+
userComments: 1,
|
|
1341
1353
|
storeName: '$store.storeName',
|
|
1342
1354
|
clientId: 1,
|
|
1343
1355
|
clientName: '$client.clientName',
|
|
1344
1356
|
fileDate: 1,
|
|
1345
1357
|
auditType: 1,
|
|
1346
|
-
zoneName: 1,
|
|
1347
1358
|
moduleType: 1,
|
|
1359
|
+
value: {
|
|
1360
|
+
$replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
|
|
1361
|
+
},
|
|
1348
1362
|
beforeCount: 1,
|
|
1349
1363
|
afterCount: 1,
|
|
1350
1364
|
accuracy: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, { $round: [
|
|
@@ -1411,11 +1425,12 @@ export async function userAuditHistory( req, res ) {
|
|
|
1411
1425
|
{ storeId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1412
1426
|
{ storeName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1413
1427
|
{ streamName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1414
|
-
{
|
|
1428
|
+
{ value: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1415
1429
|
{ auditType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1416
1430
|
{ auditStatus: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1417
1431
|
{ tempId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1418
1432
|
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1433
|
+
{ userComments: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1419
1434
|
],
|
|
1420
1435
|
|
|
1421
1436
|
},
|
|
@@ -1440,25 +1455,50 @@ export async function userAuditHistory( req, res ) {
|
|
|
1440
1455
|
const promises = chunkedMappingData.map( async ( chunk ) => {
|
|
1441
1456
|
const exportData = [];
|
|
1442
1457
|
chunk.forEach( ( element ) => {
|
|
1443
|
-
|
|
1458
|
+
const temp ={
|
|
1459
|
+
|
|
1444
1460
|
'File Date': element.fileDate,
|
|
1445
1461
|
'Brand ID': element.clientId,
|
|
1446
1462
|
'Brand Name': element.clientName,
|
|
1447
1463
|
'Store ID': element.storeId,
|
|
1448
1464
|
'Store Name': element.storeName,
|
|
1449
|
-
'Stream Name': element.moduleType == 'camera-angle-change'? element.zoneName : '',
|
|
1450
1465
|
'Audit Type': element.auditType,
|
|
1451
|
-
'Product Type': element.
|
|
1452
|
-
'Before Count': element.beforeCount,
|
|
1453
|
-
'After Count': element.afterCount || '',
|
|
1454
|
-
'Accuracy': element.accuracy || '',
|
|
1466
|
+
'Product Type': element.value,
|
|
1455
1467
|
'Start Time': element.startTime,
|
|
1456
1468
|
'End Time': element.endTime || '',
|
|
1457
1469
|
'Time Spent': element.timeSpent,
|
|
1458
|
-
'
|
|
1470
|
+
'Status': element.auditStatus,
|
|
1459
1471
|
'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
|
|
1472
|
+
'Result': element.answer,
|
|
1460
1473
|
|
|
1461
|
-
|
|
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 );
|
|
1462
1502
|
} );
|
|
1463
1503
|
return exportData;
|
|
1464
1504
|
} );
|
|
@@ -1611,6 +1651,9 @@ export async function clientMetrics( req, res ) {
|
|
|
1611
1651
|
clientName: 1,
|
|
1612
1652
|
totalFilesCount: 1,
|
|
1613
1653
|
moduleType: 1,
|
|
1654
|
+
value: {
|
|
1655
|
+
$replaceAll: { input: '$moduleType', find: '-', replacement: ' ' }, // Replacing "-" with " "
|
|
1656
|
+
},
|
|
1614
1657
|
installedStore: 1,
|
|
1615
1658
|
// notAssignedStores: '$binaryAudit.notAssignedStores',
|
|
1616
1659
|
inprogressStoresCount: '$binaryAudit.inprogressStores',
|
|
@@ -1673,7 +1716,7 @@ export async function clientMetrics( req, res ) {
|
|
|
1673
1716
|
'File Date': '$fileDate',
|
|
1674
1717
|
'Client Name': '$clientName',
|
|
1675
1718
|
'Client Id': '$clientId',
|
|
1676
|
-
'Product Type': '$
|
|
1719
|
+
'Product Type': '$value',
|
|
1677
1720
|
'Completed Percentage': '$completionPercentage',
|
|
1678
1721
|
'Installed Stores': '$installedStore',
|
|
1679
1722
|
'Audit Stores': '$totalFilesCount',
|
|
@@ -1769,6 +1812,7 @@ export async function storeMetrics( req, res ) {
|
|
|
1769
1812
|
},
|
|
1770
1813
|
{
|
|
1771
1814
|
$project: {
|
|
1815
|
+
auditId: '$_id',
|
|
1772
1816
|
_id: 0,
|
|
1773
1817
|
fileDate: 1,
|
|
1774
1818
|
storeId: 1,
|
|
@@ -1776,9 +1820,13 @@ export async function storeMetrics( req, res ) {
|
|
|
1776
1820
|
clientName: '',
|
|
1777
1821
|
clientId: 1,
|
|
1778
1822
|
moduleType: 1,
|
|
1823
|
+
value: {
|
|
1824
|
+
$replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
|
|
1825
|
+
},
|
|
1779
1826
|
tempId: 1,
|
|
1780
1827
|
streamName: 1,
|
|
1781
1828
|
question: 1,
|
|
1829
|
+
questionType: 1,
|
|
1782
1830
|
answer: 1,
|
|
1783
1831
|
// userId: {
|
|
1784
1832
|
// $arrayElemAt: [ '$userId', { $subtract: [ { $size: '$userId' }, 1 ] } ], //need to check if no data
|
|
@@ -1855,7 +1903,7 @@ export async function storeMetrics( req, res ) {
|
|
|
1855
1903
|
},
|
|
1856
1904
|
{
|
|
1857
1905
|
$project: {
|
|
1858
|
-
|
|
1906
|
+
auditId: 1,
|
|
1859
1907
|
fileDate: 1,
|
|
1860
1908
|
storeId: 1,
|
|
1861
1909
|
storeName: 1,
|
|
@@ -1866,8 +1914,10 @@ export async function storeMetrics( req, res ) {
|
|
|
1866
1914
|
tempId: 1,
|
|
1867
1915
|
streamName: 1,
|
|
1868
1916
|
question: 1,
|
|
1917
|
+
questionType: 1,
|
|
1869
1918
|
answer: 1,
|
|
1870
1919
|
moduleType: 1,
|
|
1920
|
+
value: 1,
|
|
1871
1921
|
auditType: 1,
|
|
1872
1922
|
beforeCount: 1,
|
|
1873
1923
|
afterCount: { $ifNull: [ '$afterCount', null ] },
|
|
@@ -1920,7 +1970,7 @@ export async function storeMetrics( req, res ) {
|
|
|
1920
1970
|
{ userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1921
1971
|
{ status: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1922
1972
|
{ auditType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1923
|
-
{
|
|
1973
|
+
{ value: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1924
1974
|
{ tempId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1925
1975
|
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
1926
1976
|
{ answer: { $regex: inputData.searchValue, $options: 'i' } },
|
|
@@ -1957,43 +2007,47 @@ export async function storeMetrics( req, res ) {
|
|
|
1957
2007
|
if ( inputData.isExport ) {
|
|
1958
2008
|
const exportdata = [];
|
|
1959
2009
|
result.forEach( ( element ) => {
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
'
|
|
1975
|
-
'
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
'
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
'
|
|
1984
|
-
'
|
|
1985
|
-
'
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
'
|
|
1989
|
-
'
|
|
1990
|
-
'
|
|
1991
|
-
'Accuracy'
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
'
|
|
1995
|
-
|
|
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;
|
|
1996
2049
|
}
|
|
2050
|
+
exportdata.push( temp );
|
|
1997
2051
|
} );
|
|
1998
2052
|
await download( exportdata, res );
|
|
1999
2053
|
return;
|
|
@@ -2053,16 +2107,18 @@ export async function userMetrics( req, res ) {
|
|
|
2053
2107
|
userId: 1,
|
|
2054
2108
|
fileDate: 1,
|
|
2055
2109
|
startTime: 1,
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2110
|
+
beforeCount: 1,
|
|
2111
|
+
moduleType: 1,
|
|
2112
|
+
afterCount: 1,
|
|
2113
|
+
checkIntime: 1,
|
|
2114
|
+
checkOutTime: 1,
|
|
2061
2115
|
totalCompletedFiles: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, 1, 0 ] },
|
|
2062
2116
|
beforeCount: 1,
|
|
2063
2117
|
afterCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$afterCount', 0 ] },
|
|
2064
|
-
|
|
2065
|
-
|
|
2118
|
+
|
|
2119
|
+
value: {
|
|
2120
|
+
$replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
|
|
2121
|
+
} },
|
|
2066
2122
|
},
|
|
2067
2123
|
{
|
|
2068
2124
|
$group: {
|
|
@@ -2074,12 +2130,8 @@ export async function userMetrics( req, res ) {
|
|
|
2074
2130
|
afterCount: { $sum: '$afterCount' },
|
|
2075
2131
|
checkIntime: { $first: '$startTime' },
|
|
2076
2132
|
checkOutTime: { $last: '$endTime' },
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
question: { $last: '$question' },
|
|
2080
|
-
answer: { $last: '$answer' },
|
|
2081
|
-
auditStatus: { $last: '$auditStatus' },
|
|
2082
|
-
|
|
2133
|
+
moduleType: { $last: '$moduleType' },
|
|
2134
|
+
value: { $last: '$value' },
|
|
2083
2135
|
},
|
|
2084
2136
|
},
|
|
2085
2137
|
{
|
|
@@ -2088,12 +2140,10 @@ export async function userMetrics( req, res ) {
|
|
|
2088
2140
|
userId: 1,
|
|
2089
2141
|
fileDate: 1,
|
|
2090
2142
|
totalCompletedFiles: 1,
|
|
2143
|
+
moduleType: 1,
|
|
2144
|
+
value: 1,
|
|
2091
2145
|
beforeCount: 1,
|
|
2092
2146
|
afterCount: 1,
|
|
2093
|
-
streamName: 1,
|
|
2094
|
-
tempId: 1,
|
|
2095
|
-
question: 1,
|
|
2096
|
-
answer: 1,
|
|
2097
2147
|
// mappingPerc: { $round: [
|
|
2098
2148
|
// { $multiply: [
|
|
2099
2149
|
// { $divide: [ '$afterCount', '$beforeCount' ] }, 100,
|
|
@@ -2104,7 +2154,6 @@ export async function userMetrics( req, res ) {
|
|
|
2104
2154
|
differenceInSeconds: {
|
|
2105
2155
|
$divide: [ { $subtract: [ '$checkOutTime', '$checkIntime' ] }, 1000 ],
|
|
2106
2156
|
},
|
|
2107
|
-
auditStatus: 1,
|
|
2108
2157
|
},
|
|
2109
2158
|
},
|
|
2110
2159
|
{
|
|
@@ -2116,15 +2165,12 @@ export async function userMetrics( req, res ) {
|
|
|
2116
2165
|
afterCount: 1,
|
|
2117
2166
|
checkIntime: 1,
|
|
2118
2167
|
checkOutTime: 1,
|
|
2168
|
+
moduleType: 1,
|
|
2169
|
+
value: 1,
|
|
2119
2170
|
// mappingPerc: 1,
|
|
2120
|
-
streamName: 1,
|
|
2121
|
-
tempId: 1,
|
|
2122
|
-
question: 1,
|
|
2123
|
-
answer: 1,
|
|
2124
2171
|
hours: { $floor: { $divide: [ '$differenceInSeconds', 3600 ] } },
|
|
2125
2172
|
minutes: { $floor: { $divide: [ { $mod: [ '$differenceInSeconds', 3600 ] }, 60 ] } },
|
|
2126
2173
|
seconds: { $mod: [ '$differenceInSeconds', 60 ] },
|
|
2127
|
-
auditStatus: 1,
|
|
2128
2174
|
},
|
|
2129
2175
|
},
|
|
2130
2176
|
{
|
|
@@ -2137,11 +2183,9 @@ export async function userMetrics( req, res ) {
|
|
|
2137
2183
|
afterCount: 1,
|
|
2138
2184
|
checkIntime: 1,
|
|
2139
2185
|
checkOutTime: 1,
|
|
2186
|
+
moduleType: 1,
|
|
2187
|
+
value: 1,
|
|
2140
2188
|
// mappingPerc: 1,
|
|
2141
|
-
streamName: 1,
|
|
2142
|
-
tempId: 1,
|
|
2143
|
-
question: 1,
|
|
2144
|
-
answer: 1,
|
|
2145
2189
|
hours: {
|
|
2146
2190
|
$cond: {
|
|
2147
2191
|
if: { $lt: [ '$hours', 10 ] },
|
|
@@ -2163,7 +2207,6 @@ export async function userMetrics( req, res ) {
|
|
|
2163
2207
|
else: { $toString: { $round: [ '$seconds', 0 ] } },
|
|
2164
2208
|
},
|
|
2165
2209
|
},
|
|
2166
|
-
auditStatus: 1,
|
|
2167
2210
|
},
|
|
2168
2211
|
},
|
|
2169
2212
|
{
|
|
@@ -2175,17 +2218,15 @@ export async function userMetrics( req, res ) {
|
|
|
2175
2218
|
beforeCount: 1,
|
|
2176
2219
|
afterCount: 1,
|
|
2177
2220
|
checkIntime: 1,
|
|
2178
|
-
zoneName: 1,
|
|
2179
2221
|
checkOutTime: 1,
|
|
2222
|
+
moduleType: 1,
|
|
2223
|
+
value: {
|
|
2224
|
+
$replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
|
|
2225
|
+
},
|
|
2180
2226
|
// mappingPerc: 1,
|
|
2181
|
-
streamName: 1,
|
|
2182
|
-
tempId: 1,
|
|
2183
|
-
question: 1,
|
|
2184
|
-
answer: 1,
|
|
2185
2227
|
workingHours: {
|
|
2186
2228
|
$concat: [ '$hours', ':', '$minutes', ':', '$seconds' ],
|
|
2187
2229
|
},
|
|
2188
|
-
auditStatus: 1,
|
|
2189
2230
|
},
|
|
2190
2231
|
},
|
|
2191
2232
|
{
|
|
@@ -2223,11 +2264,11 @@ export async function userMetrics( req, res ) {
|
|
|
2223
2264
|
totalCompletedFiles: 1,
|
|
2224
2265
|
beforeCount: 1,
|
|
2225
2266
|
afterCount: 1,
|
|
2267
|
+
moduleType: 1,
|
|
2268
|
+
value: {
|
|
2269
|
+
$replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
|
|
2270
|
+
},
|
|
2226
2271
|
// mappingPerc: 1,
|
|
2227
|
-
streamName: 1,
|
|
2228
|
-
tempId: 1,
|
|
2229
|
-
question: 1,
|
|
2230
|
-
answer: 1,
|
|
2231
2272
|
checkIntime: {
|
|
2232
2273
|
$dateToString: {
|
|
2233
2274
|
format: '%Y-%m-%d %H:%M:%S',
|
|
@@ -2243,7 +2284,6 @@ export async function userMetrics( req, res ) {
|
|
|
2243
2284
|
},
|
|
2244
2285
|
},
|
|
2245
2286
|
workingHours: 1,
|
|
2246
|
-
auditStatus: 1,
|
|
2247
2287
|
},
|
|
2248
2288
|
},
|
|
2249
2289
|
];
|
|
@@ -2277,25 +2317,39 @@ export async function userMetrics( req, res ) {
|
|
|
2277
2317
|
{ $limit: limit },
|
|
2278
2318
|
);
|
|
2279
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' ] )?
|
|
2280
2345
|
query.push(
|
|
2281
2346
|
{
|
|
2282
|
-
$project:
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
'Total After Count': '$afterCount',
|
|
2289
|
-
'check Intime': '$checkIntime',
|
|
2290
|
-
'check OutTime': '$checkOutTime',
|
|
2291
|
-
'working Hours': '$workingHours',
|
|
2292
|
-
'Mapping Percentage': '$mappingPerc',
|
|
2293
|
-
'Customer ID': '$tempId',
|
|
2294
|
-
'Stream Name': '$streamName',
|
|
2295
|
-
'Question': '$question',
|
|
2296
|
-
'Answer': '$answer',
|
|
2297
|
-
'Audit Status': '$auditStatus',
|
|
2298
|
-
},
|
|
2347
|
+
$project: detection,
|
|
2348
|
+
},
|
|
2349
|
+
) :
|
|
2350
|
+
query.push(
|
|
2351
|
+
{
|
|
2352
|
+
$project: YesNo,
|
|
2299
2353
|
},
|
|
2300
2354
|
);
|
|
2301
2355
|
}
|
|
@@ -2353,10 +2407,14 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2353
2407
|
streamName: 1,
|
|
2354
2408
|
tempId: 1,
|
|
2355
2409
|
question: 1,
|
|
2410
|
+
questionType: 1,
|
|
2356
2411
|
answer: 1,
|
|
2357
|
-
|
|
2412
|
+
userComments: 1,
|
|
2358
2413
|
fileDate: 1,
|
|
2359
2414
|
moduleType: 1,
|
|
2415
|
+
value: {
|
|
2416
|
+
$replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
|
|
2417
|
+
},
|
|
2360
2418
|
beforeCount: 1,
|
|
2361
2419
|
startTime: { $dateToString: {
|
|
2362
2420
|
format: '%Y-%m-%d %H:%M:%S',
|
|
@@ -2403,10 +2461,12 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2403
2461
|
streamName: 1,
|
|
2404
2462
|
tempId: 1,
|
|
2405
2463
|
question: 1,
|
|
2464
|
+
questionType: 1,
|
|
2406
2465
|
answer: 1,
|
|
2407
|
-
|
|
2466
|
+
userComments: 1,
|
|
2408
2467
|
fileDate: 1,
|
|
2409
2468
|
moduleType: 1,
|
|
2469
|
+
value: 1,
|
|
2410
2470
|
beforeCount: 1,
|
|
2411
2471
|
startTime: 1,
|
|
2412
2472
|
endTime: 1,
|
|
@@ -2428,6 +2488,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2428
2488
|
{ auditStatus: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2429
2489
|
{ userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2430
2490
|
{ userEmail: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2491
|
+
{ value: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2431
2492
|
],
|
|
2432
2493
|
|
|
2433
2494
|
},
|
|
@@ -2461,41 +2522,40 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2461
2522
|
if ( inputData.isExport ) {
|
|
2462
2523
|
const exportdata = [];
|
|
2463
2524
|
result.forEach( ( element ) => {
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
'
|
|
2479
|
-
'
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
'
|
|
2484
|
-
'
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
'
|
|
2488
|
-
'
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
'
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
'
|
|
2495
|
-
|
|
2496
|
-
'Status': element.auditStatus,
|
|
2497
|
-
} );
|
|
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;
|
|
2498
2557
|
}
|
|
2558
|
+
exportdata.push( temp );
|
|
2499
2559
|
} );
|
|
2500
2560
|
await download( exportdata, res );
|
|
2501
2561
|
return;
|
|
@@ -2792,10 +2852,15 @@ export async function overviewTable( req, res ) {
|
|
|
2792
2852
|
streamName: 1,
|
|
2793
2853
|
tempId: 1,
|
|
2794
2854
|
question: 1,
|
|
2855
|
+
questionType: 1,
|
|
2795
2856
|
answer: 1,
|
|
2796
|
-
|
|
2857
|
+
userComments: 1,
|
|
2797
2858
|
fileDate: 1,
|
|
2798
2859
|
moduleType: 1,
|
|
2860
|
+
|
|
2861
|
+
value: {
|
|
2862
|
+
$replaceAll: { input: '$moduleType', find: '-', replacement: ' ' },
|
|
2863
|
+
},
|
|
2799
2864
|
beforeCount: 1,
|
|
2800
2865
|
afterCount: 1,
|
|
2801
2866
|
auditType: 1,
|
|
@@ -2838,10 +2903,12 @@ export async function overviewTable( req, res ) {
|
|
|
2838
2903
|
streamName: 1,
|
|
2839
2904
|
tempId: 1,
|
|
2840
2905
|
question: 1,
|
|
2906
|
+
questionType: 1,
|
|
2841
2907
|
answer: 1,
|
|
2842
|
-
|
|
2908
|
+
userComments: 1,
|
|
2843
2909
|
fileDate: 1,
|
|
2844
2910
|
moduleType: 1,
|
|
2911
|
+
value: 1,
|
|
2845
2912
|
beforeCount: 1,
|
|
2846
2913
|
afterCount: 1,
|
|
2847
2914
|
auditType: 1,
|
|
@@ -2863,12 +2930,12 @@ export async function overviewTable( req, res ) {
|
|
|
2863
2930
|
{ auditType: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2864
2931
|
{ status: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2865
2932
|
{ auditStatus: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2866
|
-
{
|
|
2933
|
+
{ value: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2867
2934
|
{ streamName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2868
2935
|
{ tempId: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2869
2936
|
{ question: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2870
2937
|
{ answer: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2871
|
-
{
|
|
2938
|
+
{ userComments: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2872
2939
|
// { userName: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2873
2940
|
// { userEmail: { $regex: inputData.searchValue, $options: 'i' } },
|
|
2874
2941
|
],
|
|
@@ -2903,45 +2970,43 @@ export async function overviewTable( req, res ) {
|
|
|
2903
2970
|
if ( inputData.isExport ) {
|
|
2904
2971
|
const exportdata = [];
|
|
2905
2972
|
result.forEach( ( element ) => {
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
'
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
'
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
'
|
|
2931
|
-
'
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
'
|
|
2935
|
-
'
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
'
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
'Status': element.status,
|
|
2942
|
-
'Audit Status': element.status,
|
|
2943
|
-
} );
|
|
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;
|
|
2944
3008
|
}
|
|
3009
|
+
exportdata.push( temp );
|
|
2945
3010
|
} );
|
|
2946
3011
|
await download( exportdata, res );
|
|
2947
3012
|
return;
|
|
@@ -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
|
-
|
|
30
|
+
await updateOneBinaryAuditModel( { _id: inputData.auditId }, { auditType: 'ReAudit' } );
|
|
31
31
|
}
|
|
32
32
|
req.userAudit = userAuditDetails;
|
|
33
33
|
next();
|