tango-app-api-audit 3.5.53 → 3.5.55
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 +95 -0
- package/src/controllers/eyeTestAudit.controllers.js +0 -2
- package/src/docs/audit.docs.js +27 -2
- package/src/dtos/audit.dtos.js +11 -0
- package/src/routes/audit.routes.js +6 -3
- package/src/validation/audit.validation.js +37 -1
package/package.json
CHANGED
|
@@ -5405,3 +5405,98 @@ export async function convertTimestampToDateTime( timestamp ) {
|
|
|
5405
5405
|
const seconds = ( '0' + adjustedDate.getSeconds() ).slice( -2 );
|
|
5406
5406
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
5407
5407
|
}
|
|
5408
|
+
|
|
5409
|
+
export async function rePushAuditStores( req, res ) {
|
|
5410
|
+
try {
|
|
5411
|
+
const inputData = req.body;
|
|
5412
|
+
const sqs = JSON.parse( process.env.SQS );
|
|
5413
|
+
const getStoreAuditQuery = [
|
|
5414
|
+
{
|
|
5415
|
+
$match: {
|
|
5416
|
+
$and: [
|
|
5417
|
+
{
|
|
5418
|
+
clientId: { $eq: inputData.clientId },
|
|
5419
|
+
},
|
|
5420
|
+
{
|
|
5421
|
+
fileDate: { $eq: inputData.fileDate },
|
|
5422
|
+
},
|
|
5423
|
+
{
|
|
5424
|
+
moduleType: { $eq: 'traffic' },
|
|
5425
|
+
},
|
|
5426
|
+
],
|
|
5427
|
+
},
|
|
5428
|
+
},
|
|
5429
|
+
{
|
|
5430
|
+
$group: {
|
|
5431
|
+
_id: null,
|
|
5432
|
+
storeList: { $addToSet: '$storeId' },
|
|
5433
|
+
},
|
|
5434
|
+
},
|
|
5435
|
+
{
|
|
5436
|
+
$project: {
|
|
5437
|
+
storeList: 1,
|
|
5438
|
+
_id: 0,
|
|
5439
|
+
},
|
|
5440
|
+
},
|
|
5441
|
+
];
|
|
5442
|
+
const getStoreAudit = await aggregateStoreAudit( getStoreAuditQuery );
|
|
5443
|
+
logger.info( { getStoreAudit: getStoreAudit } );
|
|
5444
|
+
let filter = [
|
|
5445
|
+
{
|
|
5446
|
+
fileDate: { $eq: inputData?.fileDate },
|
|
5447
|
+
},
|
|
5448
|
+
{
|
|
5449
|
+
clientId: { $eq: inputData?.clientId },
|
|
5450
|
+
},
|
|
5451
|
+
{
|
|
5452
|
+
moduleType: { $eq: 'traffic' },
|
|
5453
|
+
},
|
|
5454
|
+
];
|
|
5455
|
+
if ( getStoreAudit && getStoreAudit?.length > 0 && getStoreAudit?.[0]?.storeList?.length > 0 ) {
|
|
5456
|
+
filter.push( {
|
|
5457
|
+
storeId: { $nin: getStoreAudit?.[0]?.storeList },
|
|
5458
|
+
} );
|
|
5459
|
+
}
|
|
5460
|
+
|
|
5461
|
+
const getStoreDataQuery = [
|
|
5462
|
+
{
|
|
5463
|
+
$match: {
|
|
5464
|
+
$and: filter,
|
|
5465
|
+
},
|
|
5466
|
+
|
|
5467
|
+
},
|
|
5468
|
+
{
|
|
5469
|
+
$project: {
|
|
5470
|
+
message: '$sqs.Body',
|
|
5471
|
+
queueName: 1,
|
|
5472
|
+
},
|
|
5473
|
+
},
|
|
5474
|
+
];
|
|
5475
|
+
const getStoreData = await aggregateAuditStoreData( getStoreDataQuery );
|
|
5476
|
+
const temp =[];
|
|
5477
|
+
logger.info( { getStoreDataQuery: getStoreDataQuery, getStoreData: getStoreData } );
|
|
5478
|
+
if ( getStoreData &&getStoreData.length>0 ) {
|
|
5479
|
+
for ( const item of getStoreData ) {
|
|
5480
|
+
const sqsProduceQueue = {
|
|
5481
|
+
QueueUrl: `${sqs.url}${item.queueName}`,
|
|
5482
|
+
MessageBody: JSON.stringify( item.message ),
|
|
5483
|
+
};
|
|
5484
|
+
logger.info( { item: item } );
|
|
5485
|
+
const sqsQueue = await sendMessageToQueue(
|
|
5486
|
+
sqsProduceQueue.QueueUrl,
|
|
5487
|
+
sqsProduceQueue.MessageBody );
|
|
5488
|
+
if ( !sqsQueue.statusCode ) {
|
|
5489
|
+
logger.info( { sqsQueue: sqsQueue } );
|
|
5490
|
+
temp.push( item?.message?.store_id );
|
|
5491
|
+
}
|
|
5492
|
+
}
|
|
5493
|
+
return res.sendSuccess( { result: `these store are pushed to queue ${temp?.toString()}` } );
|
|
5494
|
+
} else {
|
|
5495
|
+
return res.sendError( 'No messages are pending', 403 );
|
|
5496
|
+
}
|
|
5497
|
+
} catch ( error ) {
|
|
5498
|
+
const err = error.message || 'Internal Server Error';
|
|
5499
|
+
logger.error( { error: error, message: req.query, function: 'rePushAuditStores-audit-.controller' } );
|
|
5500
|
+
return res.sendError( err, 500 );
|
|
5501
|
+
}
|
|
5502
|
+
}
|
|
@@ -1880,8 +1880,6 @@ export async function summaryList( req, res ) {
|
|
|
1880
1880
|
'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
|
|
1881
1881
|
'Trust Score': element?._source?.trustScore == null || element?._source?.trustScore ==undefined ? 'NA' : `${element?._source?.trustScore} %`,
|
|
1882
1882
|
'Test Duration': duration || '',
|
|
1883
|
-
'Eye Test Status': element._source?.comment,
|
|
1884
|
-
'Comments ': element._source?.subComment || '',
|
|
1885
1883
|
'Audit Status': element?._source?.auditStatus || '',
|
|
1886
1884
|
'Audited By': userName?.userName || '',
|
|
1887
1885
|
|
package/src/docs/audit.docs.js
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import { auditStoreSchema, clientMetricsSchema, clientSchema, getDraftedDataSchema, getFileSchema, overAllAuditSummarySchema, overViewCardSchema, reTriggerValidSchema, saveDraftSchema, saveSchema, storeMetricsSchema, summarySplitSchema, userAuditHistorySchema, userMetricsSchema, userSchema, workSpaceSchema, auditImageValidSchema, pendingSummaryTableSchema, overviewTableSchema, auditViewlogSchema } from '../dtos/audit.dtos.js';
|
|
1
|
+
import { auditStoreSchema, clientMetricsSchema, clientSchema, getDraftedDataSchema, getFileSchema, overAllAuditSummarySchema, overViewCardSchema, reTriggerValidSchema, saveDraftSchema, saveSchema, storeMetricsSchema, summarySplitSchema, userAuditHistorySchema, userMetricsSchema, userSchema, workSpaceSchema, auditImageValidSchema, pendingSummaryTableSchema, overviewTableSchema, auditViewlogSchema, rePushAuditStoresSchema } from '../dtos/audit.dtos.js';
|
|
2
2
|
import j2s from 'joi-to-swagger';
|
|
3
3
|
|
|
4
4
|
export const auditDocs = {
|
|
5
|
+
/** internal api */
|
|
6
|
+
'/v3/audit/re-push-audit-stores': {
|
|
7
|
+
post: {
|
|
8
|
+
tags: [ 'Internal API' ],
|
|
9
|
+
description: `re-push the files which is missing any one of the layer`,
|
|
10
|
+
operationId: 're-push-audit-stores',
|
|
11
|
+
parameters: {},
|
|
12
|
+
requestBody: {
|
|
13
|
+
content: {
|
|
14
|
+
'application/json': {
|
|
15
|
+
schema: j2s( rePushAuditStoresSchema ).swagger,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
responses: {
|
|
20
|
+
200: { description: 'Successful' },
|
|
21
|
+
401: { description: 'Unauthorized User' },
|
|
22
|
+
422: { description: 'Field Error' },
|
|
23
|
+
500: { description: 'Server Error' },
|
|
24
|
+
204: { description: 'Not Found' },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
5
28
|
|
|
6
29
|
|
|
7
30
|
/* < -- *** Configuration *** --> */
|
|
@@ -41,7 +64,7 @@ export const auditDocs = {
|
|
|
41
64
|
'/v3/audit/audit-stores': {
|
|
42
65
|
post: {
|
|
43
66
|
tags: [ 'Audit Stores' ],
|
|
44
|
-
description: `
|
|
67
|
+
description: `Get list of stores`,
|
|
45
68
|
operationId: 'audit-stores',
|
|
46
69
|
parameters: {},
|
|
47
70
|
requestBody: {
|
|
@@ -627,4 +650,6 @@ export const auditDocs = {
|
|
|
627
650
|
},
|
|
628
651
|
},
|
|
629
652
|
},
|
|
653
|
+
|
|
654
|
+
|
|
630
655
|
};
|
package/src/dtos/audit.dtos.js
CHANGED
|
@@ -310,3 +310,14 @@ export const auditImageValidSchema = joi.object( {
|
|
|
310
310
|
export const auditImageValid = {
|
|
311
311
|
query: auditImageValidSchema,
|
|
312
312
|
};
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
export const rePushAuditStoresSchema = joi.object( {
|
|
316
|
+
fileDate: joi.string().required(),
|
|
317
|
+
clientId: joi.string().required(),
|
|
318
|
+
moduleType: joi.string().required().allow( 'traffic', 'track', 'zone' ),
|
|
319
|
+
} );
|
|
320
|
+
|
|
321
|
+
export const rePushAuditStoresValid = {
|
|
322
|
+
body: rePushAuditStoresSchema,
|
|
323
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import { isAuditDocumentExist, isAuditInputFolderExist, isAuditUser, isExistsQueue, validateUserAudit } from '../validation/audit.validation.js';
|
|
2
|
+
import { isAuditDocumentExist, isAuditInputFolderExist, isAuditUser, isExistsQueue, validateUserAudit, validation } from '../validation/audit.validation.js';
|
|
3
3
|
import { accessVerification, 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, auditViewLogs, getUserCredit } from '../controllers/audit.controllers.js';
|
|
5
|
-
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid, pendingSummaryTableValid, reTriggerValid, saveDraftValid, saveValid, storeMetricsValid, summarySplitValid, userAuditHistoryValid, userMetricsValid, workSpaceValid, auditImageValid, overviewTableValid, auditViewLogValid } from '../dtos/audit.dtos.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, getUserCredit, rePushAuditStores } from '../controllers/audit.controllers.js';
|
|
5
|
+
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid, pendingSummaryTableValid, reTriggerValid, saveDraftValid, saveValid, storeMetricsValid, summarySplitValid, userAuditHistoryValid, userMetricsValid, workSpaceValid, auditImageValid, overviewTableValid, auditViewLogValid, rePushAuditStoresValid } from '../dtos/audit.dtos.js';
|
|
6
6
|
|
|
7
7
|
export const auditRouter = express.Router();
|
|
8
8
|
|
|
@@ -46,3 +46,6 @@ auditRouter.get( '/get-user-audit-count-mtd', isAllowedSessionHandler, getUserAu
|
|
|
46
46
|
// audit log
|
|
47
47
|
auditRouter.get( '/audit-view-logs', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ] } ), validate( auditViewLogValid ), auditViewLogs );
|
|
48
48
|
export default auditRouter;
|
|
49
|
+
|
|
50
|
+
//
|
|
51
|
+
auditRouter.post( '/re-push-audit-stores', validate( rePushAuditStoresValid ), validation, rePushAuditStores );
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { checkFileExist, chunkArray, getJsonFileData, getObject, getQueueUrl, listFileWithoutLimit, logger, signedUrl } from 'tango-app-api-middleware';
|
|
2
2
|
import { findOneUserAudit } from '../service/userAudit.service.js';
|
|
3
|
-
import { findOneStoreAudit } from '../service/storeAudit.service.js';
|
|
3
|
+
import { aggregateStoreAudit, findOneStoreAudit } from '../service/storeAudit.service.js';
|
|
4
4
|
import AdmZip from 'adm-zip';
|
|
5
5
|
import { findOneAuditUsers } from '../service/auditUsers.service.js';
|
|
6
6
|
|
|
@@ -356,3 +356,39 @@ export async function isAuditUser( req, res, next ) {
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
+
export async function validation( req, res, next ) {
|
|
360
|
+
try {
|
|
361
|
+
const inputData = req.body;
|
|
362
|
+
const getStoreDataQuery = [
|
|
363
|
+
{
|
|
364
|
+
$match: {
|
|
365
|
+
$and: [
|
|
366
|
+
{
|
|
367
|
+
clientId: { $eq: inputData.clientId },
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
fileDate: { $eq: inputData.fileDate },
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
moduleType: { $eq: 'traffic' },
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
status: { $nin: [ 'not_assign', 'assigned' ] },
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
];
|
|
382
|
+
const getStoreAudit = await aggregateStoreAudit( getStoreDataQuery );
|
|
383
|
+
if ( getStoreAudit && getStoreAudit?.length > 0 ) {
|
|
384
|
+
return res.sendError( 'Already pending stores are there', 403 );
|
|
385
|
+
} else {
|
|
386
|
+
next();
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
} catch ( error ) {
|
|
390
|
+
logger.error( { error: error, message: req.query, function: 'validation-audit.validation' } );
|
|
391
|
+
return res.sendError( error, 500 );
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|