tango-app-api-infra 3.9.5-vms.89 → 3.9.5-vms.90
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
|
@@ -104,9 +104,10 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
104
104
|
try {
|
|
105
105
|
const inputData = req.body;
|
|
106
106
|
|
|
107
|
+
logger.info( { inputData, msg: '...........1' } );
|
|
107
108
|
// get store info by the storeId into mongo db
|
|
108
109
|
const getstoreName = await findOneStore( { storeId: inputData.storeId, status: 'active' }, { storeId: 1, storeName: 1, clientId: 1 } );
|
|
109
|
-
|
|
110
|
+
logger.info( { getstoreName, msg: '...........2' } );
|
|
110
111
|
if ( !getstoreName || getstoreName == null ) {
|
|
111
112
|
return res.sendError( 'The store ID is either inActive or not found', 400 );
|
|
112
113
|
}
|
|
@@ -114,6 +115,7 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
114
115
|
// get the footfall count from opensearch
|
|
115
116
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
116
117
|
const dateString = `${inputData.storeId}_${inputData.dateString}`;
|
|
118
|
+
logger.info( { dateString, msg: '...........3' } );
|
|
117
119
|
const getQuery = {
|
|
118
120
|
query: {
|
|
119
121
|
terms: {
|
|
@@ -131,16 +133,19 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
131
133
|
};
|
|
132
134
|
|
|
133
135
|
const getFootfallCount = await getOpenSearchData( openSearch.footfall, getQuery );
|
|
136
|
+
logger.info( { getFootfallCount, msg: '...........4' } );
|
|
134
137
|
const hits = getFootfallCount?.body?.hits?.hits || [];
|
|
135
138
|
if ( hits?.[0]?._source?.footfall_count <= 0 ) {
|
|
136
139
|
return res.sendError( 'You can’t create a ticket because this store has 0 footfall data' );
|
|
137
140
|
}
|
|
138
|
-
|
|
141
|
+
logger.info( { hits, msg: '...........5' } );
|
|
139
142
|
// get category details from the client level configuration
|
|
140
143
|
const getConfig = await findOneClient( { clientId: getstoreName.clientId }, { footfallDirectoryConfigs: 1 } );
|
|
144
|
+
logger.info( { getConfig, msg: '...........6' } );
|
|
141
145
|
if ( !getConfig || getConfig == null ) {
|
|
142
146
|
return res.sendError( 'The Client ID is either not configured or not found', 400 );
|
|
143
147
|
}
|
|
148
|
+
|
|
144
149
|
let findQuery = {
|
|
145
150
|
size: 10000,
|
|
146
151
|
query: {
|
|
@@ -161,8 +166,9 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
161
166
|
},
|
|
162
167
|
};
|
|
163
168
|
let findTicket = await getOpenSearchData( openSearch.footfallDirectory, findQuery );
|
|
169
|
+
logger.info( { findTicket, msg: '...........7' } );
|
|
164
170
|
let Ticket = findTicket.body?.hits?.hits;
|
|
165
|
-
|
|
171
|
+
logger.info( { Ticket, msg: '...........8' } );
|
|
166
172
|
if ( Ticket.length === 0 ) {
|
|
167
173
|
return res.sendError( 'Ticket not found', 400 );
|
|
168
174
|
}
|
|
@@ -186,7 +192,7 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
186
192
|
},
|
|
187
193
|
},
|
|
188
194
|
};
|
|
189
|
-
if ( Ticket[0]?._source?.type
|
|
195
|
+
if ( Ticket[0]?._source?.type !== 'internal' ) {
|
|
190
196
|
getTicket.query.bool.must.push(
|
|
191
197
|
{
|
|
192
198
|
nested: {
|
|
@@ -209,7 +215,7 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
209
215
|
}
|
|
210
216
|
const getFootfallticketData = await getOpenSearchData( openSearch.footfallDirectory, getTicket );
|
|
211
217
|
const ticketData = getFootfallticketData?.body?.hits?.hits;
|
|
212
|
-
|
|
218
|
+
logger.info( { ticketData, msg: '...........9' } );
|
|
213
219
|
if ( !ticketData || ticketData?.length == 0 ) {
|
|
214
220
|
return res.sendError( 'You don’t have any tagged images right now', 400 );
|
|
215
221
|
}
|
|
@@ -225,26 +231,32 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
225
231
|
createdByRole: req?.user?.role,
|
|
226
232
|
|
|
227
233
|
};
|
|
228
|
-
|
|
234
|
+
logger.info( { record, msg: '...........10' } );
|
|
229
235
|
|
|
230
236
|
// Retrieve client footfallDirectoryConfigs revision
|
|
231
237
|
let isAutoCloseEnable = getConfig.footfallDirectoryConfigs.isAutoCloseEnable;
|
|
232
238
|
let autoCloseAccuracy = getConfig?.footfallDirectoryConfigs?.autoCloseAccuracy;
|
|
233
|
-
|
|
239
|
+
logger.info( { isAutoCloseEnable, autoCloseAccuracy, msg: '...........11' } );
|
|
234
240
|
const getNumber = autoCloseAccuracy.split( '%' )[0];
|
|
235
|
-
|
|
241
|
+
logger.info( { getNumber, msg: '...........12' } );
|
|
236
242
|
let autoCloseAccuracyValue = parseFloat( ( autoCloseAccuracy || getNumber ).replace( '%', '' ) );
|
|
243
|
+
logger.info( { autoCloseAccuracyValue, msg: '...........13' } );
|
|
237
244
|
let revisedPercentage = inputData.mappingInfo?.revicedPerc;
|
|
245
|
+
logger.info( { revisedPercentage, msg: '...........14' } );
|
|
238
246
|
const revised = Number( revisedPercentage?.split( '%' )[0] );
|
|
247
|
+
logger.info( { revised, msg: '...........15' } );
|
|
239
248
|
const tangoReview = Number( getConfig?.footfallDirectoryConfigs?.tangoReview?.split( '%' )[0] );
|
|
240
249
|
// If autoclose enabled and revisedPercentage meets/exceeds threshold, close ticket and skip revision
|
|
250
|
+
logger.info( { tangoReview, msg: '...........16' } );
|
|
241
251
|
if (
|
|
242
252
|
isAutoCloseEnable === true &&
|
|
243
253
|
revisedPercentage >= autoCloseAccuracyValue
|
|
244
254
|
) {
|
|
255
|
+
logger.info( { isAutoCloseEnable, revisedPercentage, autoCloseAccuracyValue, msg: '...........17' } );
|
|
245
256
|
record.status = 'Closed';
|
|
246
257
|
// Only keep or modify mappingInfo items with type "review"
|
|
247
258
|
if ( Array.isArray( record.mappingInfo ) ) {
|
|
259
|
+
logger.info( { msg: '...........18' } );
|
|
248
260
|
const temp = record.mappingInfo
|
|
249
261
|
.filter( ( item ) => item.type === 'tangoreview' )
|
|
250
262
|
.map( ( item ) => ( {
|
|
@@ -291,11 +303,13 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
291
303
|
},
|
|
292
304
|
);
|
|
293
305
|
} else if ( revised < tangoReview ) {
|
|
306
|
+
logger.info( { msg: '...........19', revised, tangoReview, status: record.status } );
|
|
294
307
|
// If ticket is closed, do not proceed with revision mapping
|
|
295
308
|
|
|
296
309
|
record.status = 'Open - Accuracy Issue';
|
|
297
310
|
// Only keep or modify mappingInfo items with type "review"
|
|
298
311
|
if ( Array.isArray( record.mappingInfo ) ) {
|
|
312
|
+
logger.info( { msg: '...........20', status: record.status } );
|
|
299
313
|
const temp = record.mappingInfo
|
|
300
314
|
.filter( ( item ) => item.type === 'tangoreview' )
|
|
301
315
|
.map( ( item ) => ( {
|
|
@@ -303,6 +317,7 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
303
317
|
mode: inputData.mappingInfo?.mode,
|
|
304
318
|
revicedFootfall: inputData.mappingInfo?.revicedFootfall,
|
|
305
319
|
revicedPerc: inputData.mappingInfo?.revicedPerc,
|
|
320
|
+
reviced: parseInt( inputData.mappingInfo?.revicedPerc ),
|
|
306
321
|
count: inputData.mappingInfo?.count,
|
|
307
322
|
revisedDetail: inputData.mappingInfo?.revisedDetail,
|
|
308
323
|
status: 'Open - Accuracy Issue',
|
|
@@ -319,7 +334,7 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
319
334
|
record.mappingInfo = record.mappingInfo.map( ( item ) => {
|
|
320
335
|
return {
|
|
321
336
|
...item,
|
|
322
|
-
status: item.type === 'approve'? 'Tango Review Done':'Closed',
|
|
337
|
+
status: item.type === 'approve'? 'Tango Review Done': item.type === 'tangoreview'? 'Open - Accuracy Issue': 'Closed',
|
|
323
338
|
};
|
|
324
339
|
} );
|
|
325
340
|
}
|
|
@@ -328,8 +343,9 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
328
343
|
{
|
|
329
344
|
type: 'finalRevision',
|
|
330
345
|
mode: inputData.mappingInfo?.mode,
|
|
331
|
-
revicedFootfall: revisedFootfall,
|
|
346
|
+
revicedFootfall: inputData.mappingInfo?.revisedFootfall,
|
|
332
347
|
revicedPerc: inputData.mappingInfo?.revicedPerc,
|
|
348
|
+
reviced: parseInt( inputData.mappingInfo?.revicedPerc ),
|
|
333
349
|
count: inputData.mappingInfo?.count,
|
|
334
350
|
revisedDetail: inputData.mappingInfo?.revisedDetail,
|
|
335
351
|
status: 'Closed',
|
|
@@ -344,6 +360,7 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
344
360
|
}
|
|
345
361
|
} else {
|
|
346
362
|
if ( Array.isArray( record.mappingInfo ) ) {
|
|
363
|
+
logger.info( { msg: '...........21', status: record.status } );
|
|
347
364
|
const temp = record.mappingInfo
|
|
348
365
|
.filter( ( item ) => item.type === 'tangoreview' )
|
|
349
366
|
.map( ( item ) => ( {
|
|
@@ -351,12 +368,14 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
351
368
|
mode: inputData.mappingInfo?.mode,
|
|
352
369
|
revicedFootfall: inputData.mappingInfo?.revicedFootfall,
|
|
353
370
|
revicedPerc: inputData.mappingInfo?.revicedPerc,
|
|
371
|
+
reviced: parseInt( inputData.mappingInfo?.revicedPerc ),
|
|
354
372
|
count: inputData.mappingInfo?.count,
|
|
355
373
|
revisedDetail: inputData.mappingInfo?.revisedDetail,
|
|
356
374
|
status: 'Closed',
|
|
357
375
|
createdByEmail: req?.user?.email,
|
|
358
376
|
createdByUserName: req?.user?.userName,
|
|
359
377
|
createdByRole: req?.user?.role,
|
|
378
|
+
createdAt: new Date(),
|
|
360
379
|
} ) );
|
|
361
380
|
|
|
362
381
|
record.mappingInfo = [ ...ticketData?.[0]?._source?.mappingInfo.slice( 0, -1 ),
|
|
@@ -376,6 +395,7 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
376
395
|
mode: inputData.mappingInfo?.mode,
|
|
377
396
|
revicedFootfall: inputData.mappingInfo?.revicedFootfall,
|
|
378
397
|
revicedPerc: inputData.mappingInfo?.revicedPerc,
|
|
398
|
+
reviced: parseInt( inputData.mappingInfo?.revicedPerc ),
|
|
379
399
|
count: inputData.mappingInfo?.count,
|
|
380
400
|
revisedDetail: inputData.mappingInfo?.revisedDetail,
|
|
381
401
|
status: 'Closed',
|
|
@@ -427,76 +447,15 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
427
447
|
isVideoStream: true,
|
|
428
448
|
};
|
|
429
449
|
const getStoreType = await countDocumnetsCamera( query );
|
|
430
|
-
const revopInfoQuery = {
|
|
431
|
-
size: 10000,
|
|
432
|
-
query: {
|
|
433
|
-
bool: {
|
|
434
|
-
must: [
|
|
435
|
-
{
|
|
436
|
-
term: {
|
|
437
|
-
'storeId.keyword': inputData.storeId,
|
|
438
|
-
},
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
term: {
|
|
442
|
-
'dateString': inputData.dateString,
|
|
443
|
-
},
|
|
444
|
-
},
|
|
445
|
-
{
|
|
446
|
-
term: {
|
|
447
|
-
'isParent': false,
|
|
448
|
-
},
|
|
449
|
-
},
|
|
450
|
-
{
|
|
451
|
-
term: {
|
|
452
|
-
isChecked: true,
|
|
453
|
-
},
|
|
454
|
-
},
|
|
455
|
-
],
|
|
456
|
-
},
|
|
457
|
-
},
|
|
458
|
-
_source: [ 'tempId' ],
|
|
459
450
|
|
|
460
|
-
};
|
|
461
|
-
const revopInfo = await getOpenSearchData( openSearch.revop, revopInfoQuery );
|
|
462
451
|
// Get all tempIds from revopInfo response
|
|
463
|
-
const
|
|
452
|
+
const temp = [];
|
|
453
|
+
inputData?.mappingInfo?.revisedDetail?.map( ( hit ) => temp.push( { tempId: hit?.tempId } ) ) || [];
|
|
454
|
+
logger.info( { msg: '...........22', temp, revisedDetails: inputData?.revisedDetail } );
|
|
464
455
|
// Prepare management eyeZone query based on storeId and dateString
|
|
465
|
-
const managerEyeZoneQuery = {
|
|
466
|
-
size: 1,
|
|
467
|
-
query: {
|
|
468
|
-
bool: {
|
|
469
|
-
must: [
|
|
470
|
-
{
|
|
471
|
-
term: {
|
|
472
|
-
'storeId.keyword': inputData.storeId,
|
|
473
|
-
},
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
term: {
|
|
477
|
-
'storeDate': inputData.dateString,
|
|
478
|
-
},
|
|
479
|
-
},
|
|
480
|
-
],
|
|
481
|
-
},
|
|
482
|
-
},
|
|
483
|
-
_source: [ 'originalToTrackerCustomerMapping' ],
|
|
484
|
-
};
|
|
485
456
|
|
|
486
|
-
// Query the managerEyeZone index for the matching document
|
|
487
|
-
const managerEyeZoneResp = await getOpenSearchData( openSearch.managerEyeZone, managerEyeZoneQuery );
|
|
488
|
-
const managerEyeZoneHit = managerEyeZoneResp?.body?.hits?.hits?.[0]?._source;
|
|
489
|
-
// Extract originalToTrackerCustomerMapping if it exists
|
|
490
|
-
const mapping =
|
|
491
|
-
managerEyeZoneHit && managerEyeZoneHit.originalToTrackerCustomerMapping ?
|
|
492
|
-
managerEyeZoneHit.originalToTrackerCustomerMapping :
|
|
493
|
-
{};
|
|
494
|
-
|
|
495
|
-
// Find tempIds that exist in both revopInfo results and manager mapping
|
|
496
|
-
const temp = [];
|
|
497
|
-
tempIds.filter( ( tid ) => mapping[tid] !== null ? temp.push( { tempId: mapping[tid] } ) :'' );
|
|
498
457
|
const isSendMessge = await sendSqsMessage( inputData, temp, getStoreType, inputData.storeId );
|
|
499
|
-
if ( isSendMessge
|
|
458
|
+
if ( isSendMessge === true ) {
|
|
500
459
|
logger.info( '....1' );
|
|
501
460
|
}
|
|
502
461
|
}
|