tango-app-api-audit 3.4.11-alpha.9 → 3.4.12
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 +2 -2
- package/src/controllers/audit.controllers.js +419 -354
- package/src/controllers/traxAudit.controllers.js +99 -62
- package/src/docs/audit.docs.js +56 -1
- package/src/dtos/audit.dtos.js +13 -0
- package/src/routes/audit.routes.js +5 -4
- package/src/service/auditUserWallet.service.js +4 -0
- package/src/service/auditUsers.service.js +4 -0
- package/src/validation/audit.validation.js +25 -7
- package/src/validation/traxAuditValidation.js +1 -1
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
import { aggregateStoreEmpDetection } from '../service/storeEmpDetection.service.js';
|
|
64
64
|
import { aggregateBinaryAudit } from '../service/binaryAudit.service.js';
|
|
65
65
|
import { aggregateTraxAuditData, findOneTraxAuditData } from '../service/traxAuditData.service.js';
|
|
66
|
-
import { createAuditUserWallet } from '../service/auditUserWallet.service.js';
|
|
66
|
+
import { createAuditUserWallet, findOneAuditUserWallet } from '../service/auditUserWallet.service.js';
|
|
67
67
|
import { aggregateAuditUsers } from '../service/auditUsers.service.js';
|
|
68
68
|
|
|
69
69
|
/* < -- *** Configuration *** --> */
|
|
@@ -324,6 +324,7 @@ export async function getAuditFile( req, res ) {
|
|
|
324
324
|
userId: log.userId,
|
|
325
325
|
moduleType: userDetails[0].moduleType,
|
|
326
326
|
zoneName: userDetails[0].zoneName,
|
|
327
|
+
timeSpent: log.timeSpent,
|
|
327
328
|
};
|
|
328
329
|
const result = {
|
|
329
330
|
junk: log.junk,
|
|
@@ -378,6 +379,7 @@ export async function getAuditFile( req, res ) {
|
|
|
378
379
|
storeName: storeDetails?.storeName,
|
|
379
380
|
address: storeDetails?.address || '',
|
|
380
381
|
count: log.totalCount,
|
|
382
|
+
timeSpent: log.timeSpent,
|
|
381
383
|
file: file,
|
|
382
384
|
isDraft: userDetails[0].isDraft,
|
|
383
385
|
} );
|
|
@@ -528,6 +530,7 @@ export async function getAuditFile( req, res ) {
|
|
|
528
530
|
img_id: image[0],
|
|
529
531
|
selected: false,
|
|
530
532
|
dropped: false,
|
|
533
|
+
demographic: '',
|
|
531
534
|
count: 1,
|
|
532
535
|
mappedid: [ mapimg ],
|
|
533
536
|
} );
|
|
@@ -715,6 +718,7 @@ export async function getAuditImage( msg ) {
|
|
|
715
718
|
img_name: indexes[1],
|
|
716
719
|
img_id: image[0],
|
|
717
720
|
selected: false,
|
|
721
|
+
// demographic: '',
|
|
718
722
|
dropped: false,
|
|
719
723
|
count: 1,
|
|
720
724
|
mappedid: [ mapimg ],
|
|
@@ -1166,14 +1170,14 @@ export async function saveDraft( req, res ) {
|
|
|
1166
1170
|
};
|
|
1167
1171
|
|
|
1168
1172
|
if ( getUserAuditData?.startTime ) {
|
|
1169
|
-
const isoDate = getUserAuditData.startTime;
|
|
1170
|
-
const currentTime = dayjs();
|
|
1171
|
-
const isoDateTime = dayjs( isoDate );
|
|
1172
|
-
const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
|
|
1173
|
+
// const isoDate = getUserAuditData.startTime;
|
|
1174
|
+
// const currentTime = dayjs();
|
|
1175
|
+
// const isoDateTime = dayjs( isoDate );
|
|
1176
|
+
// const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
|
|
1173
1177
|
|
|
1174
|
-
userRecord.timeSpent =
|
|
1178
|
+
userRecord.timeSpent = inputData.timeSpent;
|
|
1175
1179
|
|
|
1176
|
-
storeRecord.timeSpent =
|
|
1180
|
+
storeRecord.timeSpent =inputData.timeSpent;
|
|
1177
1181
|
}
|
|
1178
1182
|
|
|
1179
1183
|
if ( inputData.userCommands ) {
|
|
@@ -1190,7 +1194,7 @@ export async function saveDraft( req, res ) {
|
|
|
1190
1194
|
clientName: inputData.queueName,
|
|
1191
1195
|
beforeCount: inputData.totalCount,
|
|
1192
1196
|
afterCount: inputData.customerCount,
|
|
1193
|
-
timeSpent:
|
|
1197
|
+
timeSpent: inputData.timeSpent,
|
|
1194
1198
|
auditId: inputData.auditId,
|
|
1195
1199
|
moduleType: inputData.moduleType,
|
|
1196
1200
|
zoneName: inputData.zoneName,
|
|
@@ -1321,10 +1325,10 @@ export async function save( req, res ) {
|
|
|
1321
1325
|
// // moduleType: inputData.moduleType,
|
|
1322
1326
|
// // zoneName: inputData.zoneName,
|
|
1323
1327
|
// } );
|
|
1324
|
-
const isoDate = req.userAudit?.startTime;
|
|
1325
|
-
const currentTime = dayjs();
|
|
1326
|
-
const isoDateTime = dayjs( isoDate );
|
|
1327
|
-
const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
|
|
1328
|
+
// const isoDate = req.userAudit?.startTime;
|
|
1329
|
+
// const currentTime = dayjs();
|
|
1330
|
+
// const isoDateTime = dayjs( isoDate );
|
|
1331
|
+
// const timeDifferenceInMinutes = currentTime.diff( isoDateTime, 'seconds' );
|
|
1328
1332
|
|
|
1329
1333
|
await updateOneUserAudit(
|
|
1330
1334
|
{ _id: new mongoose.Types.ObjectId( inputData.auditId ) },
|
|
@@ -1333,7 +1337,7 @@ export async function save( req, res ) {
|
|
|
1333
1337
|
endTime: Date.now(),
|
|
1334
1338
|
isDraft: false,
|
|
1335
1339
|
afterCount: inputData.customerCount,
|
|
1336
|
-
timeSpent:
|
|
1340
|
+
timeSpent: inputData.timeSpent,
|
|
1337
1341
|
},
|
|
1338
1342
|
);
|
|
1339
1343
|
|
|
@@ -1354,26 +1358,16 @@ export async function save( req, res ) {
|
|
|
1354
1358
|
afterCount: inputData.customerCount,
|
|
1355
1359
|
startTime: req.userAudit?.startTime,
|
|
1356
1360
|
endTime: Date.now(),
|
|
1357
|
-
timeSpent:
|
|
1361
|
+
timeSpent: inputData.timeSpent,
|
|
1358
1362
|
auditId: new mongoose.Types.ObjectId( inputData.auditId ),
|
|
1359
1363
|
},
|
|
1360
1364
|
createdAt: Date.now(),
|
|
1361
1365
|
};
|
|
1362
1366
|
await insertOpenSearchData( openSearch.auditLog, logData );
|
|
1363
1367
|
|
|
1364
|
-
let storeConfig = await findOneStore(
|
|
1365
|
-
{
|
|
1366
|
-
storeId: req.userAudit?.storeId,
|
|
1367
|
-
},
|
|
1368
|
-
{
|
|
1369
|
-
auditConfigs: 1,
|
|
1370
|
-
clientId: 1,
|
|
1371
|
-
},
|
|
1372
|
-
);
|
|
1373
|
-
|
|
1374
1368
|
let clientData = await findClient( { clientId: req.userAudit?.clientId } );
|
|
1375
1369
|
const ratio = ( ( storeAuditData.beforeCount - inputData.customerCount ) / storeAuditData.beforeCount );
|
|
1376
|
-
if ( ratio <
|
|
1370
|
+
if ( ratio < clientData[0].auditConfigs.ratio &&
|
|
1377
1371
|
inputData.auditType == 'Audit' &&
|
|
1378
1372
|
inputData.moduleType == 'traffic'
|
|
1379
1373
|
) {
|
|
@@ -1421,7 +1415,7 @@ export async function save( req, res ) {
|
|
|
1421
1415
|
status: 'not_assign',
|
|
1422
1416
|
afterCount: inputData.customerCount,
|
|
1423
1417
|
auditType: 'ReAudit',
|
|
1424
|
-
timeSpent:
|
|
1418
|
+
timeSpent: inputData.timeSpent,
|
|
1425
1419
|
},
|
|
1426
1420
|
);
|
|
1427
1421
|
|
|
@@ -1442,7 +1436,7 @@ export async function save( req, res ) {
|
|
|
1442
1436
|
afterCount: inputData.customerCount,
|
|
1443
1437
|
startTime: req.userAudit?.startTime,
|
|
1444
1438
|
endTime: Date.now(),
|
|
1445
|
-
timeSpent:
|
|
1439
|
+
timeSpent: inputData.timeSpent,
|
|
1446
1440
|
auditId: new mongoose.Types.ObjectId( inputData.auditId ),
|
|
1447
1441
|
},
|
|
1448
1442
|
createdAt: Date.now(),
|
|
@@ -1464,7 +1458,7 @@ export async function save( req, res ) {
|
|
|
1464
1458
|
{
|
|
1465
1459
|
status: 'completed',
|
|
1466
1460
|
afterCount: inputData.customerCount,
|
|
1467
|
-
timeSpent:
|
|
1461
|
+
timeSpent: inputData.timeSpent,
|
|
1468
1462
|
},
|
|
1469
1463
|
);
|
|
1470
1464
|
const sqsProduceQueue = {
|
|
@@ -2316,11 +2310,17 @@ export async function userMetrics( req, res ) {
|
|
|
2316
2310
|
userId: 1,
|
|
2317
2311
|
fileDate: 1,
|
|
2318
2312
|
startTime: 1,
|
|
2319
|
-
endTime:
|
|
2313
|
+
endTime: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$endTime', '$$REMOVE' ] },
|
|
2320
2314
|
totalCompletedFiles: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, 1, 0 ] },
|
|
2321
2315
|
beforeCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$beforeCount', 0 ] },
|
|
2322
2316
|
afterCount: { $cond: [ { $eq: [ '$auditStatus', 'completed' ] }, '$afterCount', 0 ] },
|
|
2323
2317
|
createdAt: 1,
|
|
2318
|
+
// to: '$createdAt',
|
|
2319
|
+
},
|
|
2320
|
+
},
|
|
2321
|
+
{
|
|
2322
|
+
$sort: {
|
|
2323
|
+
endTime: -1,
|
|
2324
2324
|
},
|
|
2325
2325
|
},
|
|
2326
2326
|
{
|
|
@@ -2332,8 +2332,9 @@ export async function userMetrics( req, res ) {
|
|
|
2332
2332
|
beforeCount: { $sum: '$beforeCount' },
|
|
2333
2333
|
afterCount: { $sum: '$afterCount' },
|
|
2334
2334
|
checkIntime: { $first: '$startTime' },
|
|
2335
|
-
checkOutTime: { $
|
|
2335
|
+
checkOutTime: { $first: '$endTime' },
|
|
2336
2336
|
createdAt: { $first: '$createdAt' },
|
|
2337
|
+
to: { $last: '$createdAt' },
|
|
2337
2338
|
|
|
2338
2339
|
},
|
|
2339
2340
|
},
|
|
@@ -2369,6 +2370,7 @@ export async function userMetrics( req, res ) {
|
|
|
2369
2370
|
$divide: [ { $subtract: [ '$checkOutTime', '$checkIntime' ] }, 1000 ],
|
|
2370
2371
|
},
|
|
2371
2372
|
createdAt: 1,
|
|
2373
|
+
to: 1,
|
|
2372
2374
|
},
|
|
2373
2375
|
},
|
|
2374
2376
|
{
|
|
@@ -2385,6 +2387,7 @@ export async function userMetrics( req, res ) {
|
|
|
2385
2387
|
minutes: { $floor: { $divide: [ { $mod: [ '$differenceInSeconds', 3600 ] }, 60 ] } },
|
|
2386
2388
|
seconds: { $mod: [ '$differenceInSeconds', 60 ] },
|
|
2387
2389
|
createdAt: 1,
|
|
2390
|
+
to: 1,
|
|
2388
2391
|
},
|
|
2389
2392
|
},
|
|
2390
2393
|
{
|
|
@@ -2420,6 +2423,7 @@ export async function userMetrics( req, res ) {
|
|
|
2420
2423
|
},
|
|
2421
2424
|
},
|
|
2422
2425
|
createdAt: 1,
|
|
2426
|
+
to: 1,
|
|
2423
2427
|
},
|
|
2424
2428
|
},
|
|
2425
2429
|
{
|
|
@@ -2438,6 +2442,7 @@ export async function userMetrics( req, res ) {
|
|
|
2438
2442
|
$concat: [ '$hours', ':', '$minutes', ':', '$seconds' ],
|
|
2439
2443
|
},
|
|
2440
2444
|
createdAt: 1,
|
|
2445
|
+
to: 1,
|
|
2441
2446
|
},
|
|
2442
2447
|
},
|
|
2443
2448
|
{
|
|
@@ -2492,6 +2497,7 @@ export async function userMetrics( req, res ) {
|
|
|
2492
2497
|
},
|
|
2493
2498
|
workingHours: 1,
|
|
2494
2499
|
createdAt: 1,
|
|
2500
|
+
to: 1,
|
|
2495
2501
|
},
|
|
2496
2502
|
},
|
|
2497
2503
|
];
|
|
@@ -3847,7 +3853,6 @@ export async function auditImages( req, res ) {
|
|
|
3847
3853
|
case 'AC':
|
|
3848
3854
|
|
|
3849
3855
|
const [ filterData, auditImageAC ] = await Promise.all( [ getAuditFilterData( inputData ), getAuditImageData( inputData ) ] );
|
|
3850
|
-
|
|
3851
3856
|
if ( filterData?.errorCode || auditImageAC?.errorCode ) {
|
|
3852
3857
|
const error = ( filterData?.error || auditImageAC.error ) || 'Internal Server Error- get AC from Bucket';
|
|
3853
3858
|
const code = filterData?.errorCode || auditImageAC.errorCode;
|
|
@@ -3886,367 +3891,426 @@ export async function auditImages( req, res ) {
|
|
|
3886
3891
|
}
|
|
3887
3892
|
}
|
|
3888
3893
|
|
|
3894
|
+
export async function getUserCredit( req, res ) {
|
|
3895
|
+
try {
|
|
3896
|
+
const userId=req.user.email;
|
|
3897
|
+
const getLastDate = await findOneAuditUserWallet( {}, {}, { fileData: -1 } );
|
|
3898
|
+
if ( !getLastDate ) {
|
|
3899
|
+
return res.sendError( 'No records found', 204 );
|
|
3900
|
+
}
|
|
3901
|
+
const getWallet = await findOneAuditUserWallet( { fileDate: getLastDate.fileDate, userEmail: userId }, { totalCredit: 1, fileDate: 1 } );
|
|
3902
|
+
if ( !getWallet ) {
|
|
3903
|
+
return res.sendSuccess( { result: 0 } );
|
|
3904
|
+
}
|
|
3905
|
+
return res.sendSuccess( { result: getWallet, isAuditUser: true } );
|
|
3906
|
+
} catch ( error ) {
|
|
3907
|
+
const err = error.message || 'Internal Server Error';
|
|
3908
|
+
logger.info( { error: error, function: 'getUserCredit' } );
|
|
3909
|
+
return res.sendError( err, 500 );
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
|
|
3889
3913
|
export async function getUserAuditCount( req, res ) {
|
|
3890
3914
|
try {
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3915
|
+
for ( let i =4; i<15; i++ ) {
|
|
3916
|
+
const userWallet = JSON.parse( process.env.USER_WALLET );
|
|
3917
|
+
const previousDate = dayjs( new Date() ).subtract( i, 'days' );
|
|
3918
|
+
const fileDate = dayjs( previousDate ).format( 'DD-MM-YYYY' );
|
|
3919
|
+
const configTimeSpentSec = userWallet.minTimeSpentSec; // 18000;
|
|
3920
|
+
// const beforeCountX = userWallet.beforeCountCreditPerc; // 0.0335;
|
|
3921
|
+
// const afterCountY = userWallet.afterCountCreditPerc; // 0.0035;
|
|
3922
|
+
const reduce = userWallet.reductionPerc; // 0.05;
|
|
3923
|
+
const today = new Date();
|
|
3924
|
+
|
|
3925
|
+
// Subtract one day to get the previous day
|
|
3926
|
+
const previousDay = new Date( today );
|
|
3927
|
+
previousDay.setDate( today.getDate() - i );
|
|
3928
|
+
const lateLogin = previousDay;
|
|
3929
|
+
logger.info( { lateLogin1: lateLogin } );
|
|
3930
|
+
lateLogin.setHours( 21, 30, 0, 0 );
|
|
3931
|
+
logger.info( { lateLogin: lateLogin } );
|
|
3932
|
+
const auditUserQuery=[
|
|
3933
|
+
{
|
|
3934
|
+
$match: {
|
|
3935
|
+
$and: [
|
|
3936
|
+
{ type: { $eq: 'consultant' } },
|
|
3937
|
+
{ isActive: { $eq: true } },
|
|
3938
|
+
],
|
|
3939
|
+
},
|
|
3905
3940
|
},
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3941
|
+
{
|
|
3942
|
+
$group: {
|
|
3943
|
+
_id: null,
|
|
3944
|
+
userList: { $push: '$userId' },
|
|
3945
|
+
},
|
|
3911
3946
|
},
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3947
|
+
{
|
|
3948
|
+
$project: {
|
|
3949
|
+
_id: 0,
|
|
3950
|
+
userList: 1,
|
|
3951
|
+
},
|
|
3917
3952
|
},
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3953
|
+
];
|
|
3954
|
+
const auditUserList = await aggregateAuditUsers( auditUserQuery );
|
|
3955
|
+
if ( auditUserList.length==0 ) {
|
|
3956
|
+
return res.sendError( 'No users available', 204 );
|
|
3957
|
+
}
|
|
3958
|
+
const userCountQuery= [
|
|
3959
|
+
{
|
|
3960
|
+
$match: {
|
|
3961
|
+
$and: [
|
|
3962
|
+
{ fileDate: { $eq: fileDate } },
|
|
3963
|
+
{ auditStatus: { $eq: 'completed' } },
|
|
3964
|
+
{ userId: { $in: auditUserList[0].userList } },
|
|
3965
|
+
],
|
|
3966
|
+
},
|
|
3932
3967
|
},
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3968
|
+
// {
|
|
3969
|
+
// $project: {
|
|
3970
|
+
|
|
3971
|
+
// trafficUserCount: { $cond: [
|
|
3972
|
+
// { $eq: [ '$moduleType', 'traffic' ] }, '$userId', '$$REMOVE',
|
|
3973
|
+
// ] },
|
|
3974
|
+
// zoneUserCount: { $cond: [
|
|
3975
|
+
// { $eq: [ '$moduleType', 'zone' ] }, '$userId', '$$REMOVE',
|
|
3976
|
+
// ] },
|
|
3977
|
+
|
|
3978
|
+
// trafficFilesCount: { $cond: [
|
|
3979
|
+
// { $eq: [ '$moduleType', 'traffic' ] }, '$beforeCount', '$$REMOVE',
|
|
3980
|
+
// ] },
|
|
3981
|
+
// zoneFilesCount: { $cond: [
|
|
3982
|
+
// { $eq: [ '$moduleType', 'zone' ] }, '$beforeCount', '$$REMOVE',
|
|
3983
|
+
// ] },
|
|
3984
|
+
|
|
3985
|
+
// },
|
|
3986
|
+
// },
|
|
3987
|
+
{
|
|
3988
|
+
$group: {
|
|
3989
|
+
_id: null,
|
|
3990
|
+
// trafficUserCount: { $addToSet: '$trafficUserCount' },
|
|
3991
|
+
// zoneUserCount: { $addToSet: '$zoneUserCount' },
|
|
3992
|
+
// trafficFilesCount: { $sum: '$trafficFilesCount' },
|
|
3993
|
+
// zoneFilesCount: { $sum: '$zoneFilesCount' },
|
|
3994
|
+
userCount: { $addToSet: '$userId' },
|
|
3995
|
+
filesCount: { $sum: '$beforeCount' },
|
|
3996
|
+
},
|
|
3962
3997
|
},
|
|
3963
|
-
|
|
3964
|
-
];
|
|
3998
|
+
];
|
|
3965
3999
|
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
4000
|
+
// const storeDataQuery= [
|
|
4001
|
+
// {
|
|
4002
|
+
// $match: {
|
|
4003
|
+
// fileDate: { $eq: fileDate },
|
|
4004
|
+
// },
|
|
4005
|
+
// },
|
|
4006
|
+
// {
|
|
4007
|
+
// $project: {
|
|
3974
4008
|
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
4009
|
+
// trafficFilesCount: { $cond: [
|
|
4010
|
+
// { $eq: [ '$moduleType', 'traffic' ] }, '$totalFilesCount', '$$REMOVE',
|
|
4011
|
+
// ] },
|
|
4012
|
+
// zoneFilesCount: { $cond: [
|
|
4013
|
+
// { $eq: [ '$moduleType', 'zone' ] }, '$totalFilesCount', '$$REMOVE',
|
|
4014
|
+
// ] },
|
|
3981
4015
|
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4016
|
+
// },
|
|
4017
|
+
// },
|
|
4018
|
+
// {
|
|
4019
|
+
// $group: {
|
|
4020
|
+
// _id: '$moduleType',
|
|
4021
|
+
// trafficFilesCount: { $sum: '$trafficFilesCount' },
|
|
4022
|
+
// zoneFilesCount: { $sum: '$zoneFilesCount' },
|
|
4023
|
+
// },
|
|
4024
|
+
// },
|
|
4025
|
+
// {
|
|
4026
|
+
// $project: {
|
|
4027
|
+
// _id: 0,
|
|
4028
|
+
// trafficFilesCount: { $ifNull: [ '$trafficFilesCount', 0 ] },
|
|
4029
|
+
// zoneFilesCount: { $ifNull: [ '$zoneFilesCount', 0 ] },
|
|
4030
|
+
// },
|
|
4031
|
+
// },
|
|
4032
|
+
// ];
|
|
4033
|
+
const userCount = await aggregateUserAuditCount( userCountQuery );
|
|
4000
4034
|
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4035
|
+
// const totalStoreData = await aggregateAuditStoreData( storeDataQuery );
|
|
4036
|
+
if ( userCount?.length == 0 ) {
|
|
4037
|
+
return res.sendError( 'No Data Found', 204 );
|
|
4038
|
+
}
|
|
4039
|
+
const minimumTarget =userCount[0]?.userCount?.length !== 0 && userCount[0]?.filesCount !==0 ? Math.floor( userCount[0].filesCount/userCount[0].userCount.length ) : 0;
|
|
4040
|
+
// const trafficMinimumTarget =userCount[0]?.trafficUserCount?.length !== 0 && userCount[0]?.trafficFilesCount !==0 ? Math.floor( userCount[0].trafficFilesCount/userCount[0].trafficUserCount.length ) : 0;
|
|
4041
|
+
const beforeCreditCal = 544/minimumTarget;
|
|
4042
|
+
// const beforeCountZone = 544/zoneMinimumTarget; // 0.0035;
|
|
4043
|
+
const afterCountCredit = 136;
|
|
4010
4044
|
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4045
|
+
const query = [
|
|
4046
|
+
{
|
|
4047
|
+
$match: {
|
|
4048
|
+
$and: [
|
|
4049
|
+
{ fileDate: { $eq: fileDate } },
|
|
4050
|
+
{
|
|
4051
|
+
auditStatus: { $eq: 'completed' },
|
|
4052
|
+
},
|
|
4053
|
+
{ userId: { $in: auditUserList[0].userList } },
|
|
4054
|
+
],
|
|
4055
|
+
},
|
|
4021
4056
|
},
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
$set: { minimumTarget: minimumTarget, afterCountCredit: afterCountCredit, beforeCreditCal: beforeCreditCal },
|
|
4025
|
-
},
|
|
4026
|
-
{
|
|
4027
|
-
$project: {
|
|
4028
|
-
userId: 1,
|
|
4029
|
-
moduleType: 1,
|
|
4030
|
-
beforeCount: 1,
|
|
4031
|
-
afterCount: 1,
|
|
4032
|
-
timeSpent: 1,
|
|
4033
|
-
fileDate: 1,
|
|
4034
|
-
fileDateISO: 1,
|
|
4035
|
-
minimumTarget: 1,
|
|
4036
|
-
afterCountCredit: 1,
|
|
4037
|
-
totalEarn: { $ifNull: [ 0, 0 ] },
|
|
4038
|
-
singleImageAmount: { $ifNull: [ '$beforeCreditCal', 0 ] },
|
|
4039
|
-
totalReducedAmount: { $ifNull: [ 0, 0 ] },
|
|
4040
|
-
totalCredit: { $ifNull: [ 0, 0 ] },
|
|
4041
|
-
deductionBytimeSpent: { $ifNull: [ 0, 0 ] },
|
|
4042
|
-
deductionByMinimumTarget: { $ifNull: [ 0, 0 ] },
|
|
4057
|
+
{
|
|
4058
|
+
$set: { minimumTarget: minimumTarget, afterCountCredit: afterCountCredit, beforeCreditCal: beforeCreditCal },
|
|
4043
4059
|
},
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4060
|
+
{
|
|
4061
|
+
$project: {
|
|
4062
|
+
userId: 1,
|
|
4063
|
+
moduleType: 1,
|
|
4064
|
+
beforeCount: 1,
|
|
4065
|
+
afterCount: 1,
|
|
4066
|
+
timeSpent: 1,
|
|
4067
|
+
fileDate: 1,
|
|
4068
|
+
fileDateISO: 1,
|
|
4069
|
+
minimumTarget: 1,
|
|
4070
|
+
afterCountCredit: 1,
|
|
4071
|
+
totalEarn: { $ifNull: [ 0, 0 ] },
|
|
4072
|
+
singleImageAmount: { $ifNull: [ '$beforeCreditCal', 0 ] },
|
|
4073
|
+
totalReducedAmount: { $ifNull: [ 0, 0 ] },
|
|
4074
|
+
totalCredit: { $ifNull: [ 0, 0 ] },
|
|
4075
|
+
deductionBytimeSpent: { $ifNull: [ 0, 0 ] },
|
|
4076
|
+
deductionByMinimumTarget: { $ifNull: [ 0, 0 ] },
|
|
4077
|
+
deductionByLateLogin: { $ifNull: [ 0, 0 ] },
|
|
4078
|
+
startTime: 1,
|
|
4079
|
+
},
|
|
4064
4080
|
},
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
afterCountCredit: afterCountCredit,
|
|
4090
|
-
totalEarn: { $add: [ { $multiply: [ '$totalBeforeCount', '$singleImageAmount' ] }, 136 ] },
|
|
4091
|
-
deductionBytimeSpent: 1,
|
|
4092
|
-
deductionByMinimumTarget: 1,
|
|
4093
|
-
mappingperc: { $multiply: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 100 ] },
|
|
4094
|
-
deductionByMapping: { $cond: [ { $and: [
|
|
4095
|
-
{ $gte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.4 ] }, { $lte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
|
|
4096
|
-
] }, 0,
|
|
4097
|
-
{
|
|
4098
|
-
$cond: [ { $gt: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
|
|
4099
|
-
{ $multiply: [ { $subtract: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] }, 136 ] },
|
|
4100
|
-
{ $multiply: [ { $subtract: [ 0.4, { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] } ] }, 136 ] },
|
|
4101
|
-
],
|
|
4081
|
+
{
|
|
4082
|
+
$sort: { startTime: 1 },
|
|
4083
|
+
},
|
|
4084
|
+
{
|
|
4085
|
+
$group: {
|
|
4086
|
+
_id: { user: '$userId' },
|
|
4087
|
+
totalCount: { $sum: 1 },
|
|
4088
|
+
moduleType: { $first: '$moduleType' },
|
|
4089
|
+
totalBeforeCount: { $sum: '$beforeCount' },
|
|
4090
|
+
totalAfterCount: { $sum: '$afterCount' },
|
|
4091
|
+
totalTimeSpent: { $sum: '$timeSpent' },
|
|
4092
|
+
fileDate: { $first: '$fileDate' },
|
|
4093
|
+
fileDateISO: { $first: '$fileDateISO' },
|
|
4094
|
+
userId: { $first: '$userId' },
|
|
4095
|
+
minimumTarget: { $first: '$minimumTarget' },
|
|
4096
|
+
afterCountCredit: { $first: '$afterCountCredit' },
|
|
4097
|
+
totalEarn: { $first: '$totalEarn' },
|
|
4098
|
+
totalReducedAmount: { $first: '$totalReducedAmount' },
|
|
4099
|
+
totalCredit: { $first: '$totalCredit' },
|
|
4100
|
+
deductionByMinimumTarget: { $first: '$deductionByMinimumTarget' },
|
|
4101
|
+
deductionBytimeSpent: { $first: '$deductionBytimeSpent' },
|
|
4102
|
+
singleImageAmount: { $first: '$singleImageAmount' },
|
|
4103
|
+
startTime: { $first: '$startTime' },
|
|
4104
|
+
deductionByLateLogin: { $first: '$deductionByLateLogin' },
|
|
4102
4105
|
},
|
|
4103
|
-
] },
|
|
4104
|
-
totalReducedAmount: 1,
|
|
4105
|
-
totalCredit: 1,
|
|
4106
|
-
|
|
4107
4106
|
},
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4107
|
+
{
|
|
4108
|
+
$project: {
|
|
4109
|
+
totalCount: 1,
|
|
4110
|
+
userId: 1,
|
|
4111
|
+
moduleType: 1,
|
|
4112
|
+
totalBeforeCount: 1,
|
|
4113
|
+
totalAfterCount: 1,
|
|
4114
|
+
totalTimeSpent: 1,
|
|
4115
|
+
fileDate: 1,
|
|
4116
|
+
fileDateISO: 1,
|
|
4117
|
+
minimumTarget: 1,
|
|
4118
|
+
singleImageAmount: 1,
|
|
4119
|
+
beforeCountCredit: { $multiply: [ '$totalBeforeCount', '$singleImageAmount' ] },
|
|
4120
|
+
// afterCountCredit: { $cond: [ { $and: [
|
|
4121
|
+
// { $gte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.4 ] }, { $lte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
|
|
4122
|
+
// ] }, 136,
|
|
4123
|
+
// {
|
|
4124
|
+
// $cond: [ { $gt: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
|
|
4125
|
+
// { $subtract: [ 136, { $multiply: [ { $subtract: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] }, 136 ] } ] },
|
|
4126
|
+
// { $subtract: [ 136, { $multiply: [ { $subtract: [ 0.4, { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] } ] }, 136 ] } ] },
|
|
4127
|
+
// ],
|
|
4128
|
+
// },
|
|
4129
|
+
// ] },
|
|
4130
|
+
afterCountCredit: afterCountCredit,
|
|
4131
|
+
totalEarn: { $add: [ { $multiply: [ '$totalBeforeCount', '$singleImageAmount' ] }, 136 ] },
|
|
4132
|
+
deductionBytimeSpent: 1,
|
|
4133
|
+
deductionByMinimumTarget: 1,
|
|
4134
|
+
mappingperc: { $multiply: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 100 ] },
|
|
4135
|
+
deductionByMapping: { $cond: [ { $and: [
|
|
4136
|
+
{ $gte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.4 ] }, { $lte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
|
|
4137
|
+
] }, 0,
|
|
4138
|
+
{
|
|
4139
|
+
$cond: [ { $gt: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
|
|
4140
|
+
{ $multiply: [ { $subtract: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] }, 136 ] },
|
|
4141
|
+
{ $multiply: [ { $subtract: [ 0.4, { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] } ] }, 136 ] },
|
|
4142
|
+
],
|
|
4143
|
+
},
|
|
4144
|
+
] },
|
|
4145
|
+
deductionByLateLogin: 1,
|
|
4146
|
+
totalReducedAmount: 1,
|
|
4147
|
+
totalCredit: 1,
|
|
4148
|
+
startTime: 1,
|
|
4149
|
+
|
|
4124
4150
|
},
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
{ $
|
|
4135
|
-
|
|
4151
|
+
},
|
|
4152
|
+
{
|
|
4153
|
+
$project: {
|
|
4154
|
+
totalCount: 1,
|
|
4155
|
+
userId: 1,
|
|
4156
|
+
moduleType: 1,
|
|
4157
|
+
totalBeforeCount: 1,
|
|
4158
|
+
totalAfterCount: 1,
|
|
4159
|
+
totalTimeSpent: 1,
|
|
4160
|
+
hours: { $floor: { $divide: [ '$totalTimeSpent', 3600 ] } },
|
|
4161
|
+
minutes: {
|
|
4162
|
+
$floor: {
|
|
4163
|
+
$divide: [
|
|
4164
|
+
{ $mod: [ '$totalTimeSpent', 3600 ] }, // Get remaining minutes after hours
|
|
4165
|
+
60,
|
|
4166
|
+
] },
|
|
4167
|
+
},
|
|
4168
|
+
fileDate: 1,
|
|
4169
|
+
fileDateISO: 1,
|
|
4170
|
+
minimumTarget: 1,
|
|
4171
|
+
singleImageAmount: 1,
|
|
4172
|
+
beforeCountCredit: 1,
|
|
4173
|
+
afterCountCredit: 1,
|
|
4174
|
+
totalEarn: 1,
|
|
4175
|
+
deductionBytimeSpent: { $cond: [
|
|
4176
|
+
{ $lt: [ '$totalTimeSpent', configTimeSpentSec ] },
|
|
4177
|
+
{ $multiply: [ reduce, '$totalEarn' ] }, '$deductionBytimeSpent',
|
|
4178
|
+
] },
|
|
4136
4179
|
|
|
4137
|
-
|
|
4180
|
+
deductionByMinimumTarget:
|
|
4138
4181
|
{ $cond: [
|
|
4139
4182
|
{ $lt: [ '$totalBeforeCount', '$minimumTarget' ] },
|
|
4140
4183
|
{ $multiply: [ reduce, '$totalEarn' ] }, '$deductionByMinimumTarget',
|
|
4141
4184
|
] },
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4185
|
+
deductionByLateLogin: {
|
|
4186
|
+
$cond: [
|
|
4187
|
+
{ $gt: [ '$startTime', lateLogin ] },
|
|
4188
|
+
{ $multiply: [ reduce, '$totalEarn' ] }, '$deductionByLateLogin',
|
|
4189
|
+
],
|
|
4190
|
+
},
|
|
4191
|
+
mappingperc: 1,
|
|
4192
|
+
deductionByMapping: 1,
|
|
4193
|
+
totalCredit: { $subtract: [ '$totalEarn', '$totalReducedAmount' ] },
|
|
4194
|
+
startTime: 1,
|
|
4145
4195
|
|
|
4146
4196
|
|
|
4197
|
+
},
|
|
4147
4198
|
},
|
|
4148
|
-
},
|
|
4149
4199
|
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
{ $concat: [
|
|
4160
|
-
'00:', { $toString: '$minutes' }, ':00',
|
|
4161
|
-
] },
|
|
4162
|
-
{ $cond: [ { $eq: [ '$minutes', 0 ] },
|
|
4200
|
+
{
|
|
4201
|
+
$project: {
|
|
4202
|
+
totalCount: 1,
|
|
4203
|
+
userId: 1,
|
|
4204
|
+
moduleType: 1,
|
|
4205
|
+
totalBeforeCount: 1,
|
|
4206
|
+
totalAfterCount: 1,
|
|
4207
|
+
totalTimeSpent: {
|
|
4208
|
+
$cond: [ { $eq: [ '$hours', 0 ] },
|
|
4163
4209
|
{ $concat: [
|
|
4164
|
-
{ $toString: '$
|
|
4210
|
+
'00:', { $toString: '$minutes' }, ':00',
|
|
4165
4211
|
] },
|
|
4166
|
-
{
|
|
4167
|
-
$concat: [
|
|
4168
|
-
{ $toString: '$hours' }, ':',
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4212
|
+
{ $cond: [ { $eq: [ '$minutes', 0 ] },
|
|
4213
|
+
{ $concat: [
|
|
4214
|
+
{ $toString: '$hours' }, ':00:00',
|
|
4215
|
+
] },
|
|
4216
|
+
{
|
|
4217
|
+
$concat: [
|
|
4218
|
+
{ $toString: '$hours' }, ':',
|
|
4219
|
+
{ $toString: '$minutes' }, ':00',
|
|
4220
|
+
],
|
|
4221
|
+
},
|
|
4222
|
+
] },
|
|
4223
|
+
],
|
|
4174
4224
|
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4225
|
+
},
|
|
4226
|
+
fileDate: 1,
|
|
4227
|
+
fileDateISO: 1,
|
|
4228
|
+
minimumTarget: 1,
|
|
4229
|
+
beforeCountCredit: 1,
|
|
4230
|
+
afterCountCredit: 1,
|
|
4231
|
+
totalEarn: 1,
|
|
4232
|
+
deductionByMinimumTarget: 1,
|
|
4233
|
+
singleImageAmount: 1,
|
|
4234
|
+
deductionBytimeSpent: 1,
|
|
4235
|
+
mappingperc: 1,
|
|
4236
|
+
deductionByMapping: 1,
|
|
4237
|
+
totalCredit: { $subtract: [ '$totalEarn', '$totalReducedAmount' ] },
|
|
4238
|
+
totalReducedAmount: { $round: [ { $add: [ '$deductionBytimeSpent', '$deductionByMinimumTarget', '$deductionByMapping', '$deductionByLateLogin' ] }, 2 ] },
|
|
4239
|
+
deductionByLateLogin: 1,
|
|
4240
|
+
startTime: {
|
|
4241
|
+
$dateToString: {
|
|
4242
|
+
format: '%H:%M:%S',
|
|
4243
|
+
date: '$startTime',
|
|
4244
|
+
timezone: 'Asia/Kolkata',
|
|
4245
|
+
},
|
|
4189
4246
|
|
|
4247
|
+
},
|
|
4248
|
+
|
|
4249
|
+
},
|
|
4190
4250
|
},
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4251
|
+
{
|
|
4252
|
+
$lookup: {
|
|
4253
|
+
from: 'users',
|
|
4254
|
+
let: { userId: '$userId' }, // Assuming userId is the linking field
|
|
4255
|
+
pipeline: [
|
|
4256
|
+
{
|
|
4257
|
+
$match: {
|
|
4258
|
+
$expr: { $eq: [ '$_id', '$$userId' ] },
|
|
4259
|
+
},
|
|
4200
4260
|
},
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4261
|
+
{
|
|
4262
|
+
$project: {
|
|
4263
|
+
_id: 0, // Exclude _id if not needed
|
|
4264
|
+
email: 1,
|
|
4265
|
+
userName: 1,
|
|
4266
|
+
},
|
|
4207
4267
|
},
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4268
|
+
],
|
|
4269
|
+
as: 'users',
|
|
4270
|
+
},
|
|
4211
4271
|
},
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4272
|
+
{ $unwind: { path: '$users', preserveNullAndEmptyArrays: true } },
|
|
4273
|
+
{
|
|
4274
|
+
$project: {
|
|
4275
|
+
_id: 0,
|
|
4276
|
+
totalFilesCount: { $round: [ '$totalCount', 2 ] },
|
|
4277
|
+
moduleType: 1,
|
|
4278
|
+
totalAfterCount: { $round: [ '$totalAfterCount', 2 ] },
|
|
4279
|
+
totalBeforeCount: { $round: [ '$totalBeforeCount', 2 ] },
|
|
4280
|
+
timeSpent: '$totalTimeSpent',
|
|
4281
|
+
fileDate: 1,
|
|
4282
|
+
fileDateISO: 1,
|
|
4283
|
+
beforeCountCredit: 1,
|
|
4284
|
+
afterCountCredit: 1,
|
|
4285
|
+
totalEarn: { $round: [ '$totalEarn', 2 ] },
|
|
4286
|
+
minimumTarget: 1,
|
|
4287
|
+
singleImageAmount: 1,
|
|
4288
|
+
deductionByMinimumTarget: { $round: [ '$deductionByMinimumTarget', 2 ] },
|
|
4289
|
+
deductionBytimeSpent: { $round: [ '$deductionBytimeSpent', 2 ] },
|
|
4290
|
+
mappingperc: 1,
|
|
4291
|
+
deductionByMapping: 1,
|
|
4292
|
+
totalReducedAmount: 1,
|
|
4293
|
+
totalCredit: { $round: [ { $subtract: [ '$totalEarn', '$totalReducedAmount' ] }, 2 ] },
|
|
4294
|
+
userEmail: '$users.email', // Access first element from array
|
|
4295
|
+
userName: '$users.userName', // Access first element from array,
|
|
4296
|
+
startTime: 1,
|
|
4297
|
+
deductionByLateLogin: 1,
|
|
4237
4298
|
|
|
4299
|
+
},
|
|
4238
4300
|
},
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4301
|
+
];
|
|
4302
|
+
const consolidatedData = await aggregateUserAuditCount( query );
|
|
4303
|
+
if ( consolidatedData.length == 0 ) {
|
|
4304
|
+
return res.sendError( 'No Data found', 204 );
|
|
4305
|
+
}
|
|
4306
|
+
const result = await createAuditUserWallet( consolidatedData );
|
|
4307
|
+
if ( result.length == 0 ) {
|
|
4308
|
+
return res.sendError( 'No Record Inserted', 500 );
|
|
4309
|
+
}
|
|
4310
|
+
if ( i == 14 ) {
|
|
4311
|
+
return res.sendSuccess( { message: 'Inserted successfully!' } );
|
|
4312
|
+
}
|
|
4248
4313
|
}
|
|
4249
|
-
return res.sendSuccess( { message: 'Inserted successfully!' } );
|
|
4250
4314
|
} catch ( error ) {
|
|
4251
4315
|
const err = error.message || 'Internal Server Error';
|
|
4252
4316
|
logger.info( { error: error, message: req.body, function: 'getUserAuditCount' } );
|
|
@@ -4671,6 +4735,7 @@ export async function auditViewLogs( req, res ) {
|
|
|
4671
4735
|
},
|
|
4672
4736
|
};
|
|
4673
4737
|
break;
|
|
4738
|
+
case 'uniform-detection':
|
|
4674
4739
|
case 'mobile-detection':
|
|
4675
4740
|
logsQuery = {
|
|
4676
4741
|
'size': 100,
|