Skip to content

Commit

Permalink
🐛 fix dataset detail view bug (group by select list was wrong) (#4307)
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 authored Dec 14, 2024
1 parent c57f904 commit 1afa5ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 3 additions & 4 deletions adminSiteServer/apiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,9 @@ getRouteWithROTransaction(apiRouter, "/charts.json", async (req, res, trx) => {
const charts = await db.knexRaw<OldChartFieldList>(
trx,
`-- sql
SELECT ${oldChartFieldList} FROM charts
SELECT ${oldChartFieldList},
round(views_365d / 365, 1) as pageviewsPerDay
FROM charts
JOIN chart_configs ON chart_configs.id = charts.configId
JOIN users lastEditedByUser ON lastEditedByUser.id = charts.lastEditedByUserId
LEFT JOIN analytics_pageviews on (analytics_pageviews.url = CONCAT("https://ourworldindata.org/grapher/", chart_configs.slug) AND chart_configs.full ->> '$.isPublished' = "true" )
Expand Down Expand Up @@ -1596,7 +1598,6 @@ getRouteWithROTransaction(
JOIN chart_configs ON chart_configs.id = charts.configId
JOIN users lastEditedByUser ON lastEditedByUser.id = charts.lastEditedByUserId
LEFT JOIN users publishedByUser ON publishedByUser.id = charts.publishedByUserId
LEFT JOIN analytics_pageviews on analytics_pageviews.url = CONCAT("https://ourworldindata.org/grapher/", chart_configs.slug)
JOIN chart_dimensions cd ON cd.chartId = charts.id
WHERE cd.variableId = ?
GROUP BY charts.id
Expand Down Expand Up @@ -2083,7 +2084,6 @@ getRouteWithROTransaction(
JOIN variables AS v ON cd.variableId = v.id
JOIN users lastEditedByUser ON lastEditedByUser.id = charts.lastEditedByUserId
LEFT JOIN users publishedByUser ON publishedByUser.id = charts.publishedByUserId
LEFT JOIN analytics_pageviews on analytics_pageviews.url = CONCAT("https://ourworldindata.org/grapher/", chart_configs.slug)
WHERE v.datasetId = ?
GROUP BY charts.id
`,
Expand Down Expand Up @@ -2481,7 +2481,6 @@ getRouteWithROTransaction(
LEFT JOIN chart_tags ct ON ct.chartId=charts.id
JOIN users lastEditedByUser ON lastEditedByUser.id = charts.lastEditedByUserId
LEFT JOIN users publishedByUser ON publishedByUser.id = charts.publishedByUserId
LEFT JOIN analytics_pageviews on analytics_pageviews.url = CONCAT("https://ourworldindata.org/grapher/", chart_configs.slug)
WHERE ct.tagId ${tagId === UNCATEGORIZED_TAG_ID ? "IS NULL" : "= ?"}
GROUP BY charts.id
ORDER BY charts.updatedAt DESC
Expand Down
3 changes: 1 addition & 2 deletions db/model/Chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,7 @@ export const oldChartFieldList = `
lastEditedByUser.fullName AS lastEditedBy,
charts.publishedAt,
charts.publishedByUserId,
publishedByUser.fullName AS publishedBy,
round(views_365d / 365, 1) as pageviewsPerDay
publishedByUser.fullName AS publishedBy
`
// TODO: replace this with getBySlug and pick

Expand Down

0 comments on commit 1afa5ca

Please sign in to comment.