tango-app-api-audit 3.4.11-alpha.4 → 3.4.11-alpha.5
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
|
@@ -527,7 +527,6 @@ export async function getAuditFile( req, res ) {
|
|
|
527
527
|
img_name: indexes[1],
|
|
528
528
|
img_id: image[0],
|
|
529
529
|
selected: false,
|
|
530
|
-
demographic: '',
|
|
531
530
|
dropped: false,
|
|
532
531
|
count: 1,
|
|
533
532
|
mappedid: [ mapimg ],
|
|
@@ -1167,14 +1166,14 @@ export async function saveDraft( req, res ) {
|
|
|
1167
1166
|
};
|
|
1168
1167
|
|
|
1169
1168
|
if ( getUserAuditData?.startTime ) {
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1169
|
+
const isoDate = getUserAuditData.startTime;
|
|
1170
|
+
const currentTime = dayjs();
|
|
1171
|
+
const isoDateTime = dayjs( isoDate );
|
|
1172
|
+
const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
|
|
1174
1173
|
|
|
1175
|
-
userRecord.timeSpent =
|
|
1174
|
+
userRecord.timeSpent = timeDifferenceInMinutes;
|
|
1176
1175
|
|
|
1177
|
-
storeRecord.timeSpent =
|
|
1176
|
+
storeRecord.timeSpent =timeDifferenceInMinutes;
|
|
1178
1177
|
}
|
|
1179
1178
|
|
|
1180
1179
|
if ( inputData.userCommands ) {
|
|
@@ -1191,7 +1190,7 @@ export async function saveDraft( req, res ) {
|
|
|
1191
1190
|
clientName: inputData.queueName,
|
|
1192
1191
|
beforeCount: inputData.totalCount,
|
|
1193
1192
|
afterCount: inputData.customerCount,
|
|
1194
|
-
timeSpent:
|
|
1193
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1195
1194
|
auditId: inputData.auditId,
|
|
1196
1195
|
moduleType: inputData.moduleType,
|
|
1197
1196
|
zoneName: inputData.zoneName,
|
|
@@ -1322,10 +1321,10 @@ export async function save( req, res ) {
|
|
|
1322
1321
|
// // moduleType: inputData.moduleType,
|
|
1323
1322
|
// // zoneName: inputData.zoneName,
|
|
1324
1323
|
// } );
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1324
|
+
const isoDate = req.userAudit?.startTime;
|
|
1325
|
+
const currentTime = dayjs();
|
|
1326
|
+
const isoDateTime = dayjs( isoDate );
|
|
1327
|
+
const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
|
|
1329
1328
|
|
|
1330
1329
|
await updateOneUserAudit(
|
|
1331
1330
|
{ _id: new mongoose.Types.ObjectId( inputData.auditId ) },
|
|
@@ -1334,7 +1333,7 @@ export async function save( req, res ) {
|
|
|
1334
1333
|
endTime: Date.now(),
|
|
1335
1334
|
isDraft: false,
|
|
1336
1335
|
afterCount: inputData.customerCount,
|
|
1337
|
-
timeSpent:
|
|
1336
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1338
1337
|
},
|
|
1339
1338
|
);
|
|
1340
1339
|
|
|
@@ -1355,7 +1354,7 @@ export async function save( req, res ) {
|
|
|
1355
1354
|
afterCount: inputData.customerCount,
|
|
1356
1355
|
startTime: req.userAudit?.startTime,
|
|
1357
1356
|
endTime: Date.now(),
|
|
1358
|
-
timeSpent:
|
|
1357
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1359
1358
|
auditId: new mongoose.Types.ObjectId( inputData.auditId ),
|
|
1360
1359
|
},
|
|
1361
1360
|
createdAt: Date.now(),
|
|
@@ -1422,7 +1421,7 @@ export async function save( req, res ) {
|
|
|
1422
1421
|
status: 'not_assign',
|
|
1423
1422
|
afterCount: inputData.customerCount,
|
|
1424
1423
|
auditType: 'ReAudit',
|
|
1425
|
-
timeSpent:
|
|
1424
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1426
1425
|
},
|
|
1427
1426
|
);
|
|
1428
1427
|
|
|
@@ -1443,7 +1442,7 @@ export async function save( req, res ) {
|
|
|
1443
1442
|
afterCount: inputData.customerCount,
|
|
1444
1443
|
startTime: req.userAudit?.startTime,
|
|
1445
1444
|
endTime: Date.now(),
|
|
1446
|
-
timeSpent:
|
|
1445
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1447
1446
|
auditId: new mongoose.Types.ObjectId( inputData.auditId ),
|
|
1448
1447
|
},
|
|
1449
1448
|
createdAt: Date.now(),
|
|
@@ -1465,7 +1464,7 @@ export async function save( req, res ) {
|
|
|
1465
1464
|
{
|
|
1466
1465
|
status: 'completed',
|
|
1467
1466
|
afterCount: inputData.customerCount,
|
|
1468
|
-
timeSpent:
|
|
1467
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1469
1468
|
},
|
|
1470
1469
|
);
|
|
1471
1470
|
const sqsProduceQueue = {
|
|
@@ -746,7 +746,6 @@ export async function workSpace( req, res ) {
|
|
|
746
746
|
},
|
|
747
747
|
];
|
|
748
748
|
|
|
749
|
-
logger.info( { moduleType: inputData.moduleType, key: [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType ), dateStart: new Date( dayjs( fileDate ).format( 'YYYY-MM-DD' ) ), end: dateRange.end, user: req.user._id, client: clientList } );
|
|
750
749
|
|
|
751
750
|
const userAsignAudit = [
|
|
752
751
|
{
|
|
@@ -800,11 +799,11 @@ export async function workSpace( req, res ) {
|
|
|
800
799
|
},
|
|
801
800
|
];
|
|
802
801
|
|
|
803
|
-
const auditUserCount = [ '
|
|
804
|
-
const userIncompleteFilesCount = [ '
|
|
802
|
+
const auditUserCount = [ 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( auditFiles ) : await aggregateBinaryAudit( auditFiles );
|
|
803
|
+
const userIncompleteFilesCount = [ 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( userIncompleteFiles ) : await aggregateBinaryAudit( userIncompleteFiles );
|
|
805
804
|
logger.info( { moduleType: inputData.moduleType, userIncompleteFiles: userIncompleteFilesCount } );
|
|
806
805
|
const userAsignAuditCount = await aggregateAssignAudit( userAsignAudit );
|
|
807
|
-
const completedStoresCount = [ '
|
|
806
|
+
const completedStoresCount = [ 'mobile-detection' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( completedStores ) : await aggregateBinaryAudit( binarCompletedStores );
|
|
808
807
|
const clientAssignedCount = await aggregateAssignAudit( clientAssign );
|
|
809
808
|
const auditStoreData = await aggregateTraxAuditData(
|
|
810
809
|
auditStoreDataQuery,
|
|
@@ -981,13 +980,7 @@ export async function getAuditFile( req, res ) {
|
|
|
981
980
|
query ={
|
|
982
981
|
storeId: userDetails[0].storeId,
|
|
983
982
|
fileDate: userDetails[0].fileDate,
|
|
984
|
-
|
|
985
|
-
};
|
|
986
|
-
break;
|
|
987
|
-
case 'mobile-detection':
|
|
988
|
-
query ={
|
|
989
|
-
storeId: userDetails[0].storeId,
|
|
990
|
-
fileDate: userDetails[0].fileDate,
|
|
983
|
+
tempId: userDetails[0].tempId,
|
|
991
984
|
moduleType: userDetails[0].moduleType,
|
|
992
985
|
};
|
|
993
986
|
break;
|
|
@@ -1049,46 +1042,43 @@ export async function getAuditFile( req, res ) {
|
|
|
1049
1042
|
},
|
|
1050
1043
|
];
|
|
1051
1044
|
break;
|
|
1052
|
-
case '
|
|
1045
|
+
case 'uniform-detection':
|
|
1053
1046
|
for ( let i =0; i< msg.fileDetails.length; i++ ) {
|
|
1054
1047
|
const files = [];
|
|
1048
|
+
|
|
1055
1049
|
const params ={
|
|
1056
1050
|
Bucket: msg.inputBucketName,
|
|
1057
|
-
|
|
1058
|
-
MaxKeys: 1000,
|
|
1051
|
+
Key: msg?.fileDetails[i]?.filePath,
|
|
1059
1052
|
};
|
|
1060
|
-
const list = await listFileByPath( params );
|
|
1061
|
-
const folderPath = list.data;
|
|
1062
|
-
logger.info( { folderPath: list, params: params, list: list } );
|
|
1063
|
-
if ( folderPath?.length ) {
|
|
1064
|
-
for ( let i = 0; i < folderPath.length; i++ ) {
|
|
1065
|
-
// const img = folderPath[i].Key.split( '/' );
|
|
1066
|
-
// const image = img[3].split( '.' );
|
|
1067
|
-
// const indexes = image[0].split( '_' );
|
|
1068
|
-
const signedParams ={
|
|
1069
|
-
Bucket: msg.inputBucketName,
|
|
1070
|
-
file_path: folderPath[i].Key,
|
|
1071
|
-
};
|
|
1072
|
-
const data = await signedUrl( signedParams );
|
|
1073
1053
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1054
|
+
const isExists = await checkFileExist( params );
|
|
1055
|
+
|
|
1056
|
+
if ( isExists ) {
|
|
1057
|
+
const signedParams ={
|
|
1058
|
+
Bucket: msg.inputBucketName,
|
|
1059
|
+
file_path: msg?.fileDetails[i]?.filePath,
|
|
1060
|
+
};
|
|
1061
|
+
const data = await signedUrl( signedParams );
|
|
1062
|
+
|
|
1063
|
+
files.push(
|
|
1064
|
+
data,
|
|
1065
|
+
);
|
|
1085
1066
|
}
|
|
1067
|
+
// else {
|
|
1068
|
+
// logger.error( {
|
|
1069
|
+
// error: { folderPath: folderPath },
|
|
1070
|
+
// function: `getAuditFile - ${inputData.moduleType}`,
|
|
1071
|
+
// message: 'Bucket image data not availale',
|
|
1072
|
+
// } );
|
|
1073
|
+
// return res.sendError( 'Bucket is Empty', 204 );
|
|
1074
|
+
// }
|
|
1086
1075
|
result.push( {
|
|
1087
1076
|
type: msg.fileDetails[i].type,
|
|
1088
1077
|
file: files,
|
|
1089
1078
|
} );
|
|
1090
1079
|
}
|
|
1091
1080
|
break;
|
|
1081
|
+
case 'unattended-customer':
|
|
1092
1082
|
case 'left-in-middle':
|
|
1093
1083
|
for ( let i =0; i< msg.fileDetails.length; i++ ) {
|
|
1094
1084
|
const files = [];
|
|
@@ -1404,6 +1394,7 @@ export async function getUpdatedFile( req, res ) {
|
|
|
1404
1394
|
export async function saveBinary( req, res ) {
|
|
1405
1395
|
try {
|
|
1406
1396
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1397
|
+
const sqs = JSON.parse( process.env.SQS );
|
|
1407
1398
|
const inputData = req.body;
|
|
1408
1399
|
const isoDate = req.userAudit?.startTime;
|
|
1409
1400
|
const currentTime = dayjs();
|
|
@@ -1457,11 +1448,93 @@ export async function saveBinary( req, res ) {
|
|
|
1457
1448
|
createdAt: Date.now(),
|
|
1458
1449
|
};
|
|
1459
1450
|
await insertOpenSearchData( openSearch.auditLog, logData2 );
|
|
1460
|
-
logger.info( 'update in binary data', { query: unattendedquery, update: update } );
|
|
1461
1451
|
return res.sendSuccess( `Successfully updated in ${value}` );
|
|
1462
1452
|
|
|
1463
1453
|
break;
|
|
1464
1454
|
|
|
1455
|
+
case 'uniform-detection':
|
|
1456
|
+
let uniformDetectionQuery ={
|
|
1457
|
+
_id: inputData.auditId,
|
|
1458
|
+
storeId: inputData.storeId,
|
|
1459
|
+
fileDate: inputData.fileDate,
|
|
1460
|
+
tempId: inputData.tempId,
|
|
1461
|
+
moduleType: inputData.moduleType,
|
|
1462
|
+
};
|
|
1463
|
+
|
|
1464
|
+
let updateUniform={
|
|
1465
|
+
auditStatus: 'completed',
|
|
1466
|
+
answer: inputData.answer,
|
|
1467
|
+
userComments: inputData.userComments || '',
|
|
1468
|
+
endTime: new Date(),
|
|
1469
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1470
|
+
};
|
|
1471
|
+
let updatDataUniform= await updateOneBinaryAuditModel( uniformDetectionQuery, updateUniform );
|
|
1472
|
+
if ( updatDataUniform.modifiedCount==0 ) {
|
|
1473
|
+
return res.sendError( 'Update failed, it may be invalid request', 400 );
|
|
1474
|
+
}
|
|
1475
|
+
const getFilePath = await findOneTraxAuditData(
|
|
1476
|
+
{
|
|
1477
|
+
fileDate: inputData.fileDate,
|
|
1478
|
+
storeId: inputData.storeId,
|
|
1479
|
+
moduleType: inputData.moduleType,
|
|
1480
|
+
tempId: inputData.tempId,
|
|
1481
|
+
},
|
|
1482
|
+
);
|
|
1483
|
+
if ( !getFilePath ) {
|
|
1484
|
+
return res.sendError( ' SQS is not sent due to Inserted Data is not there', 400 );
|
|
1485
|
+
}
|
|
1486
|
+
const sqsProduceQueue = {
|
|
1487
|
+
QueueUrl: `${sqs.url}${sqs.uniformOutput}`,
|
|
1488
|
+
MessageBody: JSON.stringify( {
|
|
1489
|
+
storeId: inputData.storeId,
|
|
1490
|
+
fileDate: inputData.fileDate,
|
|
1491
|
+
tempId: inputData.tempId,
|
|
1492
|
+
moduleType: inputData.moduleType,
|
|
1493
|
+
answer: inputData.answer,
|
|
1494
|
+
filePath: getFilePath?.sqs?.Body?.filePath,
|
|
1495
|
+
} ),
|
|
1496
|
+
};
|
|
1497
|
+
const sqsQueue = await sendMessageToQueue(
|
|
1498
|
+
sqsProduceQueue.QueueUrl,
|
|
1499
|
+
sqsProduceQueue.MessageBody,
|
|
1500
|
+
);
|
|
1501
|
+
|
|
1502
|
+
if ( sqsQueue.statusCode ) {
|
|
1503
|
+
logger.error( {
|
|
1504
|
+
error: `${sqsQueue}`,
|
|
1505
|
+
type: 'UPLOAD_ERROR',
|
|
1506
|
+
} );
|
|
1507
|
+
return res.sendError( 'SQS not sent', 500 );
|
|
1508
|
+
}
|
|
1509
|
+
const logData3 = {
|
|
1510
|
+
userId: req.user._id,
|
|
1511
|
+
userName: req.user.userName,
|
|
1512
|
+
logType: 'traxAudit',
|
|
1513
|
+
logSubType: 'auditDone',
|
|
1514
|
+
logData: {
|
|
1515
|
+
fileDate: req.userAudit?.fileDate,
|
|
1516
|
+
auditType: req.userAudit?.auditType,
|
|
1517
|
+
storeId: req.userAudit?.storeId,
|
|
1518
|
+
moduleType: req.userAudit?.moduleType,
|
|
1519
|
+
queueName: req.userAudit?.queueName,
|
|
1520
|
+
clientId: req.userAudit?.clientId,
|
|
1521
|
+
// beforeCount: req.userAudit?.beforeCount,
|
|
1522
|
+
// afterCount: inputData.employeeCount,
|
|
1523
|
+
startTime: req.userAudit?.startTime,
|
|
1524
|
+
streamName: req.userAudit?.streamName,
|
|
1525
|
+
tempId: req.userAudit?.tempId,
|
|
1526
|
+
question: req.userAudit?.question,
|
|
1527
|
+
result: req.userAudit?.answer,
|
|
1528
|
+
endTime: Date.now(),
|
|
1529
|
+
timeSpent: timeDifferenceInMinutes,
|
|
1530
|
+
auditId: new mongoose.Types.ObjectId( inputData.auditId ),
|
|
1531
|
+
},
|
|
1532
|
+
createdAt: Date.now(),
|
|
1533
|
+
};
|
|
1534
|
+
await insertOpenSearchData( openSearch.auditLog, logData3 );
|
|
1535
|
+
return res.sendSuccess( `Successfully updated in ${value}` );
|
|
1536
|
+
break;
|
|
1537
|
+
|
|
1465
1538
|
case 'left-in-middle':
|
|
1466
1539
|
let leftquery ={
|
|
1467
1540
|
_id: inputData.auditId,
|
|
@@ -1507,7 +1580,6 @@ export async function saveBinary( req, res ) {
|
|
|
1507
1580
|
createdAt: Date.now(),
|
|
1508
1581
|
};
|
|
1509
1582
|
await insertOpenSearchData( openSearch.auditLog, logData1 );
|
|
1510
|
-
logger.info( 'update in binary data', { query: leftquery, update: leftupdate } );
|
|
1511
1583
|
return res.sendSuccess( `Successfully updated in ${value}` );
|
|
1512
1584
|
|
|
1513
1585
|
break;
|
|
@@ -1558,7 +1630,6 @@ export async function saveBinary( req, res ) {
|
|
|
1558
1630
|
createdAt: Date.now(),
|
|
1559
1631
|
};
|
|
1560
1632
|
await insertOpenSearchData( openSearch.auditLog, logData );
|
|
1561
|
-
logger.info( 'update in binary data', { query: cameraquery, update: cameraupdate } );
|
|
1562
1633
|
return res.sendSuccess( `Successfully updated in ${value}` );
|
|
1563
1634
|
|
|
1564
1635
|
break;
|
|
@@ -1781,7 +1852,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1781
1852
|
},
|
|
1782
1853
|
);
|
|
1783
1854
|
}
|
|
1784
|
-
const count = [ '
|
|
1855
|
+
const count = [ 'mobile-detection' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
1785
1856
|
if ( count.length == 0 ) {
|
|
1786
1857
|
return res.sendError( 'No Data Found', 204 );
|
|
1787
1858
|
}
|
|
@@ -1826,9 +1897,10 @@ export async function userAuditHistory( req, res ) {
|
|
|
1826
1897
|
temp['User Comments'] = element.userComments;
|
|
1827
1898
|
break;
|
|
1828
1899
|
case 'uniform-detection':
|
|
1829
|
-
temp['
|
|
1830
|
-
temp['
|
|
1831
|
-
temp['
|
|
1900
|
+
temp['Customer ID'] = element.tempId;
|
|
1901
|
+
temp['Question'] = element.question;
|
|
1902
|
+
temp['Result'] = element.answer;
|
|
1903
|
+
temp['User Comments'] = element.userComments;
|
|
1832
1904
|
break;
|
|
1833
1905
|
case 'mobile-detection':
|
|
1834
1906
|
temp['Before Count'] = element.beforeCount;
|
|
@@ -1853,7 +1925,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1853
1925
|
{
|
|
1854
1926
|
$limit: limit,
|
|
1855
1927
|
} );
|
|
1856
|
-
const result = [ '
|
|
1928
|
+
const result = [ 'mobile-detection' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
1857
1929
|
|
|
1858
1930
|
return res.sendSuccess( { result: result, count: count.length } );
|
|
1859
1931
|
} catch ( error ) {
|
|
@@ -2178,7 +2250,7 @@ export async function clientMetrics( req, res ) {
|
|
|
2178
2250
|
);
|
|
2179
2251
|
}
|
|
2180
2252
|
|
|
2181
|
-
const count = [ '
|
|
2253
|
+
const count = [ 'mobile-detection' ].includes( inputData.moduleType )? await aggregateTraxAuditData( MappingQuery ) : await aggregateTraxAuditData( query );
|
|
2182
2254
|
logger.info( { count: count } );
|
|
2183
2255
|
if ( count.length == 0 ) {
|
|
2184
2256
|
return res.sendError( 'No Data Found', 204 );
|
|
@@ -2245,7 +2317,7 @@ export async function clientMetrics( req, res ) {
|
|
|
2245
2317
|
);
|
|
2246
2318
|
}
|
|
2247
2319
|
|
|
2248
|
-
const result = [ '
|
|
2320
|
+
const result = [ 'mobile-detection' ].includes( inputData.moduleType )? await aggregateTraxAuditData( MappingQuery ) : await aggregateTraxAuditData( query );
|
|
2249
2321
|
if ( result.length == 0 ) {
|
|
2250
2322
|
return res.sendError( 'No Data Found', 204 );
|
|
2251
2323
|
}
|
|
@@ -2280,7 +2352,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2280
2352
|
}
|
|
2281
2353
|
|
|
2282
2354
|
if ( inputData.filterByStatus && inputData.filterByStatus?.length > 0 ) {
|
|
2283
|
-
[ '
|
|
2355
|
+
[ 'mobile-detection' ].includes( inputData.moduleType )? filter.push( { status: { $in: inputData.filterByStatus } } ) : filter.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
2284
2356
|
}
|
|
2285
2357
|
|
|
2286
2358
|
if ( inputData.filterByAuditType && inputData.filterByAuditType?.length > 0 ) {
|
|
@@ -2713,8 +2785,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2713
2785
|
},
|
|
2714
2786
|
);
|
|
2715
2787
|
}
|
|
2716
|
-
|
|
2717
|
-
const count = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryQuery );
|
|
2788
|
+
const count = [ 'mobile-detection' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryQuery );
|
|
2718
2789
|
|
|
2719
2790
|
|
|
2720
2791
|
if ( count.length == 0 ) {
|
|
@@ -2738,7 +2809,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2738
2809
|
$limit: limit,
|
|
2739
2810
|
} );
|
|
2740
2811
|
}
|
|
2741
|
-
const result = [ '
|
|
2812
|
+
const result = [ 'mobile-detection' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryQuery );
|
|
2742
2813
|
if ( inputData.isExport ) {
|
|
2743
2814
|
const exportdata = [];
|
|
2744
2815
|
result.forEach( ( element ) => {
|
|
@@ -2779,10 +2850,11 @@ export async function storeMetrics( req, res ) {
|
|
|
2779
2850
|
temp['Accuracy'] = element.accuracy;
|
|
2780
2851
|
break;
|
|
2781
2852
|
case 'uniform-detection':
|
|
2782
|
-
temp['
|
|
2783
|
-
temp['
|
|
2784
|
-
temp['
|
|
2785
|
-
temp['
|
|
2853
|
+
temp['Customer ID'] = element.tempId;
|
|
2854
|
+
temp['Question'] = element.question;
|
|
2855
|
+
temp['User Comments'] = element.userComments;
|
|
2856
|
+
temp['Status'] = toCamelCase( element.auditStatus );
|
|
2857
|
+
temp['Result'] = element.answer;
|
|
2786
2858
|
break;
|
|
2787
2859
|
}
|
|
2788
2860
|
exportdata.push( temp );
|
|
@@ -3056,7 +3128,7 @@ export async function userMetrics( req, res ) {
|
|
|
3056
3128
|
);
|
|
3057
3129
|
}
|
|
3058
3130
|
|
|
3059
|
-
const count = [ '
|
|
3131
|
+
const count = [ 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3060
3132
|
if ( count.length == 0 ) {
|
|
3061
3133
|
return res.sendError( 'No Data Found', 204 );
|
|
3062
3134
|
}
|
|
@@ -3092,7 +3164,7 @@ export async function userMetrics( req, res ) {
|
|
|
3092
3164
|
'Audited Date': { $dateToString: { format: '%Y-%m-%d', date: '$createdAt' } },
|
|
3093
3165
|
// 'Mapping Percentage': '$mappingPerc',
|
|
3094
3166
|
};
|
|
3095
|
-
[ '
|
|
3167
|
+
[ 'mobile-detection' ].includes( inputData.moduleType )?
|
|
3096
3168
|
query.push(
|
|
3097
3169
|
{
|
|
3098
3170
|
$project: detection,
|
|
@@ -3106,7 +3178,7 @@ export async function userMetrics( req, res ) {
|
|
|
3106
3178
|
}
|
|
3107
3179
|
|
|
3108
3180
|
|
|
3109
|
-
const result = [ '
|
|
3181
|
+
const result = [ 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3110
3182
|
if ( inputData.isExport ) {
|
|
3111
3183
|
await download( result, res );
|
|
3112
3184
|
return;
|
|
@@ -3250,7 +3322,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3250
3322
|
},
|
|
3251
3323
|
);
|
|
3252
3324
|
}
|
|
3253
|
-
const count = [ '
|
|
3325
|
+
const count = [ 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3254
3326
|
if ( count.length == 0 ) {
|
|
3255
3327
|
return res.sendError( 'No Data Found', 204 );
|
|
3256
3328
|
}
|
|
@@ -3266,7 +3338,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3266
3338
|
} );
|
|
3267
3339
|
}
|
|
3268
3340
|
|
|
3269
|
-
const result = [ '
|
|
3341
|
+
const result = [ 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3270
3342
|
if ( inputData.isExport ) {
|
|
3271
3343
|
const exportdata = [];
|
|
3272
3344
|
result.forEach( ( element ) => {
|
|
@@ -3295,7 +3367,8 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3295
3367
|
temp['Before Count'] = element.beforeCount;
|
|
3296
3368
|
break;
|
|
3297
3369
|
case 'uniform-detection':
|
|
3298
|
-
temp['
|
|
3370
|
+
temp['Customer ID'] = element.tempId;
|
|
3371
|
+
temp['Question'] = element.question;
|
|
3299
3372
|
break;
|
|
3300
3373
|
}
|
|
3301
3374
|
exportdata.push( temp );
|
|
@@ -3460,7 +3533,7 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
3460
3533
|
},
|
|
3461
3534
|
];
|
|
3462
3535
|
|
|
3463
|
-
const storeAudit = [ '
|
|
3536
|
+
const storeAudit = [ 'mobile-detection' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( storeAuditQuery ) : await aggregateBinaryAudit( binaryAuditQuery );
|
|
3464
3537
|
if ( storeAudit.length > 0 ) {
|
|
3465
3538
|
temp.inprogressStores= storeAudit[0].inprogressStores;
|
|
3466
3539
|
temp.completedStores = storeAudit[0].completedStores;
|
|
@@ -3648,7 +3721,7 @@ export async function summarySplit( req, res ) {
|
|
|
3648
3721
|
},
|
|
3649
3722
|
},
|
|
3650
3723
|
];
|
|
3651
|
-
const result = [ '
|
|
3724
|
+
const result = [ 'mobile-detection' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryAuditQuery );
|
|
3652
3725
|
const totalCount = await aggregateTraxAuditData( totalQuery );
|
|
3653
3726
|
result[0].totalCount = totalCount[0]?.total;
|
|
3654
3727
|
return res.sendSuccess( { result: result.length> 0? result[0]: temp } );
|
|
@@ -3678,7 +3751,7 @@ export async function overviewTable( req, res ) {
|
|
|
3678
3751
|
}
|
|
3679
3752
|
|
|
3680
3753
|
if ( inputData.filterByStatus.length > 0 ) {
|
|
3681
|
-
[ '
|
|
3754
|
+
[ 'mobile-detection' ].includes( inputData.moduleType )? filters.push( { status: { $in: inputData.filterByStatus } } ):filters.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
3682
3755
|
}
|
|
3683
3756
|
|
|
3684
3757
|
const query =[
|
|
@@ -3795,7 +3868,7 @@ export async function overviewTable( req, res ) {
|
|
|
3795
3868
|
},
|
|
3796
3869
|
);
|
|
3797
3870
|
}
|
|
3798
|
-
const count = [ '
|
|
3871
|
+
const count = [ 'mobile-detection' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3799
3872
|
if ( count.length == 0 ) {
|
|
3800
3873
|
return res.sendError( 'No Data Found', 204 );
|
|
3801
3874
|
}
|
|
@@ -3810,7 +3883,7 @@ export async function overviewTable( req, res ) {
|
|
|
3810
3883
|
$limit: limit,
|
|
3811
3884
|
} );
|
|
3812
3885
|
}
|
|
3813
|
-
const result = [ '
|
|
3886
|
+
const result = [ 'mobile-detection' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3814
3887
|
if ( inputData.isExport ) {
|
|
3815
3888
|
const exportdata = [];
|
|
3816
3889
|
result.forEach( ( element ) => {
|
|
@@ -3847,10 +3920,11 @@ export async function overviewTable( req, res ) {
|
|
|
3847
3920
|
temp['Status'] = toCamelCase( element.status );
|
|
3848
3921
|
break;
|
|
3849
3922
|
case 'uniform-detection':
|
|
3850
|
-
temp['
|
|
3851
|
-
temp['
|
|
3923
|
+
temp['Customer ID'] = element.tempId;
|
|
3924
|
+
temp['Question'] = element.question;
|
|
3925
|
+
temp['User Comments'] = element.userComments;
|
|
3852
3926
|
temp['Audit Type'] = element.auditType;
|
|
3853
|
-
temp['Status'] = toCamelCase( element.
|
|
3927
|
+
temp['Status'] = toCamelCase( element.auditStatus );
|
|
3854
3928
|
break;
|
|
3855
3929
|
}
|
|
3856
3930
|
exportdata.push( temp );
|
|
@@ -4423,6 +4497,7 @@ export async function getDraftedData( req, res ) {
|
|
|
4423
4497
|
export async function save( req, res ) {
|
|
4424
4498
|
try {
|
|
4425
4499
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
4500
|
+
const sqs = JSON.parse( process.env.SQS );
|
|
4426
4501
|
const inputData = req.body;
|
|
4427
4502
|
const isoDate = req.userAudit?.startTime;
|
|
4428
4503
|
const currentTime = dayjs();
|
|
@@ -4447,6 +4522,47 @@ export async function save( req, res ) {
|
|
|
4447
4522
|
};
|
|
4448
4523
|
await updateOneUserEmpDetection( { _id: inputData.auditId }, userUpdated );
|
|
4449
4524
|
await updateOneStoreEmpDetection( query, storeUpdated );
|
|
4525
|
+
|
|
4526
|
+
const getFilePath = await findOneTraxAuditData(
|
|
4527
|
+
{
|
|
4528
|
+
fileDate: inputData.fileDate,
|
|
4529
|
+
storeId: inputData.storeId,
|
|
4530
|
+
moduleType: inputData.moduleType,
|
|
4531
|
+
},
|
|
4532
|
+
);
|
|
4533
|
+
if ( !getFilePath ) {
|
|
4534
|
+
return res.sendError( ' SQS is not sent due to Inserted Data is not there', 400 );
|
|
4535
|
+
}
|
|
4536
|
+
const tempId=[];
|
|
4537
|
+
if ( inputData.employeeCount > 0 ) {
|
|
4538
|
+
for ( let i =0; i<employee.length; i++ ) {
|
|
4539
|
+
tempId.push( employee[i].img_id );
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
const sqsProduceQueue = {
|
|
4543
|
+
QueueUrl: `${sqs.url}${sqs.uniformOutput}`,
|
|
4544
|
+
MessageBody: JSON.stringify( {
|
|
4545
|
+
storeId: inputData.storeId,
|
|
4546
|
+
fileDate: inputData.fileDate,
|
|
4547
|
+
moduleType: inputData.moduleType,
|
|
4548
|
+
tempId: tempId,
|
|
4549
|
+
count: inputData.employeeCount,
|
|
4550
|
+
folderPath: getFilePath?.sqs?.Body?.folderPath,
|
|
4551
|
+
} ),
|
|
4552
|
+
};
|
|
4553
|
+
const sqsQueue = await sendMessageToQueue(
|
|
4554
|
+
sqsProduceQueue.QueueUrl,
|
|
4555
|
+
sqsProduceQueue.MessageBody,
|
|
4556
|
+
);
|
|
4557
|
+
|
|
4558
|
+
if ( sqsQueue.statusCode ) {
|
|
4559
|
+
logger.error( {
|
|
4560
|
+
error: `${sqsQueue}`,
|
|
4561
|
+
type: 'UPLOAD_ERROR',
|
|
4562
|
+
} );
|
|
4563
|
+
return res.sendError( 'SQS not sent', 500 );
|
|
4564
|
+
}
|
|
4565
|
+
|
|
4450
4566
|
const logData = {
|
|
4451
4567
|
userId: req.user._id,
|
|
4452
4568
|
userName: req.user.userName,
|
package/src/dtos/audit.dtos.js
CHANGED
|
@@ -52,7 +52,6 @@ export const saveDraftSchema = joi.object( {
|
|
|
52
52
|
auditId: joi.string().required(),
|
|
53
53
|
moduleType: joi.string().required(),
|
|
54
54
|
zoneName: joi.string().required(),
|
|
55
|
-
timeSpent: joi.number().required(),
|
|
56
55
|
auditType: joi.string().required(),
|
|
57
56
|
fileDate: joi.string().required(),
|
|
58
57
|
queueName: joi.string().required(),
|
|
@@ -89,7 +88,6 @@ export const saveSchema = joi.object( {
|
|
|
89
88
|
storeId: joi.string().required(),
|
|
90
89
|
fileDate: joi.string().required(),
|
|
91
90
|
auditType: joi.string().required(),
|
|
92
|
-
timeSpent: joi.number().required(),
|
|
93
91
|
moduleType: joi.string().required(),
|
|
94
92
|
zoneName: joi.string().required(),
|
|
95
93
|
beforeCount: joi.number().required(),
|