tango-app-api-audit 3.5.1 → 3.5.3
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
|
@@ -65,7 +65,7 @@ import { aggregateBinaryAudit } from '../service/binaryAudit.service.js';
|
|
|
65
65
|
import { aggregateTraxAuditData, findOneTraxAuditData } from '../service/traxAuditData.service.js';
|
|
66
66
|
import { bulkWriteAuditUserWallet, createAuditUserWallet, findOneAuditUserWallet } from '../service/auditUserWallet.service.js';
|
|
67
67
|
import { updateOneAuditUsers } from '../service/auditUsers.service.js';
|
|
68
|
-
import { bulkUpdate, clearScroll, upsertOpenSearchData, scrollResponse, searchOpenSearchData } from 'tango-app-api-middleware/src/utils/openSearch.js';
|
|
68
|
+
import { bulkUpdate, clearScroll, upsertOpenSearchData, scrollResponse, searchOpenSearchData, updateOpenSearchData } from 'tango-app-api-middleware/src/utils/openSearch.js';
|
|
69
69
|
// import { aggregateAuditUsers } from '../service/auditUsers.service.js';
|
|
70
70
|
|
|
71
71
|
/* < -- *** Configuration *** --> */
|
|
@@ -539,32 +539,36 @@ export async function getAuditFile( req, res ) {
|
|
|
539
539
|
|
|
540
540
|
const getQuery = {
|
|
541
541
|
size: inputData?.limit || 2,
|
|
542
|
-
_source: [ 'module', 'date', 'store_id', 'outputCluster', 'personPath', 'isEmployee', 'isJunk' ], // Only fetch necessary fields
|
|
542
|
+
_source: [ 'module', 'status', 'date', 'store_id', 'outputCluster', 'personPath', 'isEmployee', 'isJunk', 'EmployeeStatusFinal' ], // Only fetch necessary fields
|
|
543
543
|
|
|
544
544
|
query: {
|
|
545
545
|
bool: {
|
|
546
|
-
must: [
|
|
546
|
+
'must': [
|
|
547
547
|
{
|
|
548
548
|
term: { 'store_id.keyword': msg.store_id },
|
|
549
549
|
},
|
|
550
|
-
// {
|
|
551
|
-
// term: { isJunk: false },
|
|
552
|
-
// },
|
|
553
|
-
{
|
|
554
|
-
term: { isEmployee: false },
|
|
555
|
-
},
|
|
556
550
|
{
|
|
557
551
|
term: { 'date.keyword': msg.curr_date },
|
|
558
552
|
},
|
|
559
553
|
{
|
|
560
554
|
term: { 'module.keyword': 'CUSTOMER' },
|
|
561
555
|
},
|
|
556
|
+
{
|
|
557
|
+
term: { 'status.keyword': 'PP_CLUSTER_FORMED' },
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
terms: { EmployeeStatusFinal: [ 1, 2 ] },
|
|
561
|
+
},
|
|
562
562
|
],
|
|
563
|
+
'should': [
|
|
564
|
+
{ 'term': { 'isJunk': false } },
|
|
565
|
+
{ 'bool': { 'must_not': { 'exists': { 'field': 'isJunk' } } } },
|
|
566
|
+
],
|
|
567
|
+
'minimum_should_match': 1,
|
|
563
568
|
},
|
|
564
569
|
},
|
|
565
570
|
|
|
566
571
|
};
|
|
567
|
-
|
|
568
572
|
const list = msg.zone_id === 'track' ? inputData.nextId? await scrollResponse( inputData.nextId ):await searchOpenSearchData( msg.index_name, getQuery ): await listFileByPath( fetchData );
|
|
569
573
|
const folderPath = msg.zone_id === 'track' ? list?.body?.hits?.hits : list.data;
|
|
570
574
|
const nextQuery =msg.zone_id !== 'track' ? list.pageToken: '';
|
|
@@ -618,7 +622,7 @@ export async function getAuditFile( req, res ) {
|
|
|
618
622
|
userId: req.user._id,
|
|
619
623
|
storeId: msg.store_id,
|
|
620
624
|
clientId: msg.store_id.split( '-' )[0],
|
|
621
|
-
auditType: 'Audit',
|
|
625
|
+
auditType: msg.audit_type || 'Audit',
|
|
622
626
|
fileDate: msg.curr_date,
|
|
623
627
|
queueName: inputData.queueName,
|
|
624
628
|
beforeCount: msg.total_count || files.length,
|
|
@@ -639,7 +643,7 @@ export async function getAuditFile( req, res ) {
|
|
|
639
643
|
userId: req.user._id,
|
|
640
644
|
storeId: msg.store_id,
|
|
641
645
|
clientId: msg.store_id.split( '-' )[0],
|
|
642
|
-
auditType: 'Audit',
|
|
646
|
+
auditType: msg.audit_type ||'Audit',
|
|
643
647
|
fileDate: msg.curr_date,
|
|
644
648
|
queueName: inputData.queueName,
|
|
645
649
|
beforeCount: msg.total_count || files.length,
|
|
@@ -656,6 +660,9 @@ export async function getAuditFile( req, res ) {
|
|
|
656
660
|
insertData = userDetails[0];
|
|
657
661
|
}
|
|
658
662
|
} else if ( inputData.nextId !== '' && inputData.nextId !== null && inputData.nextId !== undefined && inputData.moduleType === 'track' ) {
|
|
663
|
+
if ( !list ) {
|
|
664
|
+
return res.sendError( 'token expired', 404 );
|
|
665
|
+
}
|
|
659
666
|
list.body._scroll_id = '';
|
|
660
667
|
insertData = userDetails[0];
|
|
661
668
|
} else {
|
|
@@ -705,7 +712,7 @@ export async function getAuditFile( req, res ) {
|
|
|
705
712
|
queueName: inputData.queueName,
|
|
706
713
|
store_id: storeId,
|
|
707
714
|
file_date: fileDate,
|
|
708
|
-
type: 'Audit',
|
|
715
|
+
type: msg.audit_type || 'Audit',
|
|
709
716
|
auditId: insertData._id,
|
|
710
717
|
userId: insertData.userId,
|
|
711
718
|
zoneName: msg.zone_id,
|
|
@@ -720,7 +727,7 @@ export async function getAuditFile( req, res ) {
|
|
|
720
727
|
message: req.query,
|
|
721
728
|
function: 'getAuditFile',
|
|
722
729
|
} );
|
|
723
|
-
return res.sendError( error, 500 );
|
|
730
|
+
return res.sendError( error.message, 500 );
|
|
724
731
|
}
|
|
725
732
|
}
|
|
726
733
|
function addUniqueFile( files, newFile ) {
|
|
@@ -1694,7 +1701,7 @@ export async function save( req, res ) {
|
|
|
1694
1701
|
{ 'module': 'REID-TRACKER-V1',
|
|
1695
1702
|
'store_date_time': `${inputData.storeId}_${inputData.fileDate}_23:00`,
|
|
1696
1703
|
'status': 'POSTPROCESS_AUDIT_SUCCESS',
|
|
1697
|
-
'status_time': Date.now(),
|
|
1704
|
+
'status_time': Math.floor( Date.now() / 1000 ),
|
|
1698
1705
|
'timestamp': new Date() };
|
|
1699
1706
|
|
|
1700
1707
|
|
|
@@ -3109,7 +3116,7 @@ export async function reTrigger( req, res ) {
|
|
|
3109
3116
|
zoneName: inputData.zoneName,
|
|
3110
3117
|
};
|
|
3111
3118
|
const getQueueName = await findOneClient( { clientId: req.audit.clientId }, { 'auditConfigs': 1 } );
|
|
3112
|
-
const queueName = inputData.moduleType == 'zone' ? getQueueName?.auditConfigs?.zoneQueueName : getQueueName?.auditConfigs?.trafficQueueName;
|
|
3119
|
+
const queueName = inputData.moduleType == 'zone' ? getQueueName?.auditConfigs?.zoneQueueName :inputData.moduleType == 'track'?getQueueName?.auditConfigs?.trackQueueName: getQueueName?.auditConfigs?.trafficQueueName;
|
|
3113
3120
|
if ( !getQueueName || queueName == '' ) {
|
|
3114
3121
|
return res.sendError( 'queueName does not create', 400 );
|
|
3115
3122
|
}
|
|
@@ -3237,7 +3244,16 @@ export async function reTrigger( req, res ) {
|
|
|
3237
3244
|
};
|
|
3238
3245
|
await insertOpenSearchData( openSearch.auditLog, logData );
|
|
3239
3246
|
}
|
|
3247
|
+
const updateQuery ={
|
|
3248
|
+
module: 'REID-TRACKER-V1',
|
|
3249
|
+
store_date_time: `${inputData.storeId}_${inputData.fileDate}_23:00`,
|
|
3250
|
+
status: 'POSTPROCESS_AUDIT_INITIATED',
|
|
3251
|
+
statusvb_time: Math.floor( Date.now() / 1000 ),
|
|
3252
|
+
timestamp: new Date(),
|
|
3253
|
+
};
|
|
3254
|
+
|
|
3240
3255
|
|
|
3256
|
+
await updateOpenSearchData( 'tracker_process', `${inputData.storeId}_${inputData.fileDate}_23:00`, { doc: updateQuery } );
|
|
3241
3257
|
return res.sendSuccess( { result: 'The File has been Re-Triggered Succesfully' } );
|
|
3242
3258
|
} catch ( error ) {
|
|
3243
3259
|
const err = error.message;
|
|
@@ -173,7 +173,11 @@ export async function isAuditInputFolderExist( req, res, next ) {
|
|
|
173
173
|
Bucket: bucket.auditInput,
|
|
174
174
|
Key: `${inputData.fileDate}/${inputData.storeId}/${inputData.zoneName}`,
|
|
175
175
|
};
|
|
176
|
-
const
|
|
176
|
+
const trackParams={
|
|
177
|
+
Bucket: 'v4rnd-audit-input-images',
|
|
178
|
+
Key: `${inputData.storeId}/${inputData.fileDate}`,
|
|
179
|
+
};
|
|
180
|
+
const isExist = await checkFileExist( inputData.moduleType == 'track'? trackParams:params );
|
|
177
181
|
if ( isExist ) {
|
|
178
182
|
next();
|
|
179
183
|
} else {
|