Skip to content

Commit

Permalink
fix(download): include Year column for explorers when its slug isn't …
Browse files Browse the repository at this point in the history
…"year" (#4445)
  • Loading branch information
marcelgerber authored Jan 14, 2025
1 parent d36bbfb commit 5537ae3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/@ourworldindata/core-table/src/OwidTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,19 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
): string {
let table
if (activeColumnSlugs?.length) {
table = this.select([
const timeColumnToInclude = [
OwidTableSlugs.year,
OwidTableSlugs.day,
this.timeColumn.slug, // needed for explorers, where the time column may be called anything
].find((colSlug) => this.has(colSlug))

if (!timeColumnToInclude)
throw new Error(
"Expected to find a time column to include in the CSV"
)

table = this.select([
timeColumnToInclude,
this.entityNameSlug,
...activeColumnSlugs,
])
Expand Down

0 comments on commit 5537ae3

Please sign in to comment.