Skip to content

Commit

Permalink
🐛 only index explorer views that have viewTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Sep 10, 2024
1 parent 1377c80 commit 50326c6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions baker/algolia/indexExplorerViewsToAlgolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { getAlgoliaClient } from "./configureAlgolia.js"
import { getIndexName } from "../../site/search/searchClient.js"
import { SearchIndexName } from "../../site/search/searchTypes.js"
import { groupBy, keyBy, orderBy } from "lodash"
import { groupBy, keyBy, orderBy, partition } from "lodash"
import { MarkdownTextWrap } from "@ourworldindata/components"
import { DbRawVariable } from "@ourworldindata/utils"
import { logErrorAndMaybeSendToBugsnag } from "../../serverUtils/errorLog.js"
Expand Down Expand Up @@ -118,7 +118,7 @@ const getExplorerViewRecordsForExplorerSlug = async (

const defaultSettings = explorerDecisionMatrix.defaultSettings

let records = explorerDecisionMatrix
const records = explorerDecisionMatrix
.allDecisionsAsQueryParams()
.map((choice, i) => {
explorerDecisionMatrix.setValuesFromChoiceParams(choice)
Expand Down Expand Up @@ -270,11 +270,11 @@ const getExplorerViewRecordsForExplorerSlug = async (
}

// Drop any views where we couldn't obtain a title, for whatever reason
records = records.filter((record) => record.viewTitle !== undefined)

const recordsWithNoViewTitle = records.filter(
(record) => record.viewTitle === undefined
const [recordsWithViewTitle, recordsWithNoViewTitle] = partition(
records,
(record) => record.viewTitle !== undefined
)

for (const record of recordsWithNoViewTitle) {
await logErrorAndMaybeSendToBugsnag({
name: "ExplorerViewTitleMissing",
Expand All @@ -283,7 +283,7 @@ const getExplorerViewRecordsForExplorerSlug = async (
}

// Remove Markdown from viewSubtitle; do this after fetching grapher info above, as it might also contain Markdown
const recordsWithTitleLength = records.map((record) => {
const recordsWithTitleLength = recordsWithViewTitle.map((record) => {
if (record.viewSubtitle) {
record.viewSubtitle = new MarkdownTextWrap({
text: record.viewSubtitle,
Expand Down

0 comments on commit 50326c6

Please sign in to comment.