Skip to content

Commit

Permalink
🐛 (admin) mark unpublished charts as drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Sep 4, 2024
1 parent 3cc05db commit d5ecaed
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
32 changes: 24 additions & 8 deletions adminSiteServer/apiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,12 @@ getRouteWithROTransaction(apiRouter, "/charts.json", async (req, res, trx) => {

await assignTagsForCharts(trx, charts)

return { charts }
return {
charts: charts.map((chart) => ({
...chart,
isPublished: chart.isPublished === "true",
})),
}
})

getRouteWithROTransaction(apiRouter, "/charts.csv", async (req, res, trx) => {
Expand Down Expand Up @@ -1254,9 +1259,10 @@ getRouteWithROTransaction(
variable.catalogPath += `#${variable.shortName}`
}

const charts = await db.knexRaw<OldChartFieldList>(
trx,
`-- sql
const charts = (
await db.knexRaw<OldChartFieldList>(
trx,
`-- sql
SELECT ${oldChartFieldList}
FROM charts
JOIN chart_configs ON chart_configs.id = charts.configId
Expand All @@ -1266,8 +1272,12 @@ getRouteWithROTransaction(
WHERE cd.variableId = ?
GROUP BY charts.id
`,
[variableId]
)
[variableId]
)
).map((chart) => ({
...chart,
isPublished: chart.isPublished === "true",
}))

await assignTagsForCharts(trx, charts)

Expand Down Expand Up @@ -1497,7 +1507,10 @@ getRouteWithROTransaction(
[datasetId]
)

dataset.charts = charts
dataset.charts = charts.map((chart) => ({
...chart,
isPublished: chart.isPublished === "true",
}))

await assignTagsForCharts(trx, charts)

Expand Down Expand Up @@ -1894,7 +1907,10 @@ getRouteWithROTransaction(
`,
uncategorized ? [] : [tagId]
)
tag.charts = charts
tag.charts = charts.map((chart) => ({
...chart,
isPublished: chart.isPublished === "true",
}))

await assignTagsForCharts(trx, charts)

Expand Down
2 changes: 1 addition & 1 deletion db/model/Chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export interface OldChartFieldList {
type: string
internalNotes: string
variantName: string
isPublished: boolean
isPublished: string | null
tab: string
hasChartTab: boolean
hasMapTab: boolean
Expand Down

0 comments on commit d5ecaed

Please sign in to comment.