Skip to content

Commit

Permalink
fix: add function to remove double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
asharonbaltazar committed Dec 9, 2024
1 parent 50b681c commit 1e7ba2c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/lambda/sinkMainProcessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<string, number>>((map, item) => {
Expand Down Expand Up @@ -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 });

Expand Down

0 comments on commit 1e7ba2c

Please sign in to comment.