From 155077fdca7928efa36a894d847866e95d3780f0 Mon Sep 17 00:00:00 2001 From: Daniel Bachler Date: Mon, 16 Dec 2024 17:56:55 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix=20bug=20in=20gdoc=20comp?= =?UTF-8?q?onent=20extraction=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/model/Gdoc/extractGdocComponentInfo.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/db/model/Gdoc/extractGdocComponentInfo.ts b/db/model/Gdoc/extractGdocComponentInfo.ts index 5b3d2182be1..7b96888f1ba 100644 --- a/db/model/Gdoc/extractGdocComponentInfo.ts +++ b/db/model/Gdoc/extractGdocComponentInfo.ts @@ -68,11 +68,15 @@ function iterateArrayProp( parentPath: string, prop: keyof T ): ChildIterationInfo[] { - return (parent[prop] as OwidEnrichedGdocBlock[]).map((child, index) => ({ - child: child, - parentPath: `${parentPath}`, - path: `${parentPath}.${String(prop)}[${index}]`, - })) + if (prop in parent) + return (parent[prop] as OwidEnrichedGdocBlock[]).map( + (child, index) => ({ + child: child, + parentPath: `${parentPath}`, + path: `${parentPath}.${String(prop)}[${index}]`, + }) + ) + else return [] } /** Convert the spans in a gdoc component to plain text. From 694f4301c3c094312b3e1bcd17a6a2e00638cdd1 Mon Sep 17 00:00:00 2001 From: Daniel Bachler Date: Mon, 16 Dec 2024 18:06:52 +0100 Subject: [PATCH 2/2] Update extractGdocComponentInfo.ts --- db/model/Gdoc/extractGdocComponentInfo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/model/Gdoc/extractGdocComponentInfo.ts b/db/model/Gdoc/extractGdocComponentInfo.ts index 7b96888f1ba..8c64d2d2ac1 100644 --- a/db/model/Gdoc/extractGdocComponentInfo.ts +++ b/db/model/Gdoc/extractGdocComponentInfo.ts @@ -68,7 +68,7 @@ function iterateArrayProp( parentPath: string, prop: keyof T ): ChildIterationInfo[] { - if (prop in parent) + if (parent[prop]) return (parent[prop] as OwidEnrichedGdocBlock[]).map( (child, index) => ({ child: child,