Skip to content

Commit

Permalink
Filter out non live articles from the default related questions
Browse files Browse the repository at this point in the history
  • Loading branch information
mruwnik committed Jul 11, 2024
1 parent 3f27b92 commit 66aea84
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/server-utils/stampy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,12 @@ export const loadBanners = withCache('loadBanners', async (): Promise<Record<str

export const loadOnSiteAnswers = withCache('onSiteAnswers', async () => {
const rows = (await getCodaRows(ON_SITE_TABLE)) as AnswersRow[]
return rows.map(convertToQuestion)
const cleaned = rows.map(convertToQuestion)
const questionIds = cleaned.map((q) => q.pageid)
return cleaned.map((q) => ({
...q,
relatedQuestions: q.relatedQuestions.filter(({pageid}) => questionIds.includes(pageid)),
}))
})

export const loadAllQuestions = withCache('allQuestions', async () => {
Expand Down

0 comments on commit 66aea84

Please sign in to comment.