Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix boosted category facet in Resource model. #750

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

richardxia
Copy link
Member

We recently added a boosted category column on the services table, with the intent of syncing it to Algolia so that we can perform special types of search ranking based on it on the frontend. However, the way we added it resulted in an obscure bug where the feature appeared to work until someone visits the edit page and saves an edit to a resource or service.

The issue is that when we set the attributesForFaceting property, we only added the boosted_category field to the Service model, not the Resource model. Since we're doing something unusual by sharing the same index for both the Service and Resource model, what actually happens is that the Resource model would sometimes override the attributesForFaceting in the Algolia index with its own list, causing that attribute to not be usable in filtering anymore.

This fixes the issue by adding the boosted_category field to Resource's list of facets. To prevent this kind of issue from happening in the future, we refactor the list of attributes for faceting into a single constant that both the Service and Resource models share.

We recently added a boosted category column on the services table, with
the intent of syncing it to Algolia so that we can perform special types
of search ranking based on it on the frontend. However, the way we added
it resulted in an obscure bug where the feature appeared to work until
someone visits the edit page and saves an edit to a resource or service.

The issue is that when we set the `attributesForFaceting` property, we
only added the `boosted_category` field to the Service model, not the
Resource model. Since we're doing something unusual by sharing the same
index for both the Service and Resource model, what actually happens is
that the Resource model would sometimes override the
`attributesForFaceting` in the Algolia index with its own list, causing
that attribute to not be usable in filtering anymore.

This fixes the issue by adding the `boosted_category` field to
Resource's list of facets. To prevent this kind of issue from happening
in the future, we refactor the list of attributes for faceting into a
single constant that both the Service and Resource models share.
Copy link
Contributor

@schroerbrian schroerbrian left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@richardxia richardxia merged commit 6956c8c into master Aug 22, 2024
4 checks passed
@richardxia richardxia deleted the fix-boosted-category-facet-in-resource-model branch August 22, 2024 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants