Skip to content

Commit

Permalink
Tidy up - only generate translation id once.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmcmahon committed Jan 30, 2025
1 parent b3708aa commit acb6bee
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions packages/backend-common/src/sqs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,13 @@ export const generateOutputSignedUrlAndSendMessage = async (
languageCode: LanguageCode,
translationRequested: boolean,
): Promise<SendResult> => {
const translationId = `${s3Key}-translation`;
const signedUrls = await generateOutputSignedUrls(
s3Key,
region,
outputBucket,
userEmail,
7,
false,
);
const signedUrlsTranslation = await generateOutputSignedUrls(
s3Key,
region,
outputBucket,
userEmail,
7,
true,
);
const job: TranscriptionJob = {
id: s3Key, // id of the source file
Expand All @@ -108,6 +100,13 @@ export const generateOutputSignedUrlAndSendMessage = async (
return messageResult;
}
if (!isSqsFailure(messageResult) && translationRequested) {
const signedUrlsTranslation = await generateOutputSignedUrls(
translationId,
region,
outputBucket,
userEmail,
7,
);
return await sendMessage(
client,
queueUrl,
Expand Down Expand Up @@ -313,13 +312,11 @@ const generateOutputSignedUrls = async (
outputBucket: string,
userEmail: string,
expiresInDays: number,
translate: boolean,
): Promise<OutputBucketUrls> => {
const fileName = `${id}${translate ? '-translation' : ''}`;
const expiresIn = expiresInDays * 24 * 60 * 60;
const srtKey = `srt/${fileName}.srt`;
const jsonKey = `json/${fileName}.json`;
const textKey = `text/${fileName}.txt`;
const srtKey = `srt/${id}.srt`;
const jsonKey = `json/${id}.json`;
const textKey = `text/${id}.txt`;
const srtSignedS3Url = await getSignedUploadUrl(
region,
outputBucket,
Expand Down

0 comments on commit acb6bee

Please sign in to comment.