Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐝 remove entries-by-years code #3785

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions adminSiteServer/mockSiteRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
renderChartsPage,
renderSearchPage,
renderDonatePage,
entriesByYearPage,
makeAtomFeed,
feedbackPage,
renderNotFoundPage,
Expand Down Expand Up @@ -118,19 +117,6 @@ getPlainRouteNonIdempotentWithRWTransaction(
}
)

getPlainRouteWithROTransaction(
mockSiteRouter,
"/entries-by-year",
async (req, res, trx) => res.send(await entriesByYearPage(trx))
)

getPlainRouteWithROTransaction(
mockSiteRouter,
`/entries-by-year/:year`,
async (req, res, trx) =>
res.send(await entriesByYearPage(trx, parseInt(req.params.year)))
)

mockSiteRouter.get(
"/grapher/data/variables/data/:variableId.json",
async (req, res) => {
Expand Down
35 changes: 0 additions & 35 deletions baker/SiteBaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
renderChartsPage,
renderSearchPage,
renderDonatePage,
entriesByYearPage,
makeAtomFeed,
feedbackPage,
renderNotFoundPage,
Expand Down Expand Up @@ -77,7 +76,6 @@ import {
getFullPost,
getPostsFromSnapshots,
postsFlushCache,
postsTable,
} from "../db/model/Post.js"
import { GdocPost } from "../db/model/Gdoc/GdocPost.js"
import { Image, getAllImages } from "../db/model/Image.js"
Expand Down Expand Up @@ -125,7 +123,6 @@ const wordpressSteps = [
"assets",
"blogIndex",
"embeds",
"googleScholar",
"redirects",
"rss",
"wordpressPosts",
Expand Down Expand Up @@ -290,7 +287,6 @@ export class SiteBaker {
!path.startsWith("countries") &&
!path.startsWith("country") &&
!path.startsWith("latest") &&
!path.startsWith("entries-by-year") &&
!path.startsWith("explore") &&
!countryProfileSpecs.some((spec) =>
path.startsWith(spec.rootPath)
Expand Down Expand Up @@ -925,36 +921,6 @@ export class SiteBaker {
this.progressBar.tick({ name: "✅ baked author pages" })
}

// Pages that are expected by google scholar for indexing
private async bakeGoogleScholar(trx: db.KnexReadonlyTransaction) {
if (!this.bakeSteps.has("googleScholar")) return
await this.stageWrite(
`${this.bakedSiteDir}/entries-by-year.html`,
await entriesByYearPage(trx)
)

const rows = (await trx
.table(postsTable)
.where({ status: "publish" })
.whereNot({ type: "wp_block" })
.join("post_tags", { "post_tags.post_id": "posts.id" })
.join("tags", { "tags.id": "post_tags.tag_id" })
.where({ "tags.name": "Entries" })
.select(trx.raw("distinct year(published_at) as year"))
.orderBy("year", "DESC")) as { year: number }[]

const years = rows.map((r) => r.year)

for (const year of years) {
await this.stageWrite(
`${this.bakedSiteDir}/entries-by-year/${year}.html`,
await entriesByYearPage(trx, year)
)
}

this.progressBar.tick({ name: "✅ baked google scholar" })
}

// Bake the blog index

// TODO: this transaction is only RW because somewhere inside it we fetch images
Expand Down Expand Up @@ -1073,7 +1039,6 @@ export class SiteBaker {
await this.bakeBlogIndex(knex)
await this.bakeRSS(knex)
await this.bakeAssets(knex)
await this.bakeGoogleScholar(knex)
await this.bakePosts(knex)
}

Expand Down
39 changes: 0 additions & 39 deletions baker/siteRenderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ import {
BAKED_GRAPHER_EXPORTS_BASE_URL,
RECAPTCHA_SITE_KEY,
} from "../settings/clientSettings.js"
import {
EntriesByYearPage,
EntriesForYearPage,
} from "../site/EntriesByYearPage.js"
import { FeedbackPage } from "../site/FeedbackPage.js"
import {
getCountryBySlug,
Expand All @@ -48,7 +44,6 @@ import {
OwidGdocType,
OwidGdoc,
OwidGdocDataInsightInterface,
DbRawPost,
} from "@ourworldindata/utils"
import { extractFormattingOptions } from "../serverUtils/wordpressUtils.js"
import { FormattingOptions, GrapherInterface } from "@ourworldindata/types"
Expand Down Expand Up @@ -83,7 +78,6 @@ import {
getFullPostByIdFromSnapshot,
getFullPostBySlugFromSnapshot,
isPostSlugCitable,
postsTable,
} from "../db/model/Post.js"
import { GdocPost } from "../db/model/Gdoc/GdocPost.js"
import { logErrorAndMaybeSendToBugsnag } from "../serverUtils/errorLog.js"
Expand Down Expand Up @@ -501,39 +495,6 @@ ${dataInsights
</feed>`
}

// These pages exist largely just for Google Scholar
export const entriesByYearPage = async (
trx: KnexReadonlyTransaction,
year?: number
) => {
const entries = (await trx
.table(postsTable)
.where({ status: "publish" })
.whereNot({ type: "wp_block" })
.join("post_tags", { "post_tags.post_id": "posts.id" })
.join("tags", { "tags.id": "post_tags.tag_id" })
.where({ "tags.name": "Entries" })
.select("title", "posts.slug", "published_at")) as Pick<
DbRawPost,
"title" | "slug" | "published_at"
>[]

// TODO: include topic pages here once knex refactor is done

if (year !== undefined)
return renderToHtmlPage(
<EntriesForYearPage
entries={entries}
year={year}
baseUrl={BAKED_BASE_URL}
/>
)

return renderToHtmlPage(
<EntriesByYearPage entries={entries} baseUrl={BAKED_BASE_URL} />
)
}

export const feedbackPage = () =>
renderToHtmlPage(<FeedbackPage baseUrl={BAKED_BASE_URL} />)

Expand Down
157 changes: 0 additions & 157 deletions site/EntriesByYearPage.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions site/owid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,7 @@ html:not(.js) {
}
}

.ChartsIndexPage main,
.EntriesByYearPage main {
.ChartsIndexPage main {
padding-top: 0;
padding-bottom: 0;

Expand Down