tango-app-api-infra 3.9.5-vms.50 β†’ 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-infra",
3
- "version": "3.9.5-vms.50",
3
+ "version": "3.9.5-vms.52",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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
- logger.info( { ticketData, getFootfallticketData } );
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
- logger.info( { ticketData, getFootfallticketData } );
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
- logger.info( { getNumber } );
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
- console.log( 'πŸš€ ~ tangoReviewTicket ~ id:', id );
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,
@@ -867,6 +859,15 @@ export async function ticketList( req, res ) {
867
859
  query: {
868
860
  bool: {
869
861
  must: [
862
+ {
863
+ 'range': {
864
+ 'dateString': {
865
+ 'gte': inputData.fromDate,
866
+ 'lte': inputData.toDate,
867
+ 'format': 'yyyy-MM-dd',
868
+ },
869
+ },
870
+ },
870
871
  {
871
872
  terms: {
872
873
  'clientId.keyword': Array.isArray( inputData.clientId ) ?
@@ -1015,7 +1016,7 @@ export async function ticketList( req, res ) {
1015
1016
  }
1016
1017
  }
1017
1018
  } else {
1018
- if ( req.user.role === 'superadmin' ) {
1019
+ if ( inputData?.permissionType ==='approve' ) {
1019
1020
  for ( let item of ticketListData ) {
1020
1021
  temp.push( {
1021
1022
 
@@ -1037,6 +1038,26 @@ export async function ticketList( req, res ) {
1037
1038
  tangoStatus: item?.mappingInfo?.find( ( f ) => f.type === 'tangoreview' )?.revicedPerc || '--',
1038
1039
  approvedBy: item?.mappingInfo?.find( ( f ) => f.type === 'approve' )?.createdByEmail || '--',
1039
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
+
1040
1061
  } );
1041
1062
  }
1042
1063
  } else if ( req.user.role === 'user' ) {
@@ -2344,7 +2365,6 @@ export async function updateTempStatus( req, res ) {
2344
2365
  comments: comments || '',
2345
2366
  } );
2346
2367
  }
2347
- logger.info( { docsToUpdate } );
2348
2368
  const bulkPayload = [];
2349
2369
  // 4. Build bulk update payload
2350
2370
  for ( const doc of docsToUpdate ) {
@@ -2362,8 +2382,48 @@ export async function updateTempStatus( req, res ) {
2362
2382
  // Count successes
2363
2383
  const updatedCount = bulkResp?.body?.items?.filter( ( item ) => item?.update?.result === 'updated' || item?.update?.result === 'noop' ).length ?? 0;
2364
2384
 
2365
- logger.info( { updated: updatedCount, by: 'updateTempStatus', ids: id } );
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
+
2366
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
+ }
2367
2427
  return res.sendSuccess( { updated: updatedCount } );
2368
2428
  } catch ( error ) {
2369
2429
  const err = error.message;
@@ -2609,7 +2669,6 @@ export async function checkTicketExists( req, res ) {
2609
2669
  };
2610
2670
  let findTicket = await getOpenSearchData( openSearch.footfallDirectory, findQuery );
2611
2671
  let Ticket = findTicket.body?.hits?.hits;
2612
- console.log( Ticket );
2613
2672
 
2614
2673
 
2615
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