tango-app-api-audit 3.4.11-alpha.8 → 3.4.11
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 +16 -0
- package/src/validation/traxAuditValidation.js +1 -0
|
@@ -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
|
];
|
|
@@ -3886,367 +3892,426 @@ export async function auditImages( req, res ) {
|
|
|
3886
3892
|
}
|
|
3887
3893
|
}
|
|
3888
3894
|
|
|
3895
|
+
export async function getUserCredit( req, res ) {
|
|
3896
|
+
try {
|
|
3897
|
+
const userId=req.user.email;
|
|
3898
|
+
const getLastDate = await findOneAuditUserWallet( {}, {}, { fileData: -1 } );
|
|
3899
|
+
if ( !getLastDate ) {
|
|
3900
|
+
return res.sendError( 'No records found', 204 );
|
|
3901
|
+
}
|
|
3902
|
+
const getWallet = await findOneAuditUserWallet( { fileDate: getLastDate.fileDate, userEmail: userId }, { totalCredit: 1, fileDate: 1 } );
|
|
3903
|
+
if ( !getWallet ) {
|
|
3904
|
+
return res.sendSuccess( { result: 0 } );
|
|
3905
|
+
}
|
|
3906
|
+
return res.sendSuccess( { result: getWallet, isAuditUser: true } );
|
|
3907
|
+
} catch ( error ) {
|
|
3908
|
+
const err = error.message || 'Internal Server Error';
|
|
3909
|
+
logger.info( { error: error, function: 'getUserCredit' } );
|
|
3910
|
+
return res.sendError( err, 500 );
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3889
3914
|
export async function getUserAuditCount( req, res ) {
|
|
3890
3915
|
try {
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3916
|
+
for ( let i =4; i<15; i++ ) {
|
|
3917
|
+
const userWallet = JSON.parse( process.env.USER_WALLET );
|
|
3918
|
+
const previousDate = dayjs( new Date() ).subtract( i, 'days' );
|
|
3919
|
+
const fileDate = dayjs( previousDate ).format( 'DD-MM-YYYY' );
|
|
3920
|
+
const configTimeSpentSec = userWallet.minTimeSpentSec; // 18000;
|
|
3921
|
+
// const beforeCountX = userWallet.beforeCountCreditPerc; // 0.0335;
|
|
3922
|
+
// const afterCountY = userWallet.afterCountCreditPerc; // 0.0035;
|
|
3923
|
+
const reduce = userWallet.reductionPerc; // 0.05;
|
|
3924
|
+
const today = new Date();
|
|
3925
|
+
|
|
3926
|
+
// Subtract one day to get the previous day
|
|
3927
|
+
const previousDay = new Date( today );
|
|
3928
|
+
previousDay.setDate( today.getDate() - i );
|
|
3929
|
+
const lateLogin = previousDay;
|
|
3930
|
+
logger.info( { lateLogin1: lateLogin } );
|
|
3931
|
+
lateLogin.setHours( 21, 30, 0, 0 );
|
|
3932
|
+
logger.info( { lateLogin: lateLogin } );
|
|
3933
|
+
const auditUserQuery=[
|
|
3934
|
+
{
|
|
3935
|
+
$match: {
|
|
3936
|
+
$and: [
|
|
3937
|
+
{ type: { $eq: 'consultant' } },
|
|
3938
|
+
{ isActive: { $eq: true } },
|
|
3939
|
+
],
|
|
3940
|
+
},
|
|
3905
3941
|
},
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3942
|
+
{
|
|
3943
|
+
$group: {
|
|
3944
|
+
_id: null,
|
|
3945
|
+
userList: { $push: '$userId' },
|
|
3946
|
+
},
|
|
3911
3947
|
},
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3948
|
+
{
|
|
3949
|
+
$project: {
|
|
3950
|
+
_id: 0,
|
|
3951
|
+
userList: 1,
|
|
3952
|
+
},
|
|
3917
3953
|
},
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3954
|
+
];
|
|
3955
|
+
const auditUserList = await aggregateAuditUsers( auditUserQuery );
|
|
3956
|
+
if ( auditUserList.length==0 ) {
|
|
3957
|
+
return res.sendError( 'No users available', 204 );
|
|
3958
|
+
}
|
|
3959
|
+
const userCountQuery= [
|
|
3960
|
+
{
|
|
3961
|
+
$match: {
|
|
3962
|
+
$and: [
|
|
3963
|
+
{ fileDate: { $eq: fileDate } },
|
|
3964
|
+
{ auditStatus: { $eq: 'completed' } },
|
|
3965
|
+
{ userId: { $in: auditUserList[0].userList } },
|
|
3966
|
+
],
|
|
3967
|
+
},
|
|
3932
3968
|
},
|
|
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
|
-
|
|
3969
|
+
// {
|
|
3970
|
+
// $project: {
|
|
3971
|
+
|
|
3972
|
+
// trafficUserCount: { $cond: [
|
|
3973
|
+
// { $eq: [ '$moduleType', 'traffic' ] }, '$userId', '$$REMOVE',
|
|
3974
|
+
// ] },
|
|
3975
|
+
// zoneUserCount: { $cond: [
|
|
3976
|
+
// { $eq: [ '$moduleType', 'zone' ] }, '$userId', '$$REMOVE',
|
|
3977
|
+
// ] },
|
|
3978
|
+
|
|
3979
|
+
// trafficFilesCount: { $cond: [
|
|
3980
|
+
// { $eq: [ '$moduleType', 'traffic' ] }, '$beforeCount', '$$REMOVE',
|
|
3981
|
+
// ] },
|
|
3982
|
+
// zoneFilesCount: { $cond: [
|
|
3983
|
+
// { $eq: [ '$moduleType', 'zone' ] }, '$beforeCount', '$$REMOVE',
|
|
3984
|
+
// ] },
|
|
3985
|
+
|
|
3986
|
+
// },
|
|
3987
|
+
// },
|
|
3988
|
+
{
|
|
3989
|
+
$group: {
|
|
3990
|
+
_id: null,
|
|
3991
|
+
// trafficUserCount: { $addToSet: '$trafficUserCount' },
|
|
3992
|
+
// zoneUserCount: { $addToSet: '$zoneUserCount' },
|
|
3993
|
+
// trafficFilesCount: { $sum: '$trafficFilesCount' },
|
|
3994
|
+
// zoneFilesCount: { $sum: '$zoneFilesCount' },
|
|
3995
|
+
userCount: { $addToSet: '$userId' },
|
|
3996
|
+
filesCount: { $sum: '$beforeCount' },
|
|
3997
|
+
},
|
|
3962
3998
|
},
|
|
3963
|
-
|
|
3964
|
-
];
|
|
3999
|
+
];
|
|
3965
4000
|
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
4001
|
+
// const storeDataQuery= [
|
|
4002
|
+
// {
|
|
4003
|
+
// $match: {
|
|
4004
|
+
// fileDate: { $eq: fileDate },
|
|
4005
|
+
// },
|
|
4006
|
+
// },
|
|
4007
|
+
// {
|
|
4008
|
+
// $project: {
|
|
3974
4009
|
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
4010
|
+
// trafficFilesCount: { $cond: [
|
|
4011
|
+
// { $eq: [ '$moduleType', 'traffic' ] }, '$totalFilesCount', '$$REMOVE',
|
|
4012
|
+
// ] },
|
|
4013
|
+
// zoneFilesCount: { $cond: [
|
|
4014
|
+
// { $eq: [ '$moduleType', 'zone' ] }, '$totalFilesCount', '$$REMOVE',
|
|
4015
|
+
// ] },
|
|
3981
4016
|
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4017
|
+
// },
|
|
4018
|
+
// },
|
|
4019
|
+
// {
|
|
4020
|
+
// $group: {
|
|
4021
|
+
// _id: '$moduleType',
|
|
4022
|
+
// trafficFilesCount: { $sum: '$trafficFilesCount' },
|
|
4023
|
+
// zoneFilesCount: { $sum: '$zoneFilesCount' },
|
|
4024
|
+
// },
|
|
4025
|
+
// },
|
|
4026
|
+
// {
|
|
4027
|
+
// $project: {
|
|
4028
|
+
// _id: 0,
|
|
4029
|
+
// trafficFilesCount: { $ifNull: [ '$trafficFilesCount', 0 ] },
|
|
4030
|
+
// zoneFilesCount: { $ifNull: [ '$zoneFilesCount', 0 ] },
|
|
4031
|
+
// },
|
|
4032
|
+
// },
|
|
4033
|
+
// ];
|
|
4034
|
+
const userCount = await aggregateUserAuditCount( userCountQuery );
|
|
4000
4035
|
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4036
|
+
// const totalStoreData = await aggregateAuditStoreData( storeDataQuery );
|
|
4037
|
+
if ( userCount?.length == 0 ) {
|
|
4038
|
+
return res.sendError( 'No Data Found', 204 );
|
|
4039
|
+
}
|
|
4040
|
+
const minimumTarget =userCount[0]?.userCount?.length !== 0 && userCount[0]?.filesCount !==0 ? Math.floor( userCount[0].filesCount/userCount[0].userCount.length ) : 0;
|
|
4041
|
+
// const trafficMinimumTarget =userCount[0]?.trafficUserCount?.length !== 0 && userCount[0]?.trafficFilesCount !==0 ? Math.floor( userCount[0].trafficFilesCount/userCount[0].trafficUserCount.length ) : 0;
|
|
4042
|
+
const beforeCreditCal = 544/minimumTarget;
|
|
4043
|
+
// const beforeCountZone = 544/zoneMinimumTarget; // 0.0035;
|
|
4044
|
+
const afterCountCredit = 136;
|
|
4010
4045
|
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4046
|
+
const query = [
|
|
4047
|
+
{
|
|
4048
|
+
$match: {
|
|
4049
|
+
$and: [
|
|
4050
|
+
{ fileDate: { $eq: fileDate } },
|
|
4051
|
+
{
|
|
4052
|
+
auditStatus: { $eq: 'completed' },
|
|
4053
|
+
},
|
|
4054
|
+
{ userId: { $in: auditUserList[0].userList } },
|
|
4055
|
+
],
|
|
4056
|
+
},
|
|
4021
4057
|
},
|
|
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 ] },
|
|
4058
|
+
{
|
|
4059
|
+
$set: { minimumTarget: minimumTarget, afterCountCredit: afterCountCredit, beforeCreditCal: beforeCreditCal },
|
|
4043
4060
|
},
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4061
|
+
{
|
|
4062
|
+
$project: {
|
|
4063
|
+
userId: 1,
|
|
4064
|
+
moduleType: 1,
|
|
4065
|
+
beforeCount: 1,
|
|
4066
|
+
afterCount: 1,
|
|
4067
|
+
timeSpent: 1,
|
|
4068
|
+
fileDate: 1,
|
|
4069
|
+
fileDateISO: 1,
|
|
4070
|
+
minimumTarget: 1,
|
|
4071
|
+
afterCountCredit: 1,
|
|
4072
|
+
totalEarn: { $ifNull: [ 0, 0 ] },
|
|
4073
|
+
singleImageAmount: { $ifNull: [ '$beforeCreditCal', 0 ] },
|
|
4074
|
+
totalReducedAmount: { $ifNull: [ 0, 0 ] },
|
|
4075
|
+
totalCredit: { $ifNull: [ 0, 0 ] },
|
|
4076
|
+
deductionBytimeSpent: { $ifNull: [ 0, 0 ] },
|
|
4077
|
+
deductionByMinimumTarget: { $ifNull: [ 0, 0 ] },
|
|
4078
|
+
deductionByLateLogin: { $ifNull: [ 0, 0 ] },
|
|
4079
|
+
startTime: 1,
|
|
4080
|
+
},
|
|
4064
4081
|
},
|
|
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
|
-
],
|
|
4082
|
+
{
|
|
4083
|
+
$sort: { startTime: 1 },
|
|
4084
|
+
},
|
|
4085
|
+
{
|
|
4086
|
+
$group: {
|
|
4087
|
+
_id: { user: '$userId' },
|
|
4088
|
+
totalCount: { $sum: 1 },
|
|
4089
|
+
moduleType: { $first: '$moduleType' },
|
|
4090
|
+
totalBeforeCount: { $sum: '$beforeCount' },
|
|
4091
|
+
totalAfterCount: { $sum: '$afterCount' },
|
|
4092
|
+
totalTimeSpent: { $sum: '$timeSpent' },
|
|
4093
|
+
fileDate: { $first: '$fileDate' },
|
|
4094
|
+
fileDateISO: { $first: '$fileDateISO' },
|
|
4095
|
+
userId: { $first: '$userId' },
|
|
4096
|
+
minimumTarget: { $first: '$minimumTarget' },
|
|
4097
|
+
afterCountCredit: { $first: '$afterCountCredit' },
|
|
4098
|
+
totalEarn: { $first: '$totalEarn' },
|
|
4099
|
+
totalReducedAmount: { $first: '$totalReducedAmount' },
|
|
4100
|
+
totalCredit: { $first: '$totalCredit' },
|
|
4101
|
+
deductionByMinimumTarget: { $first: '$deductionByMinimumTarget' },
|
|
4102
|
+
deductionBytimeSpent: { $first: '$deductionBytimeSpent' },
|
|
4103
|
+
singleImageAmount: { $first: '$singleImageAmount' },
|
|
4104
|
+
startTime: { $first: '$startTime' },
|
|
4105
|
+
deductionByLateLogin: { $first: '$deductionByLateLogin' },
|
|
4102
4106
|
},
|
|
4103
|
-
] },
|
|
4104
|
-
totalReducedAmount: 1,
|
|
4105
|
-
totalCredit: 1,
|
|
4106
|
-
|
|
4107
4107
|
},
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4108
|
+
{
|
|
4109
|
+
$project: {
|
|
4110
|
+
totalCount: 1,
|
|
4111
|
+
userId: 1,
|
|
4112
|
+
moduleType: 1,
|
|
4113
|
+
totalBeforeCount: 1,
|
|
4114
|
+
totalAfterCount: 1,
|
|
4115
|
+
totalTimeSpent: 1,
|
|
4116
|
+
fileDate: 1,
|
|
4117
|
+
fileDateISO: 1,
|
|
4118
|
+
minimumTarget: 1,
|
|
4119
|
+
singleImageAmount: 1,
|
|
4120
|
+
beforeCountCredit: { $multiply: [ '$totalBeforeCount', '$singleImageAmount' ] },
|
|
4121
|
+
// afterCountCredit: { $cond: [ { $and: [
|
|
4122
|
+
// { $gte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.4 ] }, { $lte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
|
|
4123
|
+
// ] }, 136,
|
|
4124
|
+
// {
|
|
4125
|
+
// $cond: [ { $gt: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
|
|
4126
|
+
// { $subtract: [ 136, { $multiply: [ { $subtract: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] }, 136 ] } ] },
|
|
4127
|
+
// { $subtract: [ 136, { $multiply: [ { $subtract: [ 0.4, { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] } ] }, 136 ] } ] },
|
|
4128
|
+
// ],
|
|
4129
|
+
// },
|
|
4130
|
+
// ] },
|
|
4131
|
+
afterCountCredit: afterCountCredit,
|
|
4132
|
+
totalEarn: { $add: [ { $multiply: [ '$totalBeforeCount', '$singleImageAmount' ] }, 136 ] },
|
|
4133
|
+
deductionBytimeSpent: 1,
|
|
4134
|
+
deductionByMinimumTarget: 1,
|
|
4135
|
+
mappingperc: { $multiply: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 100 ] },
|
|
4136
|
+
deductionByMapping: { $cond: [ { $and: [
|
|
4137
|
+
{ $gte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.4 ] }, { $lte: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
|
|
4138
|
+
] }, 0,
|
|
4139
|
+
{
|
|
4140
|
+
$cond: [ { $gt: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] },
|
|
4141
|
+
{ $multiply: [ { $subtract: [ { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] }, 0.7 ] }, 136 ] },
|
|
4142
|
+
{ $multiply: [ { $subtract: [ 0.4, { $divide: [ '$totalAfterCount', '$totalBeforeCount' ] } ] }, 136 ] },
|
|
4143
|
+
],
|
|
4144
|
+
},
|
|
4145
|
+
] },
|
|
4146
|
+
deductionByLateLogin: 1,
|
|
4147
|
+
totalReducedAmount: 1,
|
|
4148
|
+
totalCredit: 1,
|
|
4149
|
+
startTime: 1,
|
|
4150
|
+
|
|
4124
4151
|
},
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
{ $
|
|
4135
|
-
|
|
4152
|
+
},
|
|
4153
|
+
{
|
|
4154
|
+
$project: {
|
|
4155
|
+
totalCount: 1,
|
|
4156
|
+
userId: 1,
|
|
4157
|
+
moduleType: 1,
|
|
4158
|
+
totalBeforeCount: 1,
|
|
4159
|
+
totalAfterCount: 1,
|
|
4160
|
+
totalTimeSpent: 1,
|
|
4161
|
+
hours: { $floor: { $divide: [ '$totalTimeSpent', 3600 ] } },
|
|
4162
|
+
minutes: {
|
|
4163
|
+
$floor: {
|
|
4164
|
+
$divide: [
|
|
4165
|
+
{ $mod: [ '$totalTimeSpent', 3600 ] }, // Get remaining minutes after hours
|
|
4166
|
+
60,
|
|
4167
|
+
] },
|
|
4168
|
+
},
|
|
4169
|
+
fileDate: 1,
|
|
4170
|
+
fileDateISO: 1,
|
|
4171
|
+
minimumTarget: 1,
|
|
4172
|
+
singleImageAmount: 1,
|
|
4173
|
+
beforeCountCredit: 1,
|
|
4174
|
+
afterCountCredit: 1,
|
|
4175
|
+
totalEarn: 1,
|
|
4176
|
+
deductionBytimeSpent: { $cond: [
|
|
4177
|
+
{ $lt: [ '$totalTimeSpent', configTimeSpentSec ] },
|
|
4178
|
+
{ $multiply: [ reduce, '$totalEarn' ] }, '$deductionBytimeSpent',
|
|
4179
|
+
] },
|
|
4136
4180
|
|
|
4137
|
-
|
|
4181
|
+
deductionByMinimumTarget:
|
|
4138
4182
|
{ $cond: [
|
|
4139
4183
|
{ $lt: [ '$totalBeforeCount', '$minimumTarget' ] },
|
|
4140
4184
|
{ $multiply: [ reduce, '$totalEarn' ] }, '$deductionByMinimumTarget',
|
|
4141
4185
|
] },
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4186
|
+
deductionByLateLogin: {
|
|
4187
|
+
$cond: [
|
|
4188
|
+
{ $gt: [ '$startTime', lateLogin ] },
|
|
4189
|
+
{ $multiply: [ reduce, '$totalEarn' ] }, '$deductionByLateLogin',
|
|
4190
|
+
],
|
|
4191
|
+
},
|
|
4192
|
+
mappingperc: 1,
|
|
4193
|
+
deductionByMapping: 1,
|
|
4194
|
+
totalCredit: { $subtract: [ '$totalEarn', '$totalReducedAmount' ] },
|
|
4195
|
+
startTime: 1,
|
|
4145
4196
|
|
|
4146
4197
|
|
|
4198
|
+
},
|
|
4147
4199
|
},
|
|
4148
|
-
},
|
|
4149
4200
|
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
{ $concat: [
|
|
4160
|
-
'00:', { $toString: '$minutes' }, ':00',
|
|
4161
|
-
] },
|
|
4162
|
-
{ $cond: [ { $eq: [ '$minutes', 0 ] },
|
|
4201
|
+
{
|
|
4202
|
+
$project: {
|
|
4203
|
+
totalCount: 1,
|
|
4204
|
+
userId: 1,
|
|
4205
|
+
moduleType: 1,
|
|
4206
|
+
totalBeforeCount: 1,
|
|
4207
|
+
totalAfterCount: 1,
|
|
4208
|
+
totalTimeSpent: {
|
|
4209
|
+
$cond: [ { $eq: [ '$hours', 0 ] },
|
|
4163
4210
|
{ $concat: [
|
|
4164
|
-
{ $toString: '$
|
|
4211
|
+
'00:', { $toString: '$minutes' }, ':00',
|
|
4165
4212
|
] },
|
|
4166
|
-
{
|
|
4167
|
-
$concat: [
|
|
4168
|
-
{ $toString: '$hours' }, ':',
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4213
|
+
{ $cond: [ { $eq: [ '$minutes', 0 ] },
|
|
4214
|
+
{ $concat: [
|
|
4215
|
+
{ $toString: '$hours' }, ':00:00',
|
|
4216
|
+
] },
|
|
4217
|
+
{
|
|
4218
|
+
$concat: [
|
|
4219
|
+
{ $toString: '$hours' }, ':',
|
|
4220
|
+
{ $toString: '$minutes' }, ':00',
|
|
4221
|
+
],
|
|
4222
|
+
},
|
|
4223
|
+
] },
|
|
4224
|
+
],
|
|
4174
4225
|
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4226
|
+
},
|
|
4227
|
+
fileDate: 1,
|
|
4228
|
+
fileDateISO: 1,
|
|
4229
|
+
minimumTarget: 1,
|
|
4230
|
+
beforeCountCredit: 1,
|
|
4231
|
+
afterCountCredit: 1,
|
|
4232
|
+
totalEarn: 1,
|
|
4233
|
+
deductionByMinimumTarget: 1,
|
|
4234
|
+
singleImageAmount: 1,
|
|
4235
|
+
deductionBytimeSpent: 1,
|
|
4236
|
+
mappingperc: 1,
|
|
4237
|
+
deductionByMapping: 1,
|
|
4238
|
+
totalCredit: { $subtract: [ '$totalEarn', '$totalReducedAmount' ] },
|
|
4239
|
+
totalReducedAmount: { $round: [ { $add: [ '$deductionBytimeSpent', '$deductionByMinimumTarget', '$deductionByMapping', '$deductionByLateLogin' ] }, 2 ] },
|
|
4240
|
+
deductionByLateLogin: 1,
|
|
4241
|
+
startTime: {
|
|
4242
|
+
$dateToString: {
|
|
4243
|
+
format: '%H:%M:%S',
|
|
4244
|
+
date: '$startTime',
|
|
4245
|
+
timezone: 'Asia/Kolkata',
|
|
4246
|
+
},
|
|
4189
4247
|
|
|
4248
|
+
},
|
|
4249
|
+
|
|
4250
|
+
},
|
|
4190
4251
|
},
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4252
|
+
{
|
|
4253
|
+
$lookup: {
|
|
4254
|
+
from: 'users',
|
|
4255
|
+
let: { userId: '$userId' }, // Assuming userId is the linking field
|
|
4256
|
+
pipeline: [
|
|
4257
|
+
{
|
|
4258
|
+
$match: {
|
|
4259
|
+
$expr: { $eq: [ '$_id', '$$userId' ] },
|
|
4260
|
+
},
|
|
4200
4261
|
},
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4262
|
+
{
|
|
4263
|
+
$project: {
|
|
4264
|
+
_id: 0, // Exclude _id if not needed
|
|
4265
|
+
email: 1,
|
|
4266
|
+
userName: 1,
|
|
4267
|
+
},
|
|
4207
4268
|
},
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4269
|
+
],
|
|
4270
|
+
as: 'users',
|
|
4271
|
+
},
|
|
4211
4272
|
},
|
|
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
|
-
|
|
4273
|
+
{ $unwind: { path: '$users', preserveNullAndEmptyArrays: true } },
|
|
4274
|
+
{
|
|
4275
|
+
$project: {
|
|
4276
|
+
_id: 0,
|
|
4277
|
+
totalFilesCount: { $round: [ '$totalCount', 2 ] },
|
|
4278
|
+
moduleType: 1,
|
|
4279
|
+
totalAfterCount: { $round: [ '$totalAfterCount', 2 ] },
|
|
4280
|
+
totalBeforeCount: { $round: [ '$totalBeforeCount', 2 ] },
|
|
4281
|
+
timeSpent: '$totalTimeSpent',
|
|
4282
|
+
fileDate: 1,
|
|
4283
|
+
fileDateISO: 1,
|
|
4284
|
+
beforeCountCredit: 1,
|
|
4285
|
+
afterCountCredit: 1,
|
|
4286
|
+
totalEarn: { $round: [ '$totalEarn', 2 ] },
|
|
4287
|
+
minimumTarget: 1,
|
|
4288
|
+
singleImageAmount: 1,
|
|
4289
|
+
deductionByMinimumTarget: { $round: [ '$deductionByMinimumTarget', 2 ] },
|
|
4290
|
+
deductionBytimeSpent: { $round: [ '$deductionBytimeSpent', 2 ] },
|
|
4291
|
+
mappingperc: 1,
|
|
4292
|
+
deductionByMapping: 1,
|
|
4293
|
+
totalReducedAmount: 1,
|
|
4294
|
+
totalCredit: { $round: [ { $subtract: [ '$totalEarn', '$totalReducedAmount' ] }, 2 ] },
|
|
4295
|
+
userEmail: '$users.email', // Access first element from array
|
|
4296
|
+
userName: '$users.userName', // Access first element from array,
|
|
4297
|
+
startTime: 1,
|
|
4298
|
+
deductionByLateLogin: 1,
|
|
4237
4299
|
|
|
4300
|
+
},
|
|
4238
4301
|
},
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4302
|
+
];
|
|
4303
|
+
const consolidatedData = await aggregateUserAuditCount( query );
|
|
4304
|
+
if ( consolidatedData.length == 0 ) {
|
|
4305
|
+
return res.sendError( 'No Data found', 204 );
|
|
4306
|
+
}
|
|
4307
|
+
const result = await createAuditUserWallet( consolidatedData );
|
|
4308
|
+
if ( result.length == 0 ) {
|
|
4309
|
+
return res.sendError( 'No Record Inserted', 500 );
|
|
4310
|
+
}
|
|
4311
|
+
if ( i == 14 ) {
|
|
4312
|
+
return res.sendSuccess( { message: 'Inserted successfully!' } );
|
|
4313
|
+
}
|
|
4248
4314
|
}
|
|
4249
|
-
return res.sendSuccess( { message: 'Inserted successfully!' } );
|
|
4250
4315
|
} catch ( error ) {
|
|
4251
4316
|
const err = error.message || 'Internal Server Error';
|
|
4252
4317
|
logger.info( { error: error, message: req.body, function: 'getUserAuditCount' } );
|
|
@@ -4672,7 +4737,7 @@ export async function auditViewLogs( req, res ) {
|
|
|
4672
4737
|
};
|
|
4673
4738
|
break;
|
|
4674
4739
|
case 'uniform-detection':
|
|
4675
|
-
case 'mobile-detection':
|
|
4740
|
+
case 'mobile-detection':
|
|
4676
4741
|
logsQuery = {
|
|
4677
4742
|
'size': 100,
|
|
4678
4743
|
'query': {
|