Skip to content

Commit

Permalink
🔨 incorporate PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Feb 1, 2025
1 parent c1d8bfd commit d148826
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/@ourworldindata/grapher/src/core/LegacyToOwidTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
OwidColumnDef,
OwidVariableDimensions,
OwidVariableDataMetadataDimensions,
EntityId,
ErrorValue,
OwidChartDimensionInterfaceWithMandatorySlug,
EntityName,
} from "@ourworldindata/types"
import {
OwidTable,
Expand Down Expand Up @@ -332,20 +332,19 @@ export const legacyToOwidTableAndDimensions = (
const entityColorColumnSlug = OwidTableSlugs.entityColor

const valueFn = (
entityId: EntityId | undefined
entityName: EntityName | undefined
): string | ErrorValue => {
if (!entityId) return ErrorValueTypes.UndefinedButShouldBeString
const entityName =
joinedVariablesTable.entityIdToNameMap.get(entityId)
if (!entityName) return ErrorValueTypes.UndefinedButShouldBeString
return entityName && selectedEntityColors
? (selectedEntityColors[entityName] ??
ErrorValueTypes.UndefinedButShouldBeString)
: ErrorValueTypes.UndefinedButShouldBeString
}

const values = joinedVariablesTable.rows.map((row) =>
valueFn(row.entityId)
)
const values =
joinedVariablesTable.entityNameColumn.valuesIncludingErrorValues.map(
(entityName) => valueFn(entityName as EntityName)
)

joinedVariablesTable = joinedVariablesTable.appendColumns([
{
Expand Down

0 comments on commit d148826

Please sign in to comment.