Skip to content

Commit

Permalink
enhance(gdocs): validate narrative chart components
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber committed Jan 27, 2025
1 parent b642da5 commit 5b90d2c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions db/model/Gdoc/GdocBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,9 @@ export class GdocBase implements OwidGdocBaseInterface {
const chartIdsBySlug = await mapSlugsToIds(knex)
const publishedExplorersBySlug =
await db.getPublishedExplorersBySlug(knex)
const chartViewNames = await getChartViewsInfo(knex)
.then((cv) => cv.map((c) => c.name))
.then((chartViewNames) => new Set(chartViewNames))

const linkErrors: OwidGdocErrorMessage[] = []
for (const link of this.links) {
Expand Down Expand Up @@ -847,6 +850,16 @@ export class GdocBase implements OwidGdocBaseInterface {
}
break
}
case OwidGdocLinkType.ChartView: {
if (!chartViewNames.has(link.target)) {
linkErrors.push({
property: "content",
message: `Narrative chart with name ${link.target} does not exist`,
type: OwidGdocErrorMessageType.Error,
})
}
break
}
}
}

Expand Down

0 comments on commit 5b90d2c

Please sign in to comment.