tango-app-api-audit 3.4.3-alpha.1 → 3.4.3-alpha.2
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 +1 -1
- package/src/controllers/audit.controllers.js +29 -0
- package/src/controllers/traxAudit.controllers.js +25 -23
- package/src/docs/traxAudit.docs.js +1 -1
- package/src/dtos/traxAudit.dtos.js +1 -1
- package/src/routes/audit.routes.js +4 -1
- package/src/routes/traxAudit.routes.js +1 -2
package/package.json
CHANGED
|
@@ -4302,3 +4302,32 @@ export async function getUserAuditCountMTD( req, res ) {
|
|
|
4302
4302
|
}
|
|
4303
4303
|
}
|
|
4304
4304
|
|
|
4305
|
+
export async function auditViewLogs( req, res ) {
|
|
4306
|
+
try {
|
|
4307
|
+
const parsedOpenSearch = JSON.parse( process.env.OPENSEARCH );
|
|
4308
|
+
let downTimeQuery = {
|
|
4309
|
+
'size': 100,
|
|
4310
|
+
'query': {
|
|
4311
|
+
'bool': {
|
|
4312
|
+
'must': [
|
|
4313
|
+
{
|
|
4314
|
+
'term': {
|
|
4315
|
+
'doc.date.keyword': dayjs( inputQuery.filedate ).format( 'DD-MM-YYYY' ),
|
|
4316
|
+
},
|
|
4317
|
+
},
|
|
4318
|
+
{
|
|
4319
|
+
'term': {
|
|
4320
|
+
'doc.store_id.keyword': inputQuery.storeId,
|
|
4321
|
+
},
|
|
4322
|
+
},
|
|
4323
|
+
],
|
|
4324
|
+
|
|
4325
|
+
},
|
|
4326
|
+
},
|
|
4327
|
+
};
|
|
4328
|
+
const downtime = await getOpenSearchData( parsedOpenSearch.activityLog, downTimeQuery );
|
|
4329
|
+
return res.sendSuccess( downtime );
|
|
4330
|
+
} catch ( err ) {
|
|
4331
|
+
|
|
4332
|
+
}
|
|
4333
|
+
}
|
|
@@ -7,12 +7,15 @@ import { aggregateTraxAuditData, findOneTraxAuditData } from '../service/traxAud
|
|
|
7
7
|
import { aggregateClient } from '../service/client.service.js';
|
|
8
8
|
import dayjs from 'dayjs';
|
|
9
9
|
import { aggregateAssignAudit } from '../service/assignAudit.service.js';
|
|
10
|
-
import { aggregateStoreEmpDetection, updateManyStoreEmpDetection } from '../service/storeEmpDetection.service.js';
|
|
10
|
+
import { aggregateStoreEmpDetection, updateManyStoreEmpDetection, updateOneStoreEmpDetection } from '../service/storeEmpDetection.service.js';
|
|
11
11
|
import { listQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
|
|
12
12
|
import _ from 'lodash';
|
|
13
13
|
import mongoose from 'mongoose';
|
|
14
|
-
import { findOneAuditLog
|
|
15
|
-
|
|
14
|
+
import { findOneAuditLog, createAuditLog,
|
|
15
|
+
} from '../service/auditLog.service.js';
|
|
16
|
+
import {
|
|
17
|
+
findOneUserEmpDetection,
|
|
18
|
+
} from '../service/userEmpDetection.service.js';
|
|
16
19
|
|
|
17
20
|
// export async function getDetectionAuditFile( req, res ) {
|
|
18
21
|
// try {
|
|
@@ -742,7 +745,7 @@ export async function workSpace( req, res ) {
|
|
|
742
745
|
},
|
|
743
746
|
];
|
|
744
747
|
|
|
745
|
-
logger.info( { moduleType: inputData.moduleType, key:
|
|
748
|
+
logger.info( { moduleType: inputData.moduleType, key: [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType ), dateStart: new Date( dayjs( fileDate ).format( 'YYYY-MM-DD' ) ), end: dateRange.end, user: req.user._id, client: clientList } );
|
|
746
749
|
|
|
747
750
|
const userAsignAudit = [
|
|
748
751
|
{
|
|
@@ -796,11 +799,11 @@ export async function workSpace( req, res ) {
|
|
|
796
799
|
},
|
|
797
800
|
];
|
|
798
801
|
|
|
799
|
-
const auditUserCount =
|
|
800
|
-
const userIncompleteFilesCount =
|
|
802
|
+
const auditUserCount = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( auditFiles ) : await aggregateBinaryAudit( auditFiles );
|
|
803
|
+
const userIncompleteFilesCount = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( userIncompleteFiles ) : await aggregateBinaryAudit( userIncompleteFiles );
|
|
801
804
|
logger.info( { moduleType: inputData.moduleType, userIncompleteFiles: userIncompleteFilesCount } );
|
|
802
805
|
const userAsignAuditCount = await aggregateAssignAudit( userAsignAudit );
|
|
803
|
-
const completedStoresCount =
|
|
806
|
+
const completedStoresCount = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( completedStores ) : await aggregateBinaryAudit( binarCompletedStores );
|
|
804
807
|
const clientAssignedCount = await aggregateAssignAudit( clientAssign );
|
|
805
808
|
const auditStoreData = await aggregateTraxAuditData(
|
|
806
809
|
auditStoreDataQuery,
|
|
@@ -1697,7 +1700,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1697
1700
|
},
|
|
1698
1701
|
);
|
|
1699
1702
|
}
|
|
1700
|
-
const count =
|
|
1703
|
+
const count = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
1701
1704
|
if ( count.length == 0 ) {
|
|
1702
1705
|
return res.sendError( 'No Data Found', 204 );
|
|
1703
1706
|
}
|
|
@@ -1767,7 +1770,7 @@ export async function userAuditHistory( req, res ) {
|
|
|
1767
1770
|
{
|
|
1768
1771
|
$limit: limit,
|
|
1769
1772
|
} );
|
|
1770
|
-
const result =
|
|
1773
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
1771
1774
|
|
|
1772
1775
|
return res.sendSuccess( { result: result, count: count.length } );
|
|
1773
1776
|
} catch ( error ) {
|
|
@@ -2426,7 +2429,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2426
2429
|
},
|
|
2427
2430
|
);
|
|
2428
2431
|
}
|
|
2429
|
-
const count =
|
|
2432
|
+
const count = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( binaryQuery );
|
|
2430
2433
|
|
|
2431
2434
|
if ( count.length == 0 ) {
|
|
2432
2435
|
return res.sendError( 'No data Found', 204 );
|
|
@@ -2441,7 +2444,7 @@ export async function storeMetrics( req, res ) {
|
|
|
2441
2444
|
} else {
|
|
2442
2445
|
query.push( { $limit: 10000 } );
|
|
2443
2446
|
}
|
|
2444
|
-
const result =
|
|
2447
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2445
2448
|
if ( inputData.isExport ) {
|
|
2446
2449
|
const exportdata = [];
|
|
2447
2450
|
result.forEach( ( element ) => {
|
|
@@ -2744,7 +2747,7 @@ export async function userMetrics( req, res ) {
|
|
|
2744
2747
|
);
|
|
2745
2748
|
}
|
|
2746
2749
|
|
|
2747
|
-
const count =
|
|
2750
|
+
const count = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2748
2751
|
if ( count.length == 0 ) {
|
|
2749
2752
|
return res.sendError( 'No Data Found', 204 );
|
|
2750
2753
|
}
|
|
@@ -2778,7 +2781,7 @@ export async function userMetrics( req, res ) {
|
|
|
2778
2781
|
'Product Type': '$value',
|
|
2779
2782
|
// 'Mapping Percentage': '$mappingPerc',
|
|
2780
2783
|
};
|
|
2781
|
-
|
|
2784
|
+
[ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?
|
|
2782
2785
|
query.push(
|
|
2783
2786
|
{
|
|
2784
2787
|
$project: detection,
|
|
@@ -2792,7 +2795,7 @@ export async function userMetrics( req, res ) {
|
|
|
2792
2795
|
}
|
|
2793
2796
|
|
|
2794
2797
|
|
|
2795
|
-
const result =
|
|
2798
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2796
2799
|
if ( inputData.isExport ) {
|
|
2797
2800
|
await download( result, res );
|
|
2798
2801
|
return;
|
|
@@ -2936,7 +2939,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2936
2939
|
},
|
|
2937
2940
|
);
|
|
2938
2941
|
}
|
|
2939
|
-
const count =
|
|
2942
|
+
const count = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2940
2943
|
if ( count.length == 0 ) {
|
|
2941
2944
|
return res.sendError( 'No Data Found', 204 );
|
|
2942
2945
|
}
|
|
@@ -2952,7 +2955,7 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
2952
2955
|
} );
|
|
2953
2956
|
}
|
|
2954
2957
|
|
|
2955
|
-
const result =
|
|
2958
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
2956
2959
|
if ( inputData.isExport ) {
|
|
2957
2960
|
const exportdata = [];
|
|
2958
2961
|
result.forEach( ( element ) => {
|
|
@@ -3146,7 +3149,7 @@ export async function overAllAuditSummary( req, res ) {
|
|
|
3146
3149
|
},
|
|
3147
3150
|
];
|
|
3148
3151
|
|
|
3149
|
-
const storeAudit =
|
|
3152
|
+
const storeAudit = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )?await aggregateStoreEmpDetection( storeAuditQuery ) : await aggregateBinaryAudit( binaryAuditQuery );
|
|
3150
3153
|
if ( storeAudit.length > 0 ) {
|
|
3151
3154
|
temp.inprogressStores= storeAudit[0].inprogressStores;
|
|
3152
3155
|
temp.completedStores = storeAudit[0].completedStores;
|
|
@@ -3277,7 +3280,7 @@ export async function summarySplit( req, res ) {
|
|
|
3277
3280
|
},
|
|
3278
3281
|
},
|
|
3279
3282
|
];
|
|
3280
|
-
const result =
|
|
3283
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateUserEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3281
3284
|
const totalCount = await aggregateTraxAuditData( totalQuery );
|
|
3282
3285
|
result[0].totalCount = totalCount[0]?.total;
|
|
3283
3286
|
return res.sendSuccess( { result: result.length> 0? result[0]: temp } );
|
|
@@ -3424,7 +3427,7 @@ export async function overviewTable( req, res ) {
|
|
|
3424
3427
|
},
|
|
3425
3428
|
);
|
|
3426
3429
|
}
|
|
3427
|
-
const count =
|
|
3430
|
+
const count = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3428
3431
|
if ( count.length == 0 ) {
|
|
3429
3432
|
return res.sendError( 'No Data Found', 204 );
|
|
3430
3433
|
}
|
|
@@ -3439,7 +3442,7 @@ export async function overviewTable( req, res ) {
|
|
|
3439
3442
|
$limit: limit,
|
|
3440
3443
|
} );
|
|
3441
3444
|
}
|
|
3442
|
-
const result =
|
|
3445
|
+
const result = [ 'uniform-detection', 'mobile-detection' ].includes( inputData.moduleType )? await aggregateStoreEmpDetection( query ) : await aggregateBinaryAudit( query );
|
|
3443
3446
|
if ( inputData.isExport ) {
|
|
3444
3447
|
const exportdata = [];
|
|
3445
3448
|
result.forEach( ( element ) => {
|
|
@@ -3945,7 +3948,7 @@ export async function saveDraft( req, res ) {
|
|
|
3945
3948
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
3946
3949
|
const inputData = req.body;
|
|
3947
3950
|
inputData.userId = req.user._id;
|
|
3948
|
-
const getUserAuditData = await
|
|
3951
|
+
const getUserAuditData = await findOneUserEmpDetection( { _id: inputData.auditId } );
|
|
3949
3952
|
if ( !getUserAuditData ) {
|
|
3950
3953
|
return res.sendError( 'No Data Found', 204 );
|
|
3951
3954
|
}
|
|
@@ -3963,7 +3966,6 @@ export async function saveDraft( req, res ) {
|
|
|
3963
3966
|
const storeQuery = {
|
|
3964
3967
|
storeId: inputData.storeId,
|
|
3965
3968
|
fileDate: inputData.fileDate,
|
|
3966
|
-
zoneName: inputData.zoneName,
|
|
3967
3969
|
};
|
|
3968
3970
|
|
|
3969
3971
|
let storeRecord = {
|
|
@@ -4004,7 +4006,7 @@ export async function saveDraft( req, res ) {
|
|
|
4004
4006
|
}
|
|
4005
4007
|
await createAuditLog( inputData );
|
|
4006
4008
|
await updateOneUserEmpDetection( userQuery, userRecord );
|
|
4007
|
-
await
|
|
4009
|
+
await updateOneStoreEmpDetection( storeQuery, storeRecord );
|
|
4008
4010
|
return res.sendSuccess( {
|
|
4009
4011
|
result: 'The file has been drafted successfully',
|
|
4010
4012
|
} );
|
|
@@ -45,7 +45,7 @@ export const saveDraftSchema = joi.object(
|
|
|
45
45
|
storeId: joi.string().required(),
|
|
46
46
|
auditId: joi.string().required(),
|
|
47
47
|
moduleType: joi.string().required(),
|
|
48
|
-
zoneName: joi.string().required(),
|
|
48
|
+
// zoneName: joi.string().required(),
|
|
49
49
|
auditType: joi.string().required(),
|
|
50
50
|
fileDate: joi.string().required(),
|
|
51
51
|
queueName: joi.string().required(),
|
|
@@ -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, totalNotAssignedCount, userAuditHistory, userMetrics, workSpace, getUserAuditCount, getUserAuditCountMTD } 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, getUserAuditCount, getUserAuditCountMTD, auditViewLogs } 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();
|
|
@@ -39,4 +39,7 @@ auditRouter.get( '/total-not-assigned-count', isAllowedSessionHandler, totalNotA
|
|
|
39
39
|
// audit user wallet
|
|
40
40
|
auditRouter.get( '/get-user-audit-count', isAllowedSessionHandler, getUserAuditCount );
|
|
41
41
|
auditRouter.get( '/get-user-audit-count-mtd', isAllowedSessionHandler, getUserAuditCountMTD );
|
|
42
|
+
|
|
43
|
+
// audit log
|
|
44
|
+
auditRouter.get( '/audit-viewLogs', auditViewLogs );
|
|
42
45
|
export default auditRouter;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
3
|
-
import { getDetectionFileValid, getFileValid, userAuditHistoryValid, workSpaceValid, saveValid, clientMetricsValid, storeMetricsValid, userMetricsValid, pendingSummaryTableValid, overAllAuditSummaryValid, summarySplitValid, overviewTableValid, getUpdatedFileValid, saveBinaryValid, getDraftedDataValid } from '../dtos/traxAudit.dtos.js';
|
|
3
|
+
import { getDetectionFileValid, getFileValid, userAuditHistoryValid, workSpaceValid, saveValid, clientMetricsValid, storeMetricsValid, userMetricsValid, pendingSummaryTableValid, overAllAuditSummaryValid, summarySplitValid, overviewTableValid, getUpdatedFileValid, saveBinaryValid, getDraftedDataValid, saveDraftValid } from '../dtos/traxAudit.dtos.js';
|
|
4
4
|
import { isExistsQueue } from '../validation/audit.validation.js';
|
|
5
5
|
import { clientMetrics, getAuditFile, getDetectionAuditFile, getUpdatedFile, overAllAuditSummary, overviewTable, pendingSummaryTable, saveBinary, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace, saveDraft, getDraftedData, save } from '../controllers/traxAudit.controllers.js';
|
|
6
6
|
import { isTraxAuditDocumentExist, validateBinaryAudit } from '../validation/traxAuditValidation.js';
|
|
7
|
-
import { saveDraftValid } from '../dtos/audit.dtos.js';
|
|
8
7
|
|
|
9
8
|
export const traxAuditRouter = Router();
|
|
10
9
|
|