Skip to content

Narrow a form's results to any event its submissions were made for - #2965

Merged
maebeale merged 2 commits into
mainfrom
survey-results-event-filter
Nov 8, 2026
Merged

maebeale merged 2 commits into
mainfrom
survey-results-event-filter

Conversation

@maebeale

@maebeale maebeale commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Closes #2963. Scope picked per the recommendation on that issue.

Problem

FormsController#results honored its event filter only for an event connected to the form through event_forms, and the picker offered that same set:

@selected_event_id = @form.events.where(id: params[:event_id]).pick(:id)

A standalone form has no event_forms rows, so for the surveys shared as /f/:slug?event= (#2768) and for the on-demand agreement — both of which stamp an event on the submission — the filter was dead by construction. Staff could see a training's survey responses on the registrants roster but never roll them up on their own.

Change

  • Which events — the filterable set is now the events the form's own submissions were made for (Event.where(id: @form.form_submissions.select(:event_id))), one definition shared by the picker and the param check. Standalone forms gain the filter; an event-connected form no longer offers connected events with no submissions, which only ever filtered to an empty rollup. The existing .many? gate still hides the picker for a single-event form.
  • Keeping context — the subnav's Results tab carries event_id like the Edit tabs already do, and results runs set_dashboard_event, so the event an admin arrived with survives a trip through the rollup instead of being dropped on one tab out of three.
  • Scope — any standalone form, not survey roles only: the rule that matters is "its submissions carry an event," which already covered the on-demand agreement before Associate standalone survey submissions with their event so training feedback automatically tracks on the registrants roster (#2749) #2768, so a role check would leave that one broken for no reason.

Changes

  • app/controllers/forms_controller.rb, app/helpers/forms_helper.rb, app/views/forms/results.html.erb
  • Specs: a standalone survey's rollup narrows to an event its submissions carry; the picker offers every event with submissions; no picker when every submission is event-less; an event_id with no submissions is ignored; the subnav keeps the event. Three existing filter specs now create the submissions they imply, since connected-but-empty events no longer appear.

Testing

spec/requests/forms_spec.rb (166), plus spec/helpers/forms_helper_spec.rb, spec/requests/{form_submissions,form_answers,public_forms}_spec.rb, spec/services/form_response_aggregator_spec.rb, spec/decorators/form_decorator_spec.rb — 357 examples, 0 failures. Rubocop clean.

🤖 Generated with Claude Code

maebeale and others added 2 commits November 8, 2026 10:08
The results rollup honored its event filter only for an event connected
to the form through event_forms, and the picker offered only those. A
standalone form has no event_forms rows, so for the surveys shared as
/f/:slug?event= (#2768) and the on-demand agreement — both of which stamp
an event on the submission — the filter was dead by construction: staff
could see a training's survey responses on the roster but never roll them
up on their own.

Define the filterable events as the ones the form's own submissions were
made for, one definition for the picker and the param check. Standalone
forms gain the filter, and an event-connected form no longer offers
events with nothing to show. The Results subnav tab now carries event_id
like the Edit tabs, and the results page sets @dashboard_event, so the
event an admin arrived with survives a trip through the rollup.

Closes #2963

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@maebeale

maebeale commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

Added the Features & tips seed (db/seeds/features/2026-11-08-per-event-form-results.yml, area reporting, admin-facing) in a follow-up commit, per the project rule that a staff-facing improvement ships with one.

@maebeale
maebeale merged commit 1cfdfe2 into main Nov 8, 2026
3 checks passed
@maebeale
maebeale deleted the survey-results-event-filter branch November 8, 2026 15:49
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.

Survey Results page can't be narrowed to the event a standalone survey was submitted for

1 participant