From 1e7ba2c7b41dcb15acca19ac6b0737c6f98e816d Mon Sep 17 00:00:00 2001 From: Asharon Baltazar Date: Mon, 9 Dec 2024 09:54:50 -0500 Subject: [PATCH] fix: add function to remove double quotes --- lib/lambda/sinkMainProcessors.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/lambda/sinkMainProcessors.ts b/lib/lambda/sinkMainProcessors.ts index 07ffafdf42..9009628cc0 100644 --- a/lib/lambda/sinkMainProcessors.ts +++ b/lib/lambda/sinkMainProcessors.ts @@ -4,6 +4,8 @@ import { Document, transforms } from "shared-types/opensearch/main"; import { decodeBase64WithUtf8 } from "shared-utils"; import { isBefore } from "date-fns"; +const removeDoubleQuotesSurroundingString = (str: string) => str.replace(/^"|"$/g, ""); + type OneMacRecord = { id: string; makoChangedDate: string | null; @@ -97,7 +99,9 @@ export const insertOneMacRecordsFromKafkaIntoMako = async ( }; const getMakoDocTimestamps = async (kafkaRecords: KafkaRecord[]) => { - const kafkaIds = kafkaRecords.map((record) => decodeBase64WithUtf8(record.key)); + const kafkaIds = kafkaRecords.map((record) => + removeDoubleQuotesSurroundingString(decodeBase64WithUtf8(record.key)), + ); const openSearchRecords = await getItems(kafkaIds); return openSearchRecords.reduce>((map, item) => { @@ -129,7 +133,7 @@ export const insertNewSeatoolRecordsFromKafkaIntoMako = async ( return collection; } - const id: string = decodeBase64WithUtf8(key); + const id: string = removeDoubleQuotesSurroundingString(decodeBase64WithUtf8(key)); console.log({ splitId: id.split(""), makoDocTimestamps });