tango-app-api-audit 3.3.0-alpha.14 → 3.3.0-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.3.0-alpha.
|
|
3
|
+
"version": "3.3.0-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.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
|
}
|
|
@@ -2730,7 +2729,7 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
2730
2729
|
return res.sendSuccess( { result: temp } );
|
|
2731
2730
|
} catch ( error ) {
|
|
2732
2731
|
const err = error.message || 'Internal Server Error';
|
|
2733
|
-
logger.error( { error: error, message: req.body, function: '
|
|
2732
|
+
logger.error( { error: error, message: req.body, function: 'overAllAuditSummary' } );
|
|
2734
2733
|
return res.sendError( err, 500 );
|
|
2735
2734
|
}
|
|
2736
2735
|
}
|
|
@@ -2878,7 +2877,7 @@ export async function reTrigger( req, res ) {
|
|
|
2878
2877
|
return res.sendSuccess( { result: 'The File has been Re Trigger Succesfully' } );
|
|
2879
2878
|
} catch ( error ) {
|
|
2880
2879
|
const err = error.message;
|
|
2881
|
-
logger.error( { error: error, message: req.body } );
|
|
2880
|
+
logger.error( { error: error, message: req.body, function: 'reTrigger' } );
|
|
2882
2881
|
return res.sendError( err, 500 );
|
|
2883
2882
|
}
|
|
2884
2883
|
}
|
|
@@ -3259,6 +3258,117 @@ export async function overviewTable( req, res ) {
|
|
|
3259
3258
|
}
|
|
3260
3259
|
}
|
|
3261
3260
|
|
|
3261
|
+
export async function totalNotAssignedCount( req, res ) {
|
|
3262
|
+
try {
|
|
3263
|
+
let notAssignedCount = {
|
|
3264
|
+
totalAuditCount: 0,
|
|
3265
|
+
totalZoneCount: 0,
|
|
3266
|
+
totalTrafficCount: 0,
|
|
3267
|
+
};
|
|
3268
|
+
const getStoreData = await findOneStoreData(
|
|
3269
|
+
{},
|
|
3270
|
+
{ fileDate: 1 },
|
|
3271
|
+
{ createdAt: -1 },
|
|
3272
|
+
);
|
|
3273
|
+
const latestDate = getStoreData?.fileDate || dayjs( fileDate ).format( 'DD-MM-YYYY' );
|
|
3274
|
+
const query =[
|
|
3275
|
+
{
|
|
3276
|
+
$match: {
|
|
3277
|
+
fileDate: { $eq: latestDate },
|
|
3278
|
+
},
|
|
3279
|
+
},
|
|
3280
|
+
{
|
|
3281
|
+
$project: {
|
|
3282
|
+
totalZoneCount: { $cond: [
|
|
3283
|
+
{ $eq: [ '$moduleType', 'zone' ] }, 1, 0,
|
|
3284
|
+
] },
|
|
3285
|
+
totalTrafficCount: { $cond: [
|
|
3286
|
+
{ $eq: [ '$moduleType', 'traffic' ] }, 1, 0,
|
|
3287
|
+
] },
|
|
3288
|
+
|
|
3289
|
+
},
|
|
3290
|
+
},
|
|
3291
|
+
{
|
|
3292
|
+
$group: {
|
|
3293
|
+
_id: null,
|
|
3294
|
+
totalAuditCount: { $sum: 1 },
|
|
3295
|
+
totalZoneCount: { $sum: '$totalZoneCount' },
|
|
3296
|
+
totalTrafficCount: { $sum: '$totalTrafficCount' },
|
|
3297
|
+
|
|
3298
|
+
},
|
|
3299
|
+
},
|
|
3300
|
+
{
|
|
3301
|
+
$project: {
|
|
3302
|
+
_id: 0,
|
|
3303
|
+
totalAuditCount: 1,
|
|
3304
|
+
totalZoneCount: 1,
|
|
3305
|
+
totalTrafficCount: 1,
|
|
3306
|
+
},
|
|
3307
|
+
},
|
|
3308
|
+
];
|
|
3309
|
+
const inprogressCount=[
|
|
3310
|
+
{
|
|
3311
|
+
$match: {
|
|
3312
|
+
fileDate: { $eq: latestDate },
|
|
3313
|
+
},
|
|
3314
|
+
},
|
|
3315
|
+
{
|
|
3316
|
+
$project: {
|
|
3317
|
+
inprogressAuditCount: {
|
|
3318
|
+
$cond: [
|
|
3319
|
+
{ $in: [ '$status', [ 'completed', 'not_assign' ] ] }, 1, 0,
|
|
3320
|
+
],
|
|
3321
|
+
},
|
|
3322
|
+
inprogressZoneCount: { $cond: [
|
|
3323
|
+
{ $and: [ { $eq: [ '$moduleType', 'zone' ] }, { $in: [ '$status', [ 'completed', 'not_assign' ] ] } ] }, 1, 0,
|
|
3324
|
+
] },
|
|
3325
|
+
inprogressTrafficCount: { $cond: [
|
|
3326
|
+
{ $and: [ { $eq: [ '$moduleType', 'traffic' ] }, { $in: [ '$status', [ 'completed', 'not_assign' ] ] } ] }, 1, 0,
|
|
3327
|
+
] },
|
|
3328
|
+
|
|
3329
|
+
},
|
|
3330
|
+
},
|
|
3331
|
+
{
|
|
3332
|
+
$group: {
|
|
3333
|
+
_id: null,
|
|
3334
|
+
inprogressAuditCount: { $sum: '$inprogressAuditCount' },
|
|
3335
|
+
inprogressZoneCount: { $sum: '$inprogressZoneCount' },
|
|
3336
|
+
inprogressTrafficCount: { $sum: '$inprogressTrafficCount' },
|
|
3337
|
+
|
|
3338
|
+
},
|
|
3339
|
+
},
|
|
3340
|
+
{
|
|
3341
|
+
$project: {
|
|
3342
|
+
_id: 0,
|
|
3343
|
+
inprogressAuditCount: { $ifNull: [ '$inprogressAuditCount', 0 ] },
|
|
3344
|
+
inprogressZoneCount: { $ifNull: [ '$inprogressZoneCount', 0 ] },
|
|
3345
|
+
inprogressTrafficCount: { $ifNull: [ '$inprogressTrafficCount', 0 ] },
|
|
3346
|
+
},
|
|
3347
|
+
},
|
|
3348
|
+
];
|
|
3349
|
+
const getTotalcount = await aggregateAuditStoreData( query );
|
|
3350
|
+
|
|
3351
|
+
const getInprogressCount = await aggregateStoreAudit( inprogressCount );
|
|
3352
|
+
if ( getTotalcount.length == 0 ) {
|
|
3353
|
+
return res.sendError( 'No Data Found', 204 );
|
|
3354
|
+
}
|
|
3355
|
+
|
|
3356
|
+
if ( getInprogressCount.length >0 ) {
|
|
3357
|
+
notAssignedCount.totalAuditCount = getTotalcount[0].totalAuditCount - getInprogressCount[0]?.inprogressAuditCount;
|
|
3358
|
+
notAssignedCount.totalZoneCount = getTotalcount[0].totalZoneCount - getInprogressCount[0]?.inprogressZoneCount;
|
|
3359
|
+
notAssignedCount.totalTrafficCount = getTotalcount[0].totalTrafficCount - getInprogressCount[0]?.inprogressTrafficCount;
|
|
3360
|
+
} else {
|
|
3361
|
+
notAssignedCount.totalAuditCount = getTotalcount[0].totalAuditCount;
|
|
3362
|
+
notAssignedCount.totalZoneCount = getTotalcount[0].totalZoneCount;
|
|
3363
|
+
notAssignedCount.totalTrafficCount;
|
|
3364
|
+
}
|
|
3365
|
+
return res.sendSuccess( { result: notAssignedCount } );
|
|
3366
|
+
} catch ( error ) {
|
|
3367
|
+
const err = error.message || 'Internal Server Error';
|
|
3368
|
+
logger.info( { error: error, message: req.body, function: 'totalNotAssignedCount' } );
|
|
3369
|
+
return res.sendError( err, 500 );
|
|
3370
|
+
}
|
|
3371
|
+
}
|
|
3262
3372
|
|
|
3263
3373
|
export async function auditImages( req, res ) {
|
|
3264
3374
|
try {
|
|
@@ -3326,7 +3436,7 @@ export async function auditImages( req, res ) {
|
|
|
3326
3436
|
// return res.sendSuccess( { result: inputData } );
|
|
3327
3437
|
} catch ( error ) {
|
|
3328
3438
|
const err = error.message || 'Internal Server Error';
|
|
3329
|
-
logger.info( { error: error, message: req.body, function: '
|
|
3439
|
+
logger.info( { error: error, message: req.body, function: 'auditImages' } );
|
|
3330
3440
|
return res.sendError( err, 500 );
|
|
3331
3441
|
}
|
|
3332
3442
|
}
|
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;
|