diff --git a/baker/SiteBaker.tsx b/baker/SiteBaker.tsx index 4c47463a917..71598dfcc82 100644 --- a/baker/SiteBaker.tsx +++ b/baker/SiteBaker.tsx @@ -346,15 +346,19 @@ export class SiteBaker { ) const publishedChartsBySlug = keyBy(publishedCharts, "originalSlug") - const datapageIndicatorIds = excludeUndefined( - publishedCharts.map((chart) => chart.indicatorId) + const publishedChartsWithIndicatorIds = publishedCharts.filter( + (chart) => chart.indicatorId ) + const datapageIndicators: LinkedIndicator[] = await Promise.all( - datapageIndicatorIds.map(async (indicatorId: number) => { + publishedChartsWithIndicatorIds.map(async (linkedChart) => { + const indicatorId = linkedChart.indicatorId as number const metadata = await getVariableMetadata(indicatorId) return { id: indicatorId, - ...grabMetadataForGdocLinkedIndicator(metadata), + ...grabMetadataForGdocLinkedIndicator(metadata, { + chartConfigTitle: linkedChart.title, + }), } }) ) diff --git a/db/model/Gdoc/GdocBase.ts b/db/model/Gdoc/GdocBase.ts index ab0ba812fd4..41320d5c7f6 100644 --- a/db/model/Gdoc/GdocBase.ts +++ b/db/model/Gdoc/GdocBase.ts @@ -650,7 +650,9 @@ export class GdocBase extends BaseEntity implements OwidGdocBaseInterface { ) const linkedIndicator: LinkedIndicator = { id: linkedChart.indicatorId, - ...grabMetadataForGdocLinkedIndicator(metadata), + ...grabMetadataForGdocLinkedIndicator(metadata, { + chartConfigTitle: linkedChart.title, + }), } return linkedIndicator }) diff --git a/packages/@ourworldindata/utils/src/metadataHelpers.ts b/packages/@ourworldindata/utils/src/metadataHelpers.ts index 064716558f9..b2648fdbf90 100644 --- a/packages/@ourworldindata/utils/src/metadataHelpers.ts +++ b/packages/@ourworldindata/utils/src/metadataHelpers.ts @@ -276,11 +276,13 @@ export const formatSourceDate = ( } export function grabMetadataForGdocLinkedIndicator( - metadata: OwidVariableWithSourceAndDimension + metadata: OwidVariableWithSourceAndDimension, + { chartConfigTitle }: { chartConfigTitle: string } ): Omit { return { title: metadata.presentation?.titlePublic || + chartConfigTitle || metadata.presentation?.grapherConfigETL?.title || metadata.display?.name || metadata.name ||