Skip to content

🎉 Country profiles in search#6094

Merged
ikesau merged 16 commits intomasterfrom
country-profiles-in-search
Mar 3, 2026
Merged

🎉 Country profiles in search#6094
ikesau merged 16 commits intomasterfrom
country-profiles-in-search

Conversation

@ikesau
Copy link
Copy Markdown
Member

@ikesau ikesau commented Feb 13, 2026

Context

Part of #5918

Figma

Screenshots / Videos / Diagrams

image image

Testing guidance

Step-by-step instructions on how to test this change

  • Indexing
    • Do profiles get indexed on (re)publish
      • Do pages that don't render (due to all invalid callouts) not get indexed
    • Do profiles get indexed by indexPagesToAlgolia
      • Do pages that don't render (due to all invalid callouts) not get indexed
    • Do profiles get the correct featured image indexed
  • Searching
    • Do country profiles show up in the results
      • When a country filter is applied and R&W is shown
      • When a country filter is applied and query text exists
      • Not when only a topic filter is applied
    • Do country profiles show up in the autocomplete
      • When a country is typed
      • When a topic is typed
    • Are clicks tracked in GA?

Checklist

Before merging

  • Google Analytics events were adapted to fit the changes in this PR
  • Changes to CSS/HTML were checked on Desktop and Mobile Safari at all three breakpoints

@owidbot
Copy link
Copy Markdown
Contributor

owidbot commented Feb 13, 2026

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-country-profiles-in-search

Archive:
SVG tester:

Number of differences (graphers): 0 ✅
Number of differences (grapher views): skipped
Number of differences (mdims): skipped
Number of differences (explorers): skipped

Edited: 2026-02-13 20:42:23 UTC
Execution time: 1.47 seconds

@ikesau ikesau force-pushed the country-profiles-in-search branch from 55d0d34 to 65df6c4 Compare February 18, 2026 22:07
@ikesau ikesau marked this pull request as ready for review February 18, 2026 22:47
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65df6c4549

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ikesau ikesau force-pushed the country-profiles-in-search branch 3 times, most recently from 865a90e to 7d5e1a7 Compare February 19, 2026 16:26
getItemUrl({ item }) {
const itemUrl = prependSubdirectoryToAlgoliaItemUrl(item)
return itemUrl
const algoliaItemTemplate: AutocompleteSource<BaseItem>["templates"] = {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lifted this out of AlgoliaSource so that it can be reused by createProfileSource

@ikesau ikesau force-pushed the country-profiles-in-search branch from 7d5e1a7 to 762fe23 Compare February 19, 2026 19:28
@ikesau ikesau requested a review from mlbrgl February 19, 2026 19:30
Copy link
Copy Markdown
Member

@mlbrgl mlbrgl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submitting partial review, still pondering over the use of extractFiltersFromQuery in Autocomplete

Besides those inline comments, we're going need some updates (either here or in #6103) to get profiles to use the new indexing pipeline (vs the markdown)


const getThumbnailUrl = (
gdoc: OwidGdocPostInterface | OwidGdocDataInsightInterface,
gdoc: OwidGdocBaseInterface,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could keep a tighter type here to benefit maintain compile type checking

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should delete profile records in deleteGdoc too

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to either add support for profiles in getPreviewGdocIndexRecords or update the message that says "not indexed" (maybe something the lines of "profiles are not supported in preview mode currently")

queryFn: (liteSearchClient, state, offset, length) => {
return queryProfiles(liteSearchClient, state, offset, length)
},
firstPageSize: 4,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this throws off the display of the topic/profile section, which should render - for instance, in the absence of articles - no more than 6 boxes (e.g. "china" + co2 now renders 8).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! Looking into this, I'm not sure it's working as intended?

I thought I could fix this issue by writing (pseudocode):


const profiles = profilesQuery(size: 2)

slotsLeft = 6 - Math.min(profiles.totalResults, 2)

const articles = articlesQuery(size: 2)

slotsLeft -= Math.min(articles.TotalResults, 2)

const topicPages = topicQuery(size: slotsLeft)

but topicPages is always fetching 6, so I think in the current (production) code, noArticles is probably not working correctly, either?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no articles are returned (e.g. "co2" + tag:china)

  • requests 2 articles (gets none) and consequently fetches 6 topic pages.

If articles are returned (e.g. "co2"), then only 2 topic pages are fetched initially, then 4.

So that works as expected as far as I can tell.

And the interleaving logic makes sure than the amount of topics vs articles is always balanced in the multi column layout (e.g. if there were 2 articles and 10 topics total for a query, then most topics would end up in the overflow).

Copy link
Copy Markdown
Member

mlbrgl commented Feb 24, 2026

nice, thanks for the integration! Nothing major but there are a couple of things we might to look at before merging.

@ikesau ikesau force-pushed the country-profiles-in-search branch from 762fe23 to 2817e33 Compare February 26, 2026 22:37
@ikesau ikesau force-pushed the country-profiles-in-search branch from 2817e33 to a14e155 Compare March 3, 2026 12:50
@ikesau ikesau force-pushed the country-profiles-in-search branch from a14e155 to 8604cc5 Compare March 3, 2026 12:59
@ikesau ikesau force-pushed the country-profiles-in-search branch from 8604cc5 to 3aaae1a Compare March 3, 2026 13:33
@ikesau
Copy link
Copy Markdown
Member Author

ikesau commented Mar 3, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d3b9d202f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return queryArticles(liteSearchClient, state, offset, length)
},
firstPageSize: 2,
firstPageSize: 4 - profileSlots,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Freeze article page sizing before running paginated query

When showProfiles is true, profileSlots is 0 on the first render, so the articles query starts with firstPageSize=4; once profiles load, firstPageSize drops (to 2/3), but the React Query key is unchanged, so the existing infinite-query pages are reused with a different offset formula. That mismatch can produce duplicated/skipped article hits on fetchNextPage and overfill the first results block whenever profiles exist.

Useful? React with 👍 / 👎.

@ikesau ikesau force-pushed the country-profiles-in-search branch from 0d3b9d2 to 1138333 Compare March 3, 2026 16:08
@ikesau ikesau merged commit 2d41222 into master Mar 3, 2026
18 of 21 checks passed
@ikesau ikesau deleted the country-profiles-in-search branch March 3, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants