tango-app-api-audit 3.4.3-alpha.13 → 3.4.3-alpha.15
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.3-alpha.
|
|
3
|
+
"version": "3.4.3-alpha.15",
|
|
4
4
|
"description": "audit & audit metrics apis",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"mongodb": "^6.7.0",
|
|
25
25
|
"nodemon": "^3.1.3",
|
|
26
26
|
"swagger-ui-express": "^5.0.1",
|
|
27
|
-
"tango-api-schema": "^2.1.
|
|
27
|
+
"tango-api-schema": "^2.1.28",
|
|
28
28
|
"tango-app-api-middleware": "^3.1.33",
|
|
29
29
|
"winston": "^3.13.0",
|
|
30
30
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -2,7 +2,7 @@ import { checkFileExist, chunkArray, download, getDate, getDateWithCustomizeTime
|
|
|
2
2
|
import { aggregateBinaryAudit, createBinaryAudit, updateOneBinaryAuditModel } from '../service/binaryAudit.service.js';
|
|
3
3
|
import { countDocumentsStore, findOneStore } from '../service/store.service.js';
|
|
4
4
|
import { findOneUser } from '../service/user.service.js';
|
|
5
|
-
import { aggregateUserEmpDetection, createUserEmpDetection, updateOneUserEmpDetection } from '../service/userEmpDetection.service.js';
|
|
5
|
+
import { aggregateUserEmpDetection, countDocumentsUserEmpDetection, createUserEmpDetection, updateOneUserEmpDetection } from '../service/userEmpDetection.service.js';
|
|
6
6
|
import { aggregateTraxAuditData, findOneTraxAuditData } from '../service/traxAuditData.service.js';
|
|
7
7
|
import { aggregateClient, findOneClient } from '../service/client.service.js';
|
|
8
8
|
import dayjs from 'dayjs';
|
|
@@ -346,6 +346,7 @@ import { updateOneEmpDetectionOutput } from '../service/empDetectionOutput.servi
|
|
|
346
346
|
// img_id: img[3],
|
|
347
347
|
// selected: false,
|
|
348
348
|
// dropped: false,
|
|
349
|
+
// singleDetection: false,
|
|
349
350
|
// count: 1,
|
|
350
351
|
// mappedid: [ mapimg ],
|
|
351
352
|
// } );
|
|
@@ -1722,7 +1723,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1722
1723
|
'Start Time': element.startTime,
|
|
1723
1724
|
'End Time': element.endTime || '',
|
|
1724
1725
|
'Time Spent': element.timeSpent,
|
|
1725
|
-
'Status': element.auditStatus,
|
|
1726
|
+
'Status': toCamelCase( element.auditStatus ),
|
|
1726
1727
|
'Audited Date': dayjs( element.createdAt ).format( 'YYYY,MMM D' ),
|
|
1727
1728
|
'Result': element.answer,
|
|
1728
1729
|
|
|
@@ -2594,18 +2595,18 @@ export async function storeMetrics( req, res ) {
|
|
|
2594
2595
|
case 'left-in-middle':
|
|
2595
2596
|
temp['Question'] = element.question;
|
|
2596
2597
|
temp['User Comments'] = element.userComments;
|
|
2597
|
-
temp['Status'] = element.auditStatus;
|
|
2598
|
+
temp['Status'] = toCamelCase( element.auditStatus );
|
|
2598
2599
|
break;
|
|
2599
2600
|
case 'mobile-detection':
|
|
2600
2601
|
temp['Before Count'] = element.beforeCount;
|
|
2601
2602
|
temp['After Count'] = element.afterCount;
|
|
2602
|
-
temp['Status'] = element.status;
|
|
2603
|
+
temp['Status'] = toCamelCase( element.status );
|
|
2603
2604
|
temp['Accuracy'] = element.accuracy;
|
|
2604
2605
|
break;
|
|
2605
2606
|
case 'uniform-detection':
|
|
2606
2607
|
temp['Before Count'] = element.beforeCount;
|
|
2607
2608
|
temp['After Count'] = element.afterCount;
|
|
2608
|
-
temp['Status'] = element.status;
|
|
2609
|
+
temp['Status'] = toCamelCase( element.status );
|
|
2609
2610
|
temp['Accuracy'] = element.accuracy;
|
|
2610
2611
|
break;
|
|
2611
2612
|
}
|
|
@@ -3088,7 +3089,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3088
3089
|
'Start Time': element.startTime,
|
|
3089
3090
|
'User Name': element.userName,
|
|
3090
3091
|
'User Email': element.userEmail,
|
|
3091
|
-
'Status': element.auditStatus,
|
|
3092
|
+
'Status': toCamelCase( element.auditStatus ),
|
|
3092
3093
|
};
|
|
3093
3094
|
switch ( inputData.moduleType ) {
|
|
3094
3095
|
case 'camera-angle-change':
|
|
@@ -3635,32 +3636,32 @@ export async function overviewTable( req, res ) {
|
|
|
3635
3636
|
temp['stream Name'] = element.streamName;
|
|
3636
3637
|
temp['User Comments'] = element.userComments;
|
|
3637
3638
|
temp['Audit Type'] = element.auditType;
|
|
3638
|
-
temp['Status'] = element.auditStatus;
|
|
3639
|
+
temp['Status'] = toCamelCase( element.auditStatus );
|
|
3639
3640
|
break;
|
|
3640
3641
|
case 'unattended-customer':
|
|
3641
3642
|
temp['Customer ID'] = element.tempId;
|
|
3642
3643
|
temp['Question'] = element.question;
|
|
3643
3644
|
temp['User Comments'] = element.userComments;
|
|
3644
3645
|
temp['Audit Type'] = element.auditType;
|
|
3645
|
-
temp['Status'] = element.auditStatus;
|
|
3646
|
+
temp['Status'] = toCamelCase( element.auditStatus );
|
|
3646
3647
|
break;
|
|
3647
3648
|
case 'left-in-middle':
|
|
3648
3649
|
temp['Question'] = element.question;
|
|
3649
3650
|
temp['User Comments'] = element.userComments;
|
|
3650
3651
|
temp['Audit Type'] = element.auditType;
|
|
3651
|
-
temp['Status'] = element.auditStatus;
|
|
3652
|
+
temp['Status'] = toCamelCase( element.auditStatus );
|
|
3652
3653
|
break;
|
|
3653
3654
|
case 'mobile-detection':
|
|
3654
3655
|
temp['Before Count'] = element.beforeCount;
|
|
3655
3656
|
temp['After Count'] = element.afterCount;
|
|
3656
3657
|
temp['Audit Type'] = element.auditType;
|
|
3657
|
-
temp['Status'] = element.status;
|
|
3658
|
+
temp['Status'] = toCamelCase( element.status );
|
|
3658
3659
|
break;
|
|
3659
3660
|
case 'uniform-detection':
|
|
3660
3661
|
temp['Before Count'] = element.beforeCount;
|
|
3661
3662
|
temp['After Count'] = element.afterCount;
|
|
3662
3663
|
temp['Audit Type'] = element.auditType;
|
|
3663
|
-
temp['Status'] = element.status;
|
|
3664
|
+
temp['Status'] = toCamelCase( element.status );
|
|
3664
3665
|
break;
|
|
3665
3666
|
}
|
|
3666
3667
|
exportdata.push( temp );
|
|
@@ -4005,6 +4006,7 @@ export async function getDetectionAuditFile( req, res ) {
|
|
|
4005
4006
|
img_id: img[3],
|
|
4006
4007
|
selected: false,
|
|
4007
4008
|
dropped: false,
|
|
4009
|
+
singleDetection: false,
|
|
4008
4010
|
count: 1,
|
|
4009
4011
|
mappedid: [ mapimg ],
|
|
4010
4012
|
} );
|
|
@@ -4231,13 +4233,29 @@ export async function getDraftedData( req, res ) {
|
|
|
4231
4233
|
export async function save( req, res ) {
|
|
4232
4234
|
try {
|
|
4233
4235
|
const inputData = req.body;
|
|
4236
|
+
const isoDate = req.userAudit?.startTime;
|
|
4237
|
+
const currentTime = dayjs();
|
|
4238
|
+
const isoDateTime = dayjs( isoDate );
|
|
4239
|
+
const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
|
|
4234
4240
|
const getUserAuditData = await findOneUserEmpDetection( { _id: inputData.auditId } );
|
|
4235
4241
|
inputData.clientId = getUserAuditData.clientId;
|
|
4236
4242
|
const query ={ storeId: inputData.storeId, moduleType: inputData.moduleType, fileDate: inputData.fileDate };
|
|
4237
4243
|
const data = await updateOneEmpDetectionOutput( query, { $set: inputData }, { upsert: true } );
|
|
4238
4244
|
if ( data ) {
|
|
4239
|
-
|
|
4240
|
-
|
|
4245
|
+
const userUpdated ={
|
|
4246
|
+
auditStatus: 'completed',
|
|
4247
|
+
afterCount: inputData.employeeCount,
|
|
4248
|
+
endTime: Date.now(),
|
|
4249
|
+
isDraft: false,
|
|
4250
|
+
timeSpent: timeDifferenceInMinutes,
|
|
4251
|
+
};
|
|
4252
|
+
const storeUpdated ={
|
|
4253
|
+
status: 'completed',
|
|
4254
|
+
afterCount: inputData.employeeCount,
|
|
4255
|
+
timeSpent: timeDifferenceInMinutes,
|
|
4256
|
+
};
|
|
4257
|
+
await updateOneUserEmpDetection( { _id: inputData.auditId }, userUpdated );
|
|
4258
|
+
await updateOneStoreEmpDetection( query, storeUpdated );
|
|
4241
4259
|
return res.sendSuccess( { result: 'Updated Successfully' } );
|
|
4242
4260
|
} else {
|
|
4243
4261
|
return res.sendError( 'something went wrong', 403 );
|
|
@@ -4264,6 +4282,9 @@ export async function reTrigger( req, res ) {
|
|
|
4264
4282
|
if ( !getQueueName || queueName == '' ) {
|
|
4265
4283
|
return res.sendError( 'queueName does not create', 400 );
|
|
4266
4284
|
}
|
|
4285
|
+
const getRecord = await countDocumentsUserEmpDetection( { storeId: message.storeId,
|
|
4286
|
+
fileDate: message.fileDate,
|
|
4287
|
+
moduleType: message.moduleType, auditStatus: 'completed' } );
|
|
4267
4288
|
const msg = {
|
|
4268
4289
|
storeId: message.storeId,
|
|
4269
4290
|
fileDate: message.fileDate,
|
|
@@ -4273,6 +4294,7 @@ export async function reTrigger( req, res ) {
|
|
|
4273
4294
|
question: message.question,
|
|
4274
4295
|
folderPath: message.folderPath,
|
|
4275
4296
|
fileCount: message.fileCount,
|
|
4297
|
+
auditType: getRecord > 0? 'ReAudit':'Audit',
|
|
4276
4298
|
};
|
|
4277
4299
|
const sqsProduceQueue = {
|
|
4278
4300
|
QueueUrl: `${sqs.url}${queueName}`,
|
|
@@ -4338,3 +4360,15 @@ export async function reTrigger( req, res ) {
|
|
|
4338
4360
|
return res.sendError( err, 500 );
|
|
4339
4361
|
}
|
|
4340
4362
|
}
|
|
4363
|
+
|
|
4364
|
+
export function toCamelCase( str ) {
|
|
4365
|
+
logger.info( { str: str } );
|
|
4366
|
+
return str
|
|
4367
|
+
.split( '-' ) // Split the string by spaces
|
|
4368
|
+
.map( ( word, index ) =>
|
|
4369
|
+
// index === 0 ?
|
|
4370
|
+
// word.toLowerCase() : // Lowercase the first word
|
|
4371
|
+
word.charAt( 0 ).toUpperCase() + word.slice( 1 ).toLowerCase(), // Capitalize the first letter of subsequent words
|
|
4372
|
+
)
|
|
4373
|
+
.join( '' ); // Join the words without spaces
|
|
4374
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import userEmpDetectionModel from 'tango-api-schema/schema/userEmpDetection.model.js';
|
|
2
|
-
import { logger } from 'tango-app-api-middleware';
|
|
3
2
|
|
|
4
3
|
|
|
5
4
|
export function aggregateUserEmpDetection( query ) {
|
|
6
|
-
logger.info( { seelevt: 'yryruteretwyyyyyyyyyyyyyyyyyyyyyyyyyyyyewe' } );
|
|
7
5
|
return userEmpDetectionModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
|
|
8
6
|
}
|
|
9
7
|
|
|
@@ -15,6 +13,10 @@ export function findOneUserEmpDetection( query, fields ) {
|
|
|
15
13
|
return userEmpDetectionModel.findOne( query, fields );
|
|
16
14
|
}
|
|
17
15
|
|
|
16
|
+
export function countDocumentsUserEmpDetection( query, fields ) {
|
|
17
|
+
return userEmpDetectionModel.countDocuments( query, fields );
|
|
18
|
+
}
|
|
19
|
+
|
|
18
20
|
export function updateOneUserEmpDetection( query, record ) {
|
|
19
21
|
return userEmpDetectionModel.updateOne( query, { $set: record } );
|
|
20
22
|
}
|