Skip to content

Comments

Add workshops dropdown filter to workshop_logs index#729

Merged
maebeale merged 19 commits intomainfrom
copilot/add-workshops-dropdown-filter
Jan 31, 2026
Merged

Add workshops dropdown filter to workshop_logs index#729
maebeale merged 19 commits intomainfrom
copilot/add-workshops-dropdown-filter

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.

Asides

  • Updated ahoy tracking logic to better handle test environment
  • Change test to not use super_user anywhere, but instead use admin/admin trait
  • Change assign_pending_associations callback on workshop to only run after_create (otherwise regular update works to handle category_ids=[] and sector_ids=[]
  • Add empty category_ids=[] and sector_ids=[] ahead of checkboxes to form so it always sends something
  • Fix brittle tests by changing workshop text to gsub 'error'
  • Change unprocessable_entity to unprocessable_content
  • Turn back on assigns categories and sectors from checkboxes test
  • Move active_storage_validations gem to :test
  • Add launchy gem to avoid rspec output
  • Rearrange rails_helper and spec_helper

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 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
@maebeale maebeale force-pushed the copilot/add-workshops-dropdown-filter branch from f27598f to ee94fc8 Compare January 26, 2026 01:27
@maebeale maebeale force-pushed the copilot/add-workshops-dropdown-filter branch from 27a0354 to 93ab33a Compare January 31, 2026 16:59
@maebeale maebeale marked this pull request as ready for review January 31, 2026 17:06
@maebeale maebeale merged commit 21a9ccd into main Jan 31, 2026
3 checks passed
@maebeale maebeale deleted the copilot/add-workshops-dropdown-filter branch January 31, 2026 17:13
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