tango-app-api-audit 3.5.60 → 3.6.0
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,5 +1,5 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import { isAuditDocumentExist, isAuditInputFolderExist, isAuditUser, isExistsQueue, validateUserAudit, validation } from '../validation/audit.validation.js';
|
|
2
|
+
import { isAuditDocumentExist, isAuditInputFolderExist, isAuditUser, isExistsQueue, isFeatureRunning, validateUserAudit, validation } from '../validation/audit.validation.js';
|
|
3
3
|
import { accessVerification, isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
4
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
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';
|
|
@@ -28,7 +28,7 @@ auditRouter.post( '/metrics/pending-summary-table', isAllowedSessionHandler, acc
|
|
|
28
28
|
auditRouter.post( '/metrics/overall-audit-summary', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ] } ), validate( overAllAuditSummaryValid ), overAllAuditSummary );
|
|
29
29
|
auditRouter.post( '/metrics/re-trigger', isAllowedSessionHandler,
|
|
30
30
|
accessVerification( { userType: [ 'tango' ], access: [ { featureName: 'TangoAdmin', name: 'TicketConfiguration', permissions: [ 'isEdit' ] } ] } ),
|
|
31
|
-
validate( reTriggerValid ), isAuditDocumentExist, isAuditInputFolderExist, reTrigger );
|
|
31
|
+
validate( reTriggerValid ), isAuditDocumentExist, isAuditInputFolderExist, isFeatureRunning, reTrigger );
|
|
32
32
|
auditRouter.get( '/audit-images', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ] } ), validate( auditImageValid ), isAuditInputFolderExist, auditImages );
|
|
33
33
|
// summary
|
|
34
34
|
auditRouter.post( '/metrics/overview-card', isAllowedSessionHandler, accessVerification( { userType: [ 'tango' ] } ), validate( overViewCardValid ), overViewCard );
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { checkFileExist, chunkArray, getJsonFileData, getObject, getQueueUrl, insertWithId, listFileWithoutLimit, logger, signedUrl } from 'tango-app-api-middleware';
|
|
1
|
+
import { checkFileExist, chunkArray, getJsonFileData, getObject, getOpenSearchData, getQueueUrl, insertWithId, listFileWithoutLimit, logger, signedUrl } from 'tango-app-api-middleware';
|
|
2
2
|
import { findOneUserAudit } from '../service/userAudit.service.js';
|
|
3
3
|
import { aggregateStoreAudit, findOneStoreAudit } from '../service/storeAudit.service.js';
|
|
4
4
|
import AdmZip from 'adm-zip';
|
|
@@ -428,7 +428,7 @@ export async function openSearchLog( inputData, user, id ) {
|
|
|
428
428
|
fileDate: inputData.fileDate || '',
|
|
429
429
|
auditType: inputData.auditType || '',
|
|
430
430
|
storeId: inputData.storeId || '',
|
|
431
|
-
clientId: inputData
|
|
431
|
+
clientId: inputData?.storeId?.split( '-' )[0] || '',
|
|
432
432
|
zoneName: inputData.zoneName || '',
|
|
433
433
|
moduleType: inputData.moduleType || '',
|
|
434
434
|
queueName: inputData.queueName || '',
|
|
@@ -457,3 +457,36 @@ export async function openSearchLog( inputData, user, id ) {
|
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
+
export async function isFeatureRunning( req, res, next ) {
|
|
461
|
+
try {
|
|
462
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
463
|
+
const inputData = req.body;
|
|
464
|
+
logger.info( { index: openSearch.tangoEyeLargeLogs } );
|
|
465
|
+
const getQuery = {
|
|
466
|
+
size: 1,
|
|
467
|
+
query: {
|
|
468
|
+
bool: {
|
|
469
|
+
must: [
|
|
470
|
+
{ term: { 'store_id.keyword': inputData.storeId } },
|
|
471
|
+
{ term: { 'store_date.keyword': inputData.fileDate } },
|
|
472
|
+
{ term: { 'module.keyword': inputData.moduleType ==='track'? 'live_features_retrigger':'features_retrigger' } },
|
|
473
|
+
{ term: { 'zone_id.keyword': inputData.moduleType === 'zone'? inputData.zoneName :'traffic_zone' } },
|
|
474
|
+
{ term: { 'completed_st': true } },
|
|
475
|
+
],
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
const getId = await getOpenSearchData( openSearch.tangoEyeLargeLogs, getQuery );
|
|
481
|
+
if ( getId?.body?.hits?.hits?.length > 0 ) {
|
|
482
|
+
next();
|
|
483
|
+
} else {
|
|
484
|
+
return res.sendError( `Access denied, due to running features for this store ${inputData.storeId} and for this ${inputData.fileDate}`, 400 );
|
|
485
|
+
}
|
|
486
|
+
} catch ( error ) {
|
|
487
|
+
const err = error.message || 'Internal Server Error';
|
|
488
|
+
logger.error( { error: error, message: req.query, function: 'isFeatureRunning' } );
|
|
489
|
+
return res.sendError( err, 500 );
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|