Skip to content

Commit

Permalink
🔨 sync not just wp pages and posts but also wp_blocks
Browse files Browse the repository at this point in the history
This is mostly to unify the behaviour of syncPostsToGrapher
and postUpdateHook
  • Loading branch information
danyx23 committed Dec 15, 2023
1 parent c9ba44b commit 95c42a6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions baker/SiteBaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ export class SiteBaker {
const rows = (await db
.knexTable(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" })
Expand Down
1 change: 1 addition & 0 deletions baker/siteRenderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ ${posts
export const entriesByYearPage = async (year?: number) => {
const entries = (await knexTable(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" })
Expand Down
2 changes: 1 addition & 1 deletion db/syncPostsToGrapher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const syncPostsToGrapher = async (): Promise<void> => {
left join post_ids_with_authors pwa on p.ID = pwa.ID
left join first_revision fr on fr.post_id = pwa.ID
left join post_featured_image fi on fi.ID = p.id
where p.post_type in ('post', 'page') AND post_status != 'trash'
where p.post_type in ('post', 'page', 'wp_block') AND post_status != 'trash'
`
)

Expand Down
1 change: 1 addition & 0 deletions db/wpdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ export const getRelatedResearchAndWritingForVariable = async (
and cd.variableId = ?
and cd.property in ('x', 'y') -- ignore cases where the indicator is size, color etc
and p.status = 'publish' -- only use published wp posts
and p.type != 'wp_block'
and coalesce(pg.published, 0) = 0 -- ignore posts if the wp post has a published gdoc successor. The
-- coalesce makes sure that if there is no gdoc successor then
-- the filter keeps the post
Expand Down

0 comments on commit 95c42a6

Please sign in to comment.