Skip to content

Fix content missing issue for "Most bookmarked" sort in workshop search#1015

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-content-missing-issue
Open

Fix content missing issue for "Most bookmarked" sort in workshop search#1015
Copilot wants to merge 2 commits intomainfrom
copilot/fix-content-missing-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 15, 2026

What is the goal of this PR and why is this important?

Fixes a customer-reported bug where searching for workshops (e.g., searching for "You") and clicking "Most bookmarked" sort resulted in a "Content missing" error. This prevented users from viewing workshops sorted by popularity, significantly impacting the search functionality.

How did you approach the change?

The root cause was in the WorkshopSearchService where the popularity sort was using COUNT(bookmarks.id) in the ORDER BY clause, which required maintaining a GROUP BY clause throughout the entire query chain. When the GROUP BY was lost during query processing, it caused SQL errors or empty results.

Changes made:

  • Updated WorkshopSearchService#order_by_params to use the pre-computed bookmarks_count column instead of COUNT(bookmarks.id) for the ORDER BY clause
  • Fixed the test in workshop_search_service_spec.rb to use the correct sort parameter "popularity" (matching what the UI sends) instead of "bookmarks"

The fix leverages the with_bookmarks_count scope that already computes the bookmarks_count column with proper aggregation at service initialization, making the query more efficient and avoiding SQL aggregation issues.

Anything else to add?

  • ✅ Code review completed - no issues found
  • ✅ Security scan (CodeQL) completed - no vulnerabilities detected
  • ✅ Test updated to match production behavior

The changes are minimal and surgical, addressing only the specific issue without modifying any other functionality.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@maebeale
Copy link
Collaborator

@copilot try again

Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 15, 2026

@copilot try again

I've fixed the issue. The problem was in the WorkshopSearchService where the "Most bookmarked" sort was using COUNT(bookmarks.id) in the ORDER BY clause, which caused SQL errors when the GROUP BY clause was lost during query processing.

The fix uses the bookmarks_count column that's already computed by the with_bookmarks_count scope, making the query more efficient and avoiding aggregation issues.

Changes in commit 8c54f21:

  • Updated ORDER BY clause to use bookmarks_count column
  • Fixed test to use correct sort parameter "popularity"

Code review and security scan completed with no issues.

Copilot AI changed the title [WIP] Fix content missing issue for bookmarked search results Fix content missing issue for "Most bookmarked" sort in workshop search Feb 15, 2026
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.

2 participants