tango-app-api-audit 3.6.51 → 3.6.53

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-audit",
3
- "version": "3.6.51",
3
+ "version": "3.6.53",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -3187,12 +3187,7 @@ export async function getConversationDetails( req, res ) {
3187
3187
  'must': [
3188
3188
  {
3189
3189
  'term': {
3190
- 'doc_id.keyword': inputData.id,
3191
- },
3192
- },
3193
- {
3194
- 'term': {
3195
- 'moduleType.keyword': 'eyeTest-SOP',
3190
+ 'unique_id.keyword': inputData.id,
3196
3191
  },
3197
3192
  },
3198
3193
  ],
@@ -3201,7 +3196,7 @@ export async function getConversationDetails( req, res ) {
3201
3196
  'size': 1,
3202
3197
  };
3203
3198
 
3204
- const result = await getOpenSearchData( 'audio_analytics_report', query );
3199
+ const result = await getOpenSearchData( 'audio_analytics_report_v2', query );
3205
3200
  if ( result?.body?.hits?.hits?.length === 0 ) {
3206
3201
  return res.sendError( 'No data found', 204 );
3207
3202
  }
@@ -3220,53 +3215,33 @@ export async function getConversationDetails( req, res ) {
3220
3215
  return `${minutes}:${secs.toString().padStart( 2, '0' )}`;
3221
3216
  };
3222
3217
 
3218
+ // Helper: parse "s3://bucket/path/to/file" into { Bucket, file_path }
3219
+ const parseS3Uri = ( uri ) => {
3220
+ if ( !uri ) return null;
3221
+ const withoutScheme = uri.replace( /^s3:\/\//, '' );
3222
+ const slashIdx = withoutScheme.indexOf( '/' );
3223
+ if ( slashIdx === -1 ) return null;
3224
+ return {
3225
+ Bucket: withoutScheme.slice( 0, slashIdx ),
3226
+ file_path: withoutScheme.slice( slashIdx + 1 ),
3227
+ };
3228
+ };
3229
+
3223
3230
  // Helper function to format transcript: fetch and clean transcript file
3224
3231
  const getFormattedTranscript = async ( transcriptPath ) => {
3225
3232
  try {
3226
3233
  if ( !transcriptPath ) return '';
3227
3234
 
3228
- // Fetch the transcript file from S3
3229
-
3230
- let text =`[00:00:33.954 --> 00:00:36.154] The bifocals are progressive glasses.
3231
- [00:00:36.294 --> 00:00:37.194] They are big.
3232
- [00:00:38.654 --> 00:00:39.330] [silence]
3233
- [00:00:39.330 --> 00:00:42.210] The lens is bifocal and has an orcish look.
3234
- [00:00:43.130 --> 00:00:44.190] It adjusts upwards and downwards.
3235
- [00:00:44.350 --> 00:00:45.590] The other lens is progressive.
3236
- [00:00:48.798 --> 00:00:49.090] [silence]
3237
- [00:00:49.090 --> 00:00:49.162] It has a standard design.
3238
- [00:00:51.134 --> 00:00:51.266] [silence]
3239
- [00:00:51.266 --> 00:00:52.166] It is near to the ear and has an inter-implication distance.
3240
- [00:00:53.182 --> 00:00:53.666] [silence]
3241
- [00:00:53.666 --> 00:00:54.050] This is the base.
3242
- [00:00:54.430 --> 00:00:54.914] [silence]
3243
- [00:00:54.914 --> 00:00:56.514] It will be adjustable upwards and downwards.
3244
- [00:00:57.174 --> 00:00:57.914] It has an up and down.
3245
- [00:00:59.194 --> 00:01:01.654] There are three lenses in this.
3246
- [00:01:03.294 --> 00:01:03.426] [silence]
3247
- [00:01:03.426 --> 00:01:05.166] The standard has a reading area and a distance.
3248
- [00:01:05.166 --> 00:01:06.906] When the wider lens is used,
3249
- [00:01:06.986 --> 00:01:08.366] the wider angle is achieved.
3250
- [00:01:08.606 --> 00:01:09.026] [silence]
3251
- [00:01:09.026 --> 00:01:10.266] The cost will change accordingly.
3252
- [00:01:10.286 --> 00:01:11.246] The lens of this is 4000.
3253
- [00:01:12.062 --> 00:01:12.738] [silence]
3254
- [00:01:12.738 --> 00:01:13.662] The lens of this is 6000.
3255
- [00:01:14.430 --> 00:01:14.722] [silence]
3256
- [00:01:14.722 --> 00:01:16.734] The lens of this is 10,000.
3257
- [00:01:16.934 --> 00:01:17.394] You can adjust the size.
3258
- [00:01:53.854 --> 00:02:08.738] [silence]
3259
- [00:02:08.738 --> 00:02:09.198] Please change the number.
3260
- [00:02:10.302 --> 00:02:10.914] [silence]
3261
- [00:02:10.914 --> 00:02:11.830] Can I change the number now?
3262
- [00:02:12.230 --> 00:02:12.770] Yes, you can.
3263
- [00:02:13.470 --> 00:02:14.114] [silence]
3264
- [00:02:14.114 --> 00:02:15.294] I will give you a different number.
3265
- [00:02:15.774 --> 00:02:15.970] [silence]
3266
- [00:02:15.970 --> 00:02:17.710] Which number do you want?
3267
- [00:02:18.670 --> 00:02:19.110] 555.
3268
- [00:02:19.130 --> 00:02:20.010] I will give you a different number.
3269
- `;
3235
+ const s3Parts = parseS3Uri( transcriptPath );
3236
+ logger.info( { s3Parts: s3Parts, function: 'getFormattedTranscript' } );
3237
+ if ( !s3Parts ) return '';
3238
+
3239
+ const transcriptSignedUrl = await signedUrl( { ...s3Parts, key: 'aws' } );
3240
+ if ( !transcriptSignedUrl ) return '';
3241
+
3242
+ const fetchRes = await fetch( transcriptSignedUrl );
3243
+ if ( !fetchRes.ok ) return '';
3244
+ let text = await fetchRes.text();
3270
3245
 
3271
3246
  // Remove timestamps like [00:00:33.954 --> 00:00:36.154]
3272
3247
  text = text.replace( /\[\d{2}:\d{2}:\d{2}\.\d{3} --> \d{2}:\d{2}:\d{2}\.\d{3}\]\s*/g, '' );
@@ -3300,7 +3275,8 @@ export async function getConversationDetails( req, res ) {
3300
3275
  };
3301
3276
 
3302
3277
  // Format metrics results with sequential time allocation
3303
- const metricsData = source?.cohort_analysis_results?.[0]?.metrics_results || [];
3278
+ const matchedCohort = source?.cohort_analysis_results?.find( ( c ) => c.cohortId === 'cohort_11_1ddea945-ff3a-4c11-95a9-bb425ca927de' );
3279
+ const metricsData = matchedCohort?.metrics_results || [];
3304
3280
 
3305
3281
  // Calculate sequential times for detected metrics
3306
3282
  let currentSeconds = 0;
@@ -3336,6 +3312,9 @@ export async function getConversationDetails( req, res ) {
3336
3312
  };
3337
3313
  } ) || [];
3338
3314
 
3315
+ // Fetch signed URL for audio
3316
+ const audioS3Parts = parseS3Uri( source?.s3_audio_path );
3317
+ const audioSignedUrl = audioS3Parts ? await signedUrl( { ...audioS3Parts, key: 'aws' } ) : null;
3339
3318
  // Fetch and format transcript
3340
3319
  const formattedTranscript = await getFormattedTranscript( source?.s3_transcript_path );
3341
3320
 
@@ -3352,7 +3331,7 @@ export async function getConversationDetails( req, res ) {
3352
3331
  // fileDate: source?.filedate,
3353
3332
  // processTimestamp: source?.processTimestamp,
3354
3333
  duration: formatDuration( source?.duration ),
3355
- s3_audio_path: 'https://lenskart-tab-audio.s3.amazonaws.com/output/LKST600/0080_1765986218.aac.m4a/0080_1765986218.aac.m4a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAW3MEBNASQ5F7U3PP%2F20260310%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Date=20260310T093304Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=1b789b8c95be45884cbadd1d6022980c57852963b77ef20d38674dbba27c6960', // source?.s3_audio_path,
3334
+ audio_url: audioSignedUrl,
3356
3335
  // s3_transcript_path: source?.s3_transcript_path,
3357
3336
  transcript_summary: formattedTranscript,
3358
3337
  // overall_score: executiveSummary?.overall_score,