Skip to content

Commit

Permalink
✨ code review enhancements for algolia indexing on publish
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Apr 9, 2024
1 parent 0fbe3b2 commit 3854a91
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions adminSiteClient/gdocsDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export enum GdocPublishingAction {
Updating = "Updating",
Publishing = "Publishing",
Unpublishing = "Unpublishing",
Saving = "Saving",
SavingDraft = "SavingDraft",
}

export function getPublishingAction(
Expand All @@ -199,6 +199,6 @@ export function getPublishingAction(
.with([true, true], () => GdocPublishingAction.Updating)
.with([false, true], () => GdocPublishingAction.Publishing)
.with([true, false], () => GdocPublishingAction.Unpublishing)
.with([false, false], () => GdocPublishingAction.Saving)
.with([false, false], () => GdocPublishingAction.SavingDraft)
.exhaustive()
}
4 changes: 2 additions & 2 deletions adminSiteServer/apiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2295,7 +2295,7 @@ getRouteNonIdempotentWithRWTransaction(

/**
* Handles all four `GdocPublishingAction` cases
* - Saving (no action)
* - SavingDraft (no action)
* - Publishing (index and bake)
* - Updating (index and bake (potentially via lightning deploy))
* - Unpublishing (remove from index and bake)
Expand All @@ -2313,7 +2313,7 @@ async function indexAndBakeGdocIfNeccesary(
const isGdocPost = checkIsGdocPostExcludingFragments(nextJson)

await match(action)
.with(GdocPublishingAction.Saving, lodash.noop)
.with(GdocPublishingAction.SavingDraft, lodash.noop)
.with(GdocPublishingAction.Publishing, async () => {
if (isGdocPost) {
await indexIndividualGdocPost(nextJson, trx, prevGdoc.slug)
Expand Down
2 changes: 1 addition & 1 deletion baker/algolia/algoliaUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export async function indexIndividualGdocPost(
const records = generateGdocRecords([gdoc], pageviewsForGdoc)

const existingRecordsForPost: ObjectWithObjectID[] =
await getExistingRecordsForSlug(index, gdoc.slug)
await getExistingRecordsForSlug(index, indexedSlug)

try {
console.log("Updating Algolia index for Gdoc post", gdoc.slug)
Expand Down

0 comments on commit 3854a91

Please sign in to comment.