Skip to content

Commit

Permalink
use serializeChartConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Sep 3, 2024
1 parent 7ba6412 commit eff6e94
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
12 changes: 10 additions & 2 deletions adminSiteServer/apiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,11 @@ const saveNewChart = async (
INSERT INTO chart_configs (id, patch, full)
VALUES (?, ?, ?)
`,
[configId, JSON.stringify(patchConfig), JSON.stringify(fullConfig)]
[
configId,
serializeChartConfig(patchConfig),
serializeChartConfig(fullConfig),
]
)

// add a new chart to the charts table
Expand Down Expand Up @@ -397,7 +401,11 @@ const updateExistingChart = async (
cc.full=?
WHERE c.id = ?
`,
[JSON.stringify(patchConfig), JSON.stringify(fullConfig), chartId]
[
serializeChartConfig(patchConfig),
serializeChartConfig(fullConfig),
chartId,
]
)

// update charts row
Expand Down
14 changes: 11 additions & 3 deletions db/model/ChartConfigs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { DbInsertChartConfig, GrapherInterface } from "@ourworldindata/types"
import {
DbInsertChartConfig,
GrapherInterface,
serializeChartConfig,
} from "@ourworldindata/types"

import * as db from "../db.js"

Expand Down Expand Up @@ -28,7 +32,11 @@ export async function updateExistingConfigPair(
full = ?
WHERE id = ?
`,
[JSON.stringify(patchConfig), JSON.stringify(fullConfig), configId]
[
serializeChartConfig(patchConfig),
serializeChartConfig(fullConfig),
configId,
]
)
}

Expand Down Expand Up @@ -63,6 +71,6 @@ async function updateExistingConfig(
SET ?? = ?
WHERE id = ?
`,
[column, JSON.stringify(config), configId]
[column, serializeChartConfig(config), configId]
)
}

0 comments on commit eff6e94

Please sign in to comment.