Skip to content

Commit

Permalink
🐛 fix wp-posts-with-successors getting indexed in algolia
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Oct 30, 2023
1 parent 5a16038 commit 32ba1a8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions baker/algolia/indexToAlgolia.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,18 @@ const getPagesRecords = async () => {
const pageviews = await Pageview.getViewsByUrlObj()
const gdocs = await Gdoc.getPublishedGdocs()
const publishedGdocsBySlug = keyBy(gdocs, "slug")
const postsApi = await wpdb.getPosts(
undefined,
(post) => !publishedGdocsBySlug[`/${post.slug}`]
)
const slugsWithPublishedGdocsSuccessors =
await db.getSlugsWithPublishedGdocsSuccessors()
const postsApi = await wpdb.getPosts(undefined, (post) => {
// Two things can happen here:
// 1. There's a published Gdoc with the same slug
// 2. This post has a Gdoc successor (which might have a different slug)
// In either case, we don't want to index this WP post
return !(
publishedGdocsBySlug[post.slug] ||
slugsWithPublishedGdocsSuccessors.has(post.slug)
)
})

const countryRecords = generateCountryRecords(countries, pageviews)
const wordpressRecords = await generateWordpressRecords(postsApi, pageviews)
Expand Down

0 comments on commit 32ba1a8

Please sign in to comment.