Replace `projects_autocomplete` with `SearchService` in `search_helper.rb` to fix timeout issues
## Summary `projects_autocomplete` in `app/helpers/search_helper.rb` runs direct database queries via `current_user.authorized_projects`, which can cause timeouts for users with many authorized projects. `users_autocomplete` was already migrated to use `SearchService` (which uses Advanced Search/Elasticsearch when available, falling back to PostgreSQL), giving it better scalability. `projects_autocomplete` should be updated the same way. ## Current behavior `projects_autocomplete` (line 472) runs: ```ruby def projects_autocomplete(term, limit = 5) projects = current_user.authorized_projects.order_id_desc.search( term, include_namespace: true, use_minimum_char_limit: false ).sorted_by_stars_desc.self_and_ancestors_non_archived.limit(limit) ... end ``` This always hits PostgreSQL directly, regardless of whether Advanced Search is enabled. For users with thousands of authorized projects, this query can time out. ## Desired behavior Replace `projects_autocomplete` with a `SearchService`-based implementation, mirroring `users_autocomplete`: ```ruby def users_autocomplete(term, limit = 5) # ... search_using_search_service(current_user, 'users', term, limit, { autocomplete: true }).map do |user| ... end end ``` The `search_using_search_service` helper (line 717) already wraps `SearchService` and returns results using Elasticsearch/OpenSearch when available, falling back to PostgreSQL otherwise. ## Implementation notes - Replace the body of `projects_autocomplete` to use `search_using_search_service(current_user, 'projects', term, limit, { autocomplete: true })` - Verify that `SearchService` with scope `'projects'` respects the same authorization constraints as `current_user.authorized_projects` - Check if a feature flag guard is needed (similar to `global_search_users_enabled?` for users) - Update/add specs in `spec/helpers/search_helper_spec.rb` ## References - `users_autocomplete` implementation: `app/helpers/search_helper.rb:491` - `projects_autocomplete` implementation: `app/helpers/search_helper.rb:472` - `search_using_search_service` helper: `app/helpers/search_helper.rb:717`
issue