tango-app-api-infra 3.9.5-vms.93 → 3.9.5-vms.96
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
|
@@ -222,7 +222,7 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
222
222
|
const getFootfallticketData = await getOpenSearchData( openSearch.footfallDirectory, getTicket );
|
|
223
223
|
const ticketData = getFootfallticketData?.body?.hits?.hits;
|
|
224
224
|
logger.info( { ticketData, msg: '...........9' } );
|
|
225
|
-
if ( !ticketData || ticketData?.length == 0 ) {
|
|
225
|
+
if ( ( !ticketData || ticketData?.length == 0 ) && inputData?.ticketType !== 'internal' ) {
|
|
226
226
|
return res.sendError( 'You don’t have any tagged images right now', 400 );
|
|
227
227
|
}
|
|
228
228
|
|
|
@@ -556,7 +556,7 @@ export async function tangoReviewAccuracyClosedTicket( req, res ) {
|
|
|
556
556
|
const getFootfallticketData = await getOpenSearchData( openSearch.footfallDirectory, getTicket );
|
|
557
557
|
const ticketData = getFootfallticketData?.body?.hits?.hits;
|
|
558
558
|
|
|
559
|
-
if ( !ticketData || ticketData?.length == 0 ) {
|
|
559
|
+
if ( ( !ticketData || ticketData?.length == 0 ) && inputData?.ticketType !== 'internal' ) {
|
|
560
560
|
return res.sendError( 'You don’t have any tagged images right now', 400 );
|
|
561
561
|
}
|
|
562
562
|
|
|
@@ -3570,88 +3570,9 @@ export async function getTickets( req, res ) {
|
|
|
3570
3570
|
if ( !response || response.length == 0 ) {
|
|
3571
3571
|
return res.sendError( `No Pending items in the selected dates for the store`, 400 );
|
|
3572
3572
|
}
|
|
3573
|
-
let temp = [];
|
|
3574
|
-
if ( inputData?.action ) {
|
|
3575
|
-
response.map( ( hit ) => {
|
|
3576
|
-
const defaultData = {
|
|
3577
|
-
storeId: hit._source.storeId,
|
|
3578
|
-
createdByEmail: hit?._source?.createdByEmail,
|
|
3579
|
-
dateString: hit?._source?.dateString,
|
|
3580
|
-
ticketName: hit?._source?.ticketName,
|
|
3581
|
-
status: hit?._source?.status?.revicedFootfall,
|
|
3582
|
-
revicedPerc: hit?._source?.revicedPerc,
|
|
3583
|
-
revicedFootfall: hit?._source?.revicedFootfall,
|
|
3584
|
-
mappingInfo: hit?._source?.mappingInfo,
|
|
3585
|
-
employeeStatus: hit?._source?.employeeStatus,
|
|
3586
|
-
houseKeepingStatus: hit?._source?.houseKeepingStatus,
|
|
3587
|
-
duplicateStatus: hit?._source?.duplicateStatus,
|
|
3588
|
-
junkStatus: hit?._source?.junkStatus,
|
|
3589
|
-
storeName: hit?._source?.storeName,
|
|
3590
|
-
ticketId: hit?._source?.ticketId,
|
|
3591
|
-
footfallCount: hit?._source?.footfallCount,
|
|
3592
|
-
comments: hit?._source?.comments,
|
|
3593
|
-
email: hit?._source?.comments,
|
|
3594
|
-
userName: hit?._source?.userName,
|
|
3595
|
-
role: hit?._source?.role,
|
|
3596
|
-
createdAt: hit?._source?.createdAt,
|
|
3597
|
-
updatedAt: hit?._source?.updatedAt,
|
|
3598
|
-
tempId: hit?._source?.tempId,
|
|
3599
|
-
houseKeepingCount: hit?._source?.houseKeepingCount,
|
|
3600
|
-
employeeCount: hit?._source?.employeeCount,
|
|
3601
|
-
duplicateCount: hit?._source?.duplicateCount,
|
|
3602
|
-
junkCount: hit?._source?.junkCount,
|
|
3603
|
-
houseKeepingACCount: hit?._source?.houseKeepingACCount,
|
|
3604
|
-
employeeACCount: hit?._source?.employeeACCount,
|
|
3605
|
-
duplicateACCount: hit?._source?.duplicateACCount,
|
|
3606
|
-
junkACCount: hit?._source?.junkACCount,
|
|
3607
|
-
approverUserName: hit?._source?.approverUserName,
|
|
3608
|
-
approverEmail: hit?._source?.approverEmail,
|
|
3609
|
-
approverRole: hit?._source?.approverRole,
|
|
3610
|
-
type: hit?._source?.type,
|
|
3611
|
-
};
|
|
3612
|
-
let result;
|
|
3613
3573
|
|
|
3614
3574
|
|
|
3615
|
-
|
|
3616
|
-
// Add only matched data array
|
|
3617
|
-
if ( matched.includes( 'matched_employee' ) && ( !inputData.revopsType || inputData.revopsType == 'employee' ) ) {
|
|
3618
|
-
result = defaultData;
|
|
3619
|
-
result.employee = hit?._source?.employee;
|
|
3620
|
-
// result.type = 'employee';
|
|
3621
|
-
result.matched = matched;
|
|
3622
|
-
}
|
|
3623
|
-
if ( matched.includes( 'matched_housekeeping' ) && ( !inputData.revopsType || inputData.revopsType == 'houseKeeping' ) ) {
|
|
3624
|
-
result = defaultData;
|
|
3625
|
-
result.houseKeeping = hit?._source?.houseKeeping;
|
|
3626
|
-
result.matched = matched;
|
|
3627
|
-
}
|
|
3628
|
-
if ( matched.includes( 'matched_duplicate' ) && ( !inputData.revopsType || inputData.revopsType == 'duplicateImages' ) ) {
|
|
3629
|
-
result = defaultData;
|
|
3630
|
-
result.duplicateImages = hit?._source?.duplicateImages;
|
|
3631
|
-
result.matched = matched;
|
|
3632
|
-
}
|
|
3633
|
-
|
|
3634
|
-
if ( matched.includes( 'matched_junk' ) && ( !inputData.revopsType || inputData.revopsType == 'junk' ) ) {
|
|
3635
|
-
result = defaultData;
|
|
3636
|
-
result.junk = hit?._source?.junk;
|
|
3637
|
-
result.matched = matched;
|
|
3638
|
-
}
|
|
3639
|
-
|
|
3640
|
-
if ( result ) {
|
|
3641
|
-
const nested = [
|
|
3642
|
-
{
|
|
3643
|
-
_id: hit._id,
|
|
3644
|
-
_index: hit._index,
|
|
3645
|
-
_score: 0,
|
|
3646
|
-
_source: result,
|
|
3647
|
-
},
|
|
3648
|
-
];
|
|
3649
|
-
temp.push( ...nested );
|
|
3650
|
-
}
|
|
3651
|
-
} );
|
|
3652
|
-
}
|
|
3653
|
-
|
|
3654
|
-
const finalResponse = inputData.action ? temp : response;
|
|
3575
|
+
const finalResponse = response;
|
|
3655
3576
|
const getRevopQuery = {
|
|
3656
3577
|
size: 10000,
|
|
3657
3578
|
query: {
|
|
@@ -3894,9 +3815,10 @@ export async function getTickets( req, res ) {
|
|
|
3894
3815
|
mappingObj.revisedDetail = processedRevopSources;
|
|
3895
3816
|
}
|
|
3896
3817
|
} );
|
|
3897
|
-
} else {
|
|
3898
|
-
item._source.mappingInfo.revisedDetail = processedRevopSources;
|
|
3899
3818
|
}
|
|
3819
|
+
// else {
|
|
3820
|
+
// item._source.mappingInfo.revisedDetail = processedRevopSources;
|
|
3821
|
+
// }
|
|
3900
3822
|
}
|
|
3901
3823
|
}
|
|
3902
3824
|
} else if (
|
|
@@ -3906,7 +3828,11 @@ export async function getTickets( req, res ) {
|
|
|
3906
3828
|
) {
|
|
3907
3829
|
finalResponse._source.mappingInfo.revisedDetail = processedRevopSources;
|
|
3908
3830
|
}
|
|
3831
|
+
if ( inputData.action && inputData.action !== '' ) {
|
|
3832
|
+
const isCheck = inputData.action === 'approved'? true : false;
|
|
3909
3833
|
|
|
3834
|
+
finalResponse[0]._source.mappingInfo[finalResponse?.[0]?._source.mappingInfo?.length -1].revisedDetail = filterRevisedDetailByIsChecked( finalResponse?.[0]?._source?.mappingInfo[finalResponse?.[0]?._source?.mappingInfo?.length -1].revisedDetail, isCheck );
|
|
3835
|
+
}
|
|
3910
3836
|
return res.sendSuccess( { result: finalResponse } );
|
|
3911
3837
|
} catch ( error ) {
|
|
3912
3838
|
const err = error.message || 'Internal Server Error';
|
|
@@ -3915,6 +3841,35 @@ export async function getTickets( req, res ) {
|
|
|
3915
3841
|
}
|
|
3916
3842
|
}
|
|
3917
3843
|
|
|
3844
|
+
function filterRevisedDetailByIsChecked( revisedDetailArr, isCheckedValue ) {
|
|
3845
|
+
if ( !Array.isArray( revisedDetailArr ) ) return [];
|
|
3846
|
+
|
|
3847
|
+
// Helper function to filter duplicateImage recursively, only for revopsType === "duplicate"
|
|
3848
|
+
function filterDuplicateImages( duplicateImages, isChecked ) {
|
|
3849
|
+
if ( !Array.isArray( duplicateImages ) ) return [];
|
|
3850
|
+
return duplicateImages
|
|
3851
|
+
.filter( ( img ) => img.isChecked === isChecked )
|
|
3852
|
+
.map( ( img ) => ( {
|
|
3853
|
+
...img,
|
|
3854
|
+
duplicateImage: filterDuplicateImages( img.duplicateImage, isChecked ),
|
|
3855
|
+
} ) );
|
|
3856
|
+
}
|
|
3857
|
+
|
|
3858
|
+
return revisedDetailArr
|
|
3859
|
+
.filter( ( item ) => item.isChecked === isCheckedValue )
|
|
3860
|
+
.map( ( item ) => {
|
|
3861
|
+
if ( item.revopsType === 'duplicate' && Array.isArray( item.duplicateImage ) ) {
|
|
3862
|
+
// Filter the duplicateImage recursively for duplicates only
|
|
3863
|
+
return {
|
|
3864
|
+
...item,
|
|
3865
|
+
duplicateImage: filterDuplicateImages( item.duplicateImage, isCheckedValue ),
|
|
3866
|
+
};
|
|
3867
|
+
} else {
|
|
3868
|
+
return { ...item };
|
|
3869
|
+
}
|
|
3870
|
+
} );
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3918
3873
|
export async function updateStatus( req, res ) {
|
|
3919
3874
|
try {
|
|
3920
3875
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
@@ -5301,7 +5256,7 @@ export async function checkTicketExists( req, res ) {
|
|
|
5301
5256
|
},
|
|
5302
5257
|
};
|
|
5303
5258
|
let findTicket = await getOpenSearchData( openSearch.footfallDirectory, findQuery );
|
|
5304
|
-
let Ticket = findTicket
|
|
5259
|
+
let Ticket = findTicket?.body?.hits?.hits;
|
|
5305
5260
|
|
|
5306
5261
|
|
|
5307
5262
|
res.sendSuccess( Ticket );
|
|
@@ -264,7 +264,7 @@ export const getTicketsSchema = Joi.object().keys( {
|
|
|
264
264
|
// } ),
|
|
265
265
|
ticketId: Joi.string().required(),
|
|
266
266
|
// status: Joi.string().optional(),
|
|
267
|
-
action: Joi.string().optional(),
|
|
267
|
+
action: Joi.string().optional().allow( '' ),
|
|
268
268
|
// revopsType: Joi.string().optional(),
|
|
269
269
|
// limit: Joi.number().required(),
|
|
270
270
|
// offset: Joi.number().optional(),
|
|
@@ -359,6 +359,7 @@ export async function ticketCreation( req, res, next ) {
|
|
|
359
359
|
// Get taggingLimitation from config (check both possible paths)
|
|
360
360
|
const taggingLimitation = getConfig?.effectiveLimitation?.values;
|
|
361
361
|
// Initialize count object from taggingLimitation
|
|
362
|
+
|
|
362
363
|
const tempAcc = [];
|
|
363
364
|
taggingLimitation.reduce( ( acc, item ) => {
|
|
364
365
|
if ( item?.type ) {
|
|
@@ -409,11 +410,6 @@ export async function ticketCreation( req, res, next ) {
|
|
|
409
410
|
'isParent': false,
|
|
410
411
|
},
|
|
411
412
|
},
|
|
412
|
-
{
|
|
413
|
-
term: {
|
|
414
|
-
isChecked: true,
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
413
|
],
|
|
418
414
|
},
|
|
419
415
|
},
|
|
@@ -421,7 +417,7 @@ export async function ticketCreation( req, res, next ) {
|
|
|
421
417
|
type_counts: {
|
|
422
418
|
terms: {
|
|
423
419
|
field: 'revopsType.keyword',
|
|
424
|
-
size:
|
|
420
|
+
size: 10000,
|
|
425
421
|
},
|
|
426
422
|
},
|
|
427
423
|
},
|
|
@@ -430,7 +426,6 @@ export async function ticketCreation( req, res, next ) {
|
|
|
430
426
|
|
|
431
427
|
const revopData = await getOpenSearchData( openSearch.revop, revopQuery );
|
|
432
428
|
const buckets = revopData?.body?.aggregations?.type_counts?.buckets || [];
|
|
433
|
-
|
|
434
429
|
// Map OpenSearch revopsType values to count object keys
|
|
435
430
|
buckets.forEach( ( bucket ) => {
|
|
436
431
|
const revopsType = bucket.key;
|
|
@@ -458,13 +453,13 @@ export async function ticketCreation( req, res, next ) {
|
|
|
458
453
|
const totalCount = Array.isArray( tempAcc ) ?
|
|
459
454
|
tempAcc.reduce( ( sum, acc ) => sum + ( acc.value || 0 ), 0 ) :
|
|
460
455
|
0;
|
|
461
|
-
|
|
456
|
+
logger.info( { totalCount, tempAcc } );
|
|
462
457
|
const footfallCount = hits?.[0]?._source?.footfall_count || 0;
|
|
463
458
|
const revisedFootfall = Math.max( 0, footfallCount - totalCount );
|
|
464
459
|
if ( footfallCount - revisedFootfall == 0 ) {
|
|
465
460
|
return res.sendError( 'Cannot create a ticket because footfall hasn’t changed', 400 );
|
|
466
461
|
}
|
|
467
|
-
|
|
462
|
+
logger.info( { footfallCount, revisedFootfall } );
|
|
468
463
|
const taggingData = {
|
|
469
464
|
size: 10000,
|
|
470
465
|
query: {
|