Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 20, 2026

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

Enable filtering workshop logs by workshop without degrading page performance. The original attempt used Workshop.joins(:workshop_logs) which joined all workshop logs regardless of user permissions or active filters, causing slow queries.

How did you approach the change?

Changed query strategy from JOIN to subquery:

# Before: joins all workshop_logs in database
Workshop.joins(:workshop_logs).order(:title)

# After: selects only from already-filtered logs
Workshop.where(id: @workshop_logs_unpaginated.select(:workshop_id).distinct)
        .order(:title)

This approach:

  • Leverages existing index on reports.workshop_id
  • Respects permission filters already applied to @workshop_logs_unpaginated
  • Scales with filtered result size, not total database size
  • Works seamlessly with existing filters (month, year, facilitator, organization)

View changes:

  • Added workshop dropdown between Year and Facilitator filters
  • Auto-submits on selection change
  • Follows existing filter pattern and styling

Test coverage:

  • Index page loads successfully
  • Filtering by workshop_id parameter works correctly
  • Workshop dropdown populates from visible logs only

Anything else to add?

The WorkshopLog model already had the workshop_id scope and search method support, so only the controller query and view needed changes. No migrations or new dependencies required.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add workshops dropdown/filter on /workshop_logs</issue_title>
<issue_description>I had it rigged up but the db must be missing an index or something bc it makes the page perform pretty slowly</issue_description>

<agent_instructions>find a lightweight way to add a workshops dropdown to workshop_logs without crushing the performance of the workshop_logs index.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@maebeale @copilot find a lightweight way to add a workshops dropdown to workshop_logs without crushing the performance of the workshop_logs index.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 20, 2026 00:48
Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
Co-authored-by: maebeale <7607813+maebeale@users.noreply.github.com>
Copilot AI changed the title [WIP] Add workshops dropdown filter on /workshop_logs Add workshops dropdown filter to workshop_logs index Jan 20, 2026
Copilot AI requested a review from maebeale January 20, 2026 00:55
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.

Add workshops dropdown/filter on /workshop_logs

2 participants