tango-app-api-infra 3.9.5-vms.51 β 3.9.5-vms.52
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
|
@@ -127,7 +127,6 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
127
127
|
|
|
128
128
|
const getFootfallCount = await getOpenSearchData( openSearch.footfall, getQuery );
|
|
129
129
|
const hits = getFootfallCount?.body?.hits?.hits || [];
|
|
130
|
-
logger.info( { hits } );
|
|
131
130
|
if ( hits?.[0]?._source?.footfall_count <= 0 ) {
|
|
132
131
|
return res.sendError( 'You canβt create a ticket because this store has 0 footfall data' );
|
|
133
132
|
}
|
|
@@ -158,7 +157,6 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
158
157
|
};
|
|
159
158
|
let findTicket = await getOpenSearchData( openSearch.footfallDirectory, findQuery );
|
|
160
159
|
let Ticket = findTicket.body?.hits?.hits;
|
|
161
|
-
console.log( Ticket );
|
|
162
160
|
if ( Ticket.length === 0 ) {
|
|
163
161
|
return res.sendError( 'Ticket not found', 400 );
|
|
164
162
|
}
|
|
@@ -182,7 +180,6 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
182
180
|
},
|
|
183
181
|
},
|
|
184
182
|
};
|
|
185
|
-
console.log( 'π ~ tangoReviewTicket ~ Ticket[0].type:', Ticket[0]?._source?.type );
|
|
186
183
|
if ( Ticket[0]?._source?.type != 'internal' ) {
|
|
187
184
|
getTicket.query.bool.must.push( {
|
|
188
185
|
term: {
|
|
@@ -192,12 +189,11 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
192
189
|
}
|
|
193
190
|
const getFootfallticketData = await getOpenSearchData( openSearch.footfallDirectory, getTicket );
|
|
194
191
|
const ticketData = getFootfallticketData?.body?.hits?.hits;
|
|
195
|
-
|
|
196
|
-
console.log( 'π ~ tangoReviewTicket ~ ticketData, getFootfallticketData:', ticketData, getFootfallticketData );
|
|
192
|
+
|
|
197
193
|
if ( !ticketData || ticketData?.length == 0 ) {
|
|
198
194
|
return res.sendError( 'You donβt have any tagged images right now', 400 );
|
|
199
195
|
}
|
|
200
|
-
|
|
196
|
+
|
|
201
197
|
const record = {
|
|
202
198
|
|
|
203
199
|
status: 'Closed',
|
|
@@ -216,12 +212,11 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
216
212
|
let autoCloseAccuracy = getConfig?.footfallDirectoryConfigs?.autoCloseAccuracy;
|
|
217
213
|
|
|
218
214
|
const getNumber = autoCloseAccuracy.split( '%' )[0];
|
|
219
|
-
|
|
215
|
+
|
|
220
216
|
let autoCloseAccuracyValue = parseFloat( ( autoCloseAccuracy || getNumber ).replace( '%', '' ) );
|
|
221
217
|
let revisedPercentage = inputData.mappingInfo?.revicedPerc;
|
|
222
218
|
const revised = Number( revisedPercentage?.split( '%' )[0] );
|
|
223
219
|
const tangoReview = Number( getConfig?.footfallDirectoryConfigs?.tangoReview?.split( '%' )[0] );
|
|
224
|
-
logger.info( { tangoReview, revised } );
|
|
225
220
|
// If autoclose enabled and revisedPercentage meets/exceeds threshold, close ticket and skip revision
|
|
226
221
|
if (
|
|
227
222
|
isAutoCloseEnable === true &&
|
|
@@ -400,11 +395,9 @@ export async function tangoReviewTicket( req, res ) {
|
|
|
400
395
|
if ( inputData.ticketType === 'internal' ) {
|
|
401
396
|
id = `${inputData.storeId}_${inputData.dateString}_internal_footfall-directory-tagging`;
|
|
402
397
|
}
|
|
403
|
-
|
|
404
|
-
console.log( 'π ~ tangoReviewTicket ~ record:', record );
|
|
398
|
+
|
|
405
399
|
const insertResult = await updateOpenSearchData( openSearch.footfallDirectory, id, { doc: record } );
|
|
406
400
|
|
|
407
|
-
logger.info( { insertResult, record, id } );
|
|
408
401
|
if ( insertResult && ( insertResult.statusCode === 201 || insertResult.statusCode === 200 ) ) {
|
|
409
402
|
return res.sendSuccess( 'Ticket closed successfully' );
|
|
410
403
|
} else {
|
|
@@ -552,7 +545,6 @@ export async function ticketSummary1( req, res ) {
|
|
|
552
545
|
|
|
553
546
|
const getData = await getOpenSearchData( openSearch.footfallDirectory, getQuery );
|
|
554
547
|
const aggs = getData?.body?.aggregations;
|
|
555
|
-
logger.info( { aggs: aggs, body: getData?.body } );
|
|
556
548
|
|
|
557
549
|
const result = {
|
|
558
550
|
totalTickets: aggs.totalTicketCount.value,
|
|
@@ -1024,7 +1016,7 @@ export async function ticketList( req, res ) {
|
|
|
1024
1016
|
}
|
|
1025
1017
|
}
|
|
1026
1018
|
} else {
|
|
1027
|
-
if (
|
|
1019
|
+
if ( inputData?.permissionType ==='approve' ) {
|
|
1028
1020
|
for ( let item of ticketListData ) {
|
|
1029
1021
|
temp.push( {
|
|
1030
1022
|
|
|
@@ -1046,6 +1038,26 @@ export async function ticketList( req, res ) {
|
|
|
1046
1038
|
tangoStatus: item?.mappingInfo?.find( ( f ) => f.type === 'tangoreview' )?.revicedPerc || '--',
|
|
1047
1039
|
approvedBy: item?.mappingInfo?.find( ( f ) => f.type === 'approve' )?.createdByEmail || '--',
|
|
1048
1040
|
|
|
1041
|
+
} );
|
|
1042
|
+
}
|
|
1043
|
+
} else if ( inputData?.permissionType ==='review' ) {
|
|
1044
|
+
for ( let item of ticketListData ) {
|
|
1045
|
+
temp.push( {
|
|
1046
|
+
|
|
1047
|
+
ticketId: item?.ticketId,
|
|
1048
|
+
storeId: item?.storeId,
|
|
1049
|
+
storeName: item?.storeName,
|
|
1050
|
+
ticketRaised: item?.mappingInfo?.find( ( f ) => f.type === 'tagging' )?.createdAt,
|
|
1051
|
+
issueDate: item?.dateString,
|
|
1052
|
+
footfall: item?.footfallCount,
|
|
1053
|
+
dueDate: '',
|
|
1054
|
+
type: item.type || 'store',
|
|
1055
|
+
storeRevisedAccuracy: item?.mappingInfo?.find( ( f ) => f.type === 'tagging' )?.revicedPerc || '--',
|
|
1056
|
+
reviewerRevisedAccuracy: item?.mappingInfo?.find( ( f ) => f.type === 'review' )?.revicedPerc || '--',
|
|
1057
|
+
|
|
1058
|
+
status: item?.mappingInfo?.find( ( f ) => f.type === 'review' )?.status || '--',
|
|
1059
|
+
ReviewedBy: item?.mappingInfo?.find( ( f ) => f.type === 'review' )?.createdByEmail || '--',
|
|
1060
|
+
|
|
1049
1061
|
} );
|
|
1050
1062
|
}
|
|
1051
1063
|
} else if ( req.user.role === 'user' ) {
|
|
@@ -2353,7 +2365,6 @@ export async function updateTempStatus( req, res ) {
|
|
|
2353
2365
|
comments: comments || '',
|
|
2354
2366
|
} );
|
|
2355
2367
|
}
|
|
2356
|
-
logger.info( { docsToUpdate } );
|
|
2357
2368
|
const bulkPayload = [];
|
|
2358
2369
|
// 4. Build bulk update payload
|
|
2359
2370
|
for ( const doc of docsToUpdate ) {
|
|
@@ -2371,8 +2382,48 @@ export async function updateTempStatus( req, res ) {
|
|
|
2371
2382
|
// Count successes
|
|
2372
2383
|
const updatedCount = bulkResp?.body?.items?.filter( ( item ) => item?.update?.result === 'updated' || item?.update?.result === 'noop' ).length ?? 0;
|
|
2373
2384
|
|
|
2374
|
-
|
|
2385
|
+
if ( inputData?.comments && inputData?.comments !== '' ) {
|
|
2386
|
+
const id = `${inputData.storeId}_${inputData.dateString}_${Date.now()}`;
|
|
2387
|
+
const searchBody1 = {
|
|
2388
|
+
size: 10000,
|
|
2389
|
+
query: {
|
|
2390
|
+
bool: {
|
|
2391
|
+
must: [
|
|
2392
|
+
{
|
|
2393
|
+
terms: {
|
|
2394
|
+
'_id': docIds,
|
|
2395
|
+
},
|
|
2396
|
+
},
|
|
2397
|
+
{
|
|
2398
|
+
term: {
|
|
2399
|
+
isParent: false,
|
|
2400
|
+
},
|
|
2401
|
+
},
|
|
2402
|
+
],
|
|
2403
|
+
},
|
|
2404
|
+
},
|
|
2405
|
+
};
|
|
2406
|
+
|
|
2407
|
+
const getSearchResp = await getOpenSearchData(
|
|
2408
|
+
openSearch.revop,
|
|
2409
|
+
searchBody1,
|
|
2410
|
+
);
|
|
2411
|
+
|
|
2375
2412
|
|
|
2413
|
+
const taggedImages = getSearchResp?.body?.hits?.hits?.length > 0? getSearchResp?.body?.hits?.hits : [];
|
|
2414
|
+
const logs = {
|
|
2415
|
+
type: inputData.type,
|
|
2416
|
+
category: taggedImages?.[0]?._source?.revopsType || '',
|
|
2417
|
+
taggedImages: taggedImages,
|
|
2418
|
+
status: inputData?.status,
|
|
2419
|
+
createdByEmail: req?.user?.email,
|
|
2420
|
+
createdByUserName: req?.user?.userName,
|
|
2421
|
+
createdByRole: req?.user?.role,
|
|
2422
|
+
message: inputData.comments || '',
|
|
2423
|
+
createdAt: new Date(),
|
|
2424
|
+
};
|
|
2425
|
+
await insertWithId( openSearch.vmsCommentsLog, id, logs );
|
|
2426
|
+
}
|
|
2376
2427
|
return res.sendSuccess( { updated: updatedCount } );
|
|
2377
2428
|
} catch ( error ) {
|
|
2378
2429
|
const err = error.message;
|
|
@@ -2618,7 +2669,6 @@ export async function checkTicketExists( req, res ) {
|
|
|
2618
2669
|
};
|
|
2619
2670
|
let findTicket = await getOpenSearchData( openSearch.footfallDirectory, findQuery );
|
|
2620
2671
|
let Ticket = findTicket.body?.hits?.hits;
|
|
2621
|
-
console.log( Ticket );
|
|
2622
2672
|
|
|
2623
2673
|
|
|
2624
2674
|
res.sendSuccess( Ticket );
|
|
@@ -536,7 +536,7 @@ export const assignTicketValid = {
|
|
|
536
536
|
export const updateTempStatusSchema = Joi.object().keys( {
|
|
537
537
|
id: Joi.array().items( Joi.string().required() ).required(),
|
|
538
538
|
status: Joi.string().required(),
|
|
539
|
-
type: Joi.string().required(),
|
|
539
|
+
type: Joi.string().required().allow( 'review', 'approve' ),
|
|
540
540
|
comments: Joi.string().optional().allow( '' ),
|
|
541
541
|
|
|
542
542
|
|