tango-app-api-audit 3.3.0-alpha.14 → 3.3.0-alpha.16
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.3.0-alpha.
|
|
3
|
+
"version": "3.3.0-alpha.16",
|
|
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.0.
|
|
27
|
+
"tango-api-schema": "^2.0.157",
|
|
28
28
|
"tango-app-api-middleware": "^3.3.0-alpha.0",
|
|
29
29
|
"winston": "^3.13.0",
|
|
30
30
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -1983,7 +1983,7 @@ export async function storeMetrics( req, res ) {
|
|
|
1983
1983
|
_id: 0,
|
|
1984
1984
|
fileDate: 1,
|
|
1985
1985
|
storeId: 1,
|
|
1986
|
-
storeName: '$
|
|
1986
|
+
storeName: '$stores.storeName',
|
|
1987
1987
|
clientName: '',
|
|
1988
1988
|
clientId: 1,
|
|
1989
1989
|
zoneName: 1,
|
|
@@ -2065,7 +2065,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2065
2065
|
_id: 0,
|
|
2066
2066
|
fileDate: 1,
|
|
2067
2067
|
storeId: 1,
|
|
2068
|
-
storeName:
|
|
2068
|
+
storeName: 1,
|
|
2069
2069
|
userName: '$users.userName',
|
|
2070
2070
|
userEmail: '$users.userEmail',
|
|
2071
2071
|
clientId: 1,
|
|
@@ -2424,9 +2424,8 @@ export async function userMetrics( req, res ) {
|
|
|
2424
2424
|
'_id': 0,
|
|
2425
2425
|
'File Date': '$fileDate',
|
|
2426
2426
|
'User Name': '$userName',
|
|
2427
|
-
'User Id': '$userId',
|
|
2428
2427
|
'Total Completed Files Count': '$totalCompletedFiles',
|
|
2429
|
-
'Total
|
|
2428
|
+
'Total Before Count': '$beforeCount',
|
|
2430
2429
|
'Total After Count': '$afterCount',
|
|
2431
2430
|
'check Intime': '$checkIntime',
|
|
2432
2431
|
'check OutTime': '$checkOutTime',
|
|
@@ -2445,7 +2444,7 @@ export async function userMetrics( req, res ) {
|
|
|
2445
2444
|
return res.sendSuccess( { result: result, count: count.length } );
|
|
2446
2445
|
} catch ( error ) {
|
|
2447
2446
|
const err = error.error || 'Internal Server Error';
|
|
2448
|
-
logger.info( { error: error, message: req.body, function: '
|
|
2447
|
+
logger.info( { error: error, message: req.body, function: 'userMetrics' } );
|
|
2449
2448
|
return res.sendError( err, 500 );
|
|
2450
2449
|
}
|
|
2451
2450
|
}
|
|
@@ -2459,7 +2458,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2459
2458
|
let filters =[
|
|
2460
2459
|
{ fileDateISO: { $gte: dateRange.start } },
|
|
2461
2460
|
{ fileDateISO: { $lte: dateRange.end } },
|
|
2462
|
-
{ auditStatus: { $
|
|
2461
|
+
{ auditStatus: { $ne: 'completed' } },
|
|
2463
2462
|
|
|
2464
2463
|
];
|
|
2465
2464
|
|
|
@@ -2474,6 +2473,10 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2474
2473
|
if ( inputData.filterByAuditType.length > 0 ) {
|
|
2475
2474
|
filters.push( { auditType: { $in: inputData.filterByAuditType } } );
|
|
2476
2475
|
}
|
|
2476
|
+
|
|
2477
|
+
if ( inputData.filterByStatus.length > 0 ) {
|
|
2478
|
+
filters.push( { auditStatus: { $in: inputData.filterByStatus } } );
|
|
2479
|
+
}
|
|
2477
2480
|
const query =[
|
|
2478
2481
|
{
|
|
2479
2482
|
$match: {
|
|
@@ -2678,8 +2681,8 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
2678
2681
|
auditInprogress: { $cond: [ { $and: [ { $in: [ '$status', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
|
|
2679
2682
|
reAuditInprogress: { $cond: [ { $and: [ { $in: [ '$status', [ 'inprogress' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
|
|
2680
2683
|
draft: { $cond: [ { $eq: [ '$status', 'drafted' ] }, 1, 0 ] },
|
|
2681
|
-
assigned: { $cond: [ { $eq: [ '$status', '
|
|
2682
|
-
exceptNoAssigned: { $cond:
|
|
2684
|
+
assigned: { $cond: [ { $eq: [ '$status', 'assigned' ] }, 1, 0 ] },
|
|
2685
|
+
exceptNoAssigned: { $cond: { if: { $not: { $in: [ '$status', [ 'skipped', 'not_assign' ] ] } }, then: 1, else: 0 } },
|
|
2683
2686
|
auditCompleted: { $cond: [ { $and: [ { $in: [ '$status', [ 'completed' ] ] }, { $eq: [ '$auditType', 'Audit' ] } ] }, 1, 0 ] },
|
|
2684
2687
|
reAuditCompleted: { $cond: [ { $and: [ { $in: [ '$status', [ 'completed' ] ] }, { $eq: [ '$auditType', 'ReAudit' ] } ] }, 1, 0 ] },
|
|
2685
2688
|
|
|
@@ -2707,7 +2710,6 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
2707
2710
|
reAuditInprogress: 1,
|
|
2708
2711
|
draft: 1,
|
|
2709
2712
|
assigned: 1,
|
|
2710
|
-
exceptNoAssigned1: 1,
|
|
2711
2713
|
exceptNoAssigned: { $subtract: [ temp.auditStores, '$exceptNoAssigned' ] },
|
|
2712
2714
|
auditCompleted: 1,
|
|
2713
2715
|
reAuditCompleted: 1,
|
|
@@ -2730,7 +2732,7 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
2730
2732
|
return res.sendSuccess( { result: temp } );
|
|
2731
2733
|
} catch ( error ) {
|
|
2732
2734
|
const err = error.message || 'Internal Server Error';
|
|
2733
|
-
logger.error( { error: error, message: req.body, function: '
|
|
2735
|
+
logger.error( { error: error, message: req.body, function: 'overAllAuditSummary' } );
|
|
2734
2736
|
return res.sendError( err, 500 );
|
|
2735
2737
|
}
|
|
2736
2738
|
}
|
|
@@ -2878,7 +2880,7 @@ export async function reTrigger( req, res ) {
|
|
|
2878
2880
|
return res.sendSuccess( { result: 'The File has been Re Trigger Succesfully' } );
|
|
2879
2881
|
} catch ( error ) {
|
|
2880
2882
|
const err = error.message;
|
|
2881
|
-
logger.error( { error: error, message: req.body } );
|
|
2883
|
+
logger.error( { error: error, message: req.body, function: 'reTrigger' } );
|
|
2882
2884
|
return res.sendError( err, 500 );
|
|
2883
2885
|
}
|
|
2884
2886
|
}
|
|
@@ -3259,6 +3261,117 @@ export async function overviewTable( req, res ) {
|
|
|
3259
3261
|
}
|
|
3260
3262
|
}
|
|
3261
3263
|
|
|
3264
|
+
export async function totalNotAssignedCount( req, res ) {
|
|
3265
|
+
try {
|
|
3266
|
+
let notAssignedCount = {
|
|
3267
|
+
totalAuditCount: 0,
|
|
3268
|
+
totalZoneCount: 0,
|
|
3269
|
+
totalTrafficCount: 0,
|
|
3270
|
+
};
|
|
3271
|
+
const getStoreData = await findOneStoreData(
|
|
3272
|
+
{},
|
|
3273
|
+
{ fileDate: 1 },
|
|
3274
|
+
{ createdAt: -1 },
|
|
3275
|
+
);
|
|
3276
|
+
const latestDate = getStoreData?.fileDate || dayjs( fileDate ).format( 'DD-MM-YYYY' );
|
|
3277
|
+
const query =[
|
|
3278
|
+
{
|
|
3279
|
+
$match: {
|
|
3280
|
+
fileDate: { $eq: latestDate },
|
|
3281
|
+
},
|
|
3282
|
+
},
|
|
3283
|
+
{
|
|
3284
|
+
$project: {
|
|
3285
|
+
totalZoneCount: { $cond: [
|
|
3286
|
+
{ $eq: [ '$moduleType', 'zone' ] }, 1, 0,
|
|
3287
|
+
] },
|
|
3288
|
+
totalTrafficCount: { $cond: [
|
|
3289
|
+
{ $eq: [ '$moduleType', 'traffic' ] }, 1, 0,
|
|
3290
|
+
] },
|
|
3291
|
+
|
|
3292
|
+
},
|
|
3293
|
+
},
|
|
3294
|
+
{
|
|
3295
|
+
$group: {
|
|
3296
|
+
_id: null,
|
|
3297
|
+
totalAuditCount: { $sum: 1 },
|
|
3298
|
+
totalZoneCount: { $sum: '$totalZoneCount' },
|
|
3299
|
+
totalTrafficCount: { $sum: '$totalTrafficCount' },
|
|
3300
|
+
|
|
3301
|
+
},
|
|
3302
|
+
},
|
|
3303
|
+
{
|
|
3304
|
+
$project: {
|
|
3305
|
+
_id: 0,
|
|
3306
|
+
totalAuditCount: 1,
|
|
3307
|
+
totalZoneCount: 1,
|
|
3308
|
+
totalTrafficCount: 1,
|
|
3309
|
+
},
|
|
3310
|
+
},
|
|
3311
|
+
];
|
|
3312
|
+
const inprogressCount=[
|
|
3313
|
+
{
|
|
3314
|
+
$match: {
|
|
3315
|
+
fileDate: { $eq: latestDate },
|
|
3316
|
+
},
|
|
3317
|
+
},
|
|
3318
|
+
{
|
|
3319
|
+
$project: {
|
|
3320
|
+
inprogressAuditCount: {
|
|
3321
|
+
$cond: [
|
|
3322
|
+
{ $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] }, 1, 0,
|
|
3323
|
+
],
|
|
3324
|
+
},
|
|
3325
|
+
inprogressZoneCount: { $cond: [
|
|
3326
|
+
{ $and: [ { $eq: [ '$moduleType', 'zone' ] }, { $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] } ] }, 1, 0,
|
|
3327
|
+
] },
|
|
3328
|
+
inprogressTrafficCount: { $cond: [
|
|
3329
|
+
{ $and: [ { $eq: [ '$moduleType', 'traffic' ] }, { $in: [ '$status', [ 'completed', 'not_assign', 'skipped' ] ] } ] }, 1, 0,
|
|
3330
|
+
] },
|
|
3331
|
+
|
|
3332
|
+
},
|
|
3333
|
+
},
|
|
3334
|
+
{
|
|
3335
|
+
$group: {
|
|
3336
|
+
_id: null,
|
|
3337
|
+
inprogressAuditCount: { $sum: '$inprogressAuditCount' },
|
|
3338
|
+
inprogressZoneCount: { $sum: '$inprogressZoneCount' },
|
|
3339
|
+
inprogressTrafficCount: { $sum: '$inprogressTrafficCount' },
|
|
3340
|
+
|
|
3341
|
+
},
|
|
3342
|
+
},
|
|
3343
|
+
{
|
|
3344
|
+
$project: {
|
|
3345
|
+
_id: 0,
|
|
3346
|
+
inprogressAuditCount: { $ifNull: [ '$inprogressAuditCount', 0 ] },
|
|
3347
|
+
inprogressZoneCount: { $ifNull: [ '$inprogressZoneCount', 0 ] },
|
|
3348
|
+
inprogressTrafficCount: { $ifNull: [ '$inprogressTrafficCount', 0 ] },
|
|
3349
|
+
},
|
|
3350
|
+
},
|
|
3351
|
+
];
|
|
3352
|
+
const getTotalcount = await aggregateAuditStoreData( query );
|
|
3353
|
+
|
|
3354
|
+
const getInprogressCount = await aggregateStoreAudit( inprogressCount );
|
|
3355
|
+
if ( getTotalcount.length == 0 ) {
|
|
3356
|
+
return res.sendError( 'No Data Found', 204 );
|
|
3357
|
+
}
|
|
3358
|
+
|
|
3359
|
+
if ( getInprogressCount.length >0 ) {
|
|
3360
|
+
notAssignedCount.totalAuditCount = getTotalcount[0].totalAuditCount - getInprogressCount[0]?.inprogressAuditCount;
|
|
3361
|
+
notAssignedCount.totalZoneCount = getTotalcount[0].totalZoneCount - getInprogressCount[0]?.inprogressZoneCount;
|
|
3362
|
+
notAssignedCount.totalTrafficCount = getTotalcount[0].totalTrafficCount - getInprogressCount[0]?.inprogressTrafficCount;
|
|
3363
|
+
} else {
|
|
3364
|
+
notAssignedCount.totalAuditCount = getTotalcount[0].totalAuditCount;
|
|
3365
|
+
notAssignedCount.totalZoneCount = getTotalcount[0].totalZoneCount;
|
|
3366
|
+
notAssignedCount.totalTrafficCount;
|
|
3367
|
+
}
|
|
3368
|
+
return res.sendSuccess( { result: notAssignedCount } );
|
|
3369
|
+
} catch ( error ) {
|
|
3370
|
+
const err = error.message || 'Internal Server Error';
|
|
3371
|
+
logger.info( { error: error, message: req.body, function: 'totalNotAssignedCount' } );
|
|
3372
|
+
return res.sendError( err, 500 );
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3262
3375
|
|
|
3263
3376
|
export async function auditImages( req, res ) {
|
|
3264
3377
|
try {
|
|
@@ -3326,7 +3439,7 @@ export async function auditImages( req, res ) {
|
|
|
3326
3439
|
// return res.sendSuccess( { result: inputData } );
|
|
3327
3440
|
} catch ( error ) {
|
|
3328
3441
|
const err = error.message || 'Internal Server Error';
|
|
3329
|
-
logger.info( { error: error, message: req.body, function: '
|
|
3442
|
+
logger.info( { error: error, message: req.body, function: 'auditImages' } );
|
|
3330
3443
|
return res.sendError( err, 500 );
|
|
3331
3444
|
}
|
|
3332
3445
|
}
|
package/src/docs/audit.docs.js
CHANGED
|
@@ -524,4 +524,18 @@ export const auditDocs = {
|
|
|
524
524
|
|
|
525
525
|
},
|
|
526
526
|
},
|
|
527
|
+
'/v3/audit/total-not-assigned-count': {
|
|
528
|
+
get: {
|
|
529
|
+
tags: [ 'Audit Mapping' ],
|
|
530
|
+
description: 'Get total Not Assigned Count',
|
|
531
|
+
operationId: 'clients',
|
|
532
|
+
responses: {
|
|
533
|
+
200: { description: 'Successful' },
|
|
534
|
+
401: { description: 'Unauthorized User' },
|
|
535
|
+
422: { description: 'Field Error' },
|
|
536
|
+
500: { description: 'Server Error' },
|
|
537
|
+
204: { description: 'Not Found' },
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
},
|
|
527
541
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { isAuditDocumentExist, isAuditInputFolderExist, isExistsQueue, validateUserAudit } from '../validation/audit.validation.js';
|
|
3
3
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
4
|
-
import { auditImages, auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard, overviewTable, pendingSummaryTable, reTrigger, save, saveDraft, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace } from '../controllers/audit.controllers.js';
|
|
4
|
+
import { auditImages, auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard, overviewTable, pendingSummaryTable, reTrigger, save, saveDraft, storeMetrics, summarySplit, totalNotAssignedCount, userAuditHistory, userMetrics, workSpace } from '../controllers/audit.controllers.js';
|
|
5
5
|
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid, pendingSummaryTableValid, reTriggerValid, saveDraftValid, saveValid, storeMetricsValid, summarySplitValid, userAuditHistoryValid, userMetricsValid, workSpaceValid, auditImageValid, overviewTableValid } from '../dtos/audit.dtos.js';
|
|
6
6
|
|
|
7
7
|
export const auditRouter = express.Router();
|
|
@@ -33,4 +33,6 @@ auditRouter.post( '/metrics/overview-card', isAllowedSessionHandler, validate( o
|
|
|
33
33
|
auditRouter.post( '/metrics/summary-split-up', isAllowedSessionHandler, validate( summarySplitValid ), summarySplit );
|
|
34
34
|
auditRouter.post( '/metrics/overview-table', isAllowedSessionHandler, validate( overviewTableValid ), overviewTable );
|
|
35
35
|
|
|
36
|
+
// ticket
|
|
37
|
+
auditRouter.get( '/total-not-assigned-count', isAllowedSessionHandler, totalNotAssignedCount );
|
|
36
38
|
export default auditRouter;
|