Skip to content

Commit

Permalink
refactor(wp): remove unnecessary checks (#3294)
Browse files Browse the repository at this point in the history
Remove WP API and DB checks. 

These checks are now unnecessary following the previous refactors whereby the underlying features were migrated to using the grapher DB.

When we disable the WP API and DB, these checks will disable  those same features that we actually want to keep.
  • Loading branch information
mlbrgl authored Mar 5, 2024
2 parents 9a5265e + 05175f6 commit 8d04d7a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
5 changes: 0 additions & 5 deletions adminSiteServer/mockSiteRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { getVariableData, getVariableMetadata } from "../db/model/Variable.js"
import { MultiEmbedderTestPage } from "../site/multiembedder/MultiEmbedderTestPage.js"
import { JsonError } from "@ourworldindata/utils"
import { GIT_CMS_DIR } from "../gitCms/GitCmsConstants.js"
import { isWordpressAPIEnabled } from "../db/wpdb.js"
import { EXPLORERS_ROUTE_FOLDER } from "../explorer/ExplorerConstants.js"
import { getExplorerRedirectForPath } from "../explorerAdminServer/ExplorerRedirects.js"
import { explorerUrlMigrationsById } from "../explorer/urlMigrations/ExplorerUrlMigrations.js"
Expand Down Expand Up @@ -289,10 +288,6 @@ mockSiteRouter.get("/latest/page/:pageno", async (req, res) => {
})

mockSiteRouter.get("/headerMenu.json", async (req, res) => {
if (!isWordpressAPIEnabled) {
res.status(404).send(await renderNotFoundPage())
return
}
res.contentType("application/json")
res.send(await renderMenuJson())
})
Expand Down
13 changes: 4 additions & 9 deletions baker/GrapherBaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
merge,
partition,
} from "@ourworldindata/utils"
import { isWordpressAPIEnabled, isWordpressDBEnabled } from "../db/wpdb.js"
import fs from "fs-extra"
import * as lodash from "lodash"
import { bakeGraphersToPngs } from "./GrapherImageBaker.js"
Expand Down Expand Up @@ -333,14 +332,10 @@ const renderGrapherPage = async (
) => {
const postSlug = urlToSlug(grapher.originUrl || "")
const post = postSlug ? await getPostEnrichedBySlug(postSlug) : undefined
const relatedCharts =
post && isWordpressDBEnabled
? await getPostRelatedCharts(post.id)
: undefined
const relatedArticles =
grapher.id && isWordpressAPIEnabled
? await getRelatedArticles(grapher.id, knex)
: undefined
const relatedCharts = post ? await getPostRelatedCharts(post.id) : undefined
const relatedArticles = grapher.id
? await getRelatedArticles(grapher.id, knex)
: undefined

return renderToHtmlPage(
<GrapherPage
Expand Down

0 comments on commit 8d04d7a

Please sign in to comment.