Skip to content

Convert monthly reports to standard REST with shared filters#1530

Merged
maebeale merged 7 commits into
mainfrom
maebeale/monthly-reports-index
May 26, 2026
Merged

Convert monthly reports to standard REST with shared filters#1530
maebeale merged 7 commits into
mainfrom
maebeale/monthly-reports-index

Conversation

@maebeale
Copy link
Copy Markdown
Collaborator

@maebeale maebeale commented May 25, 2026

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

  • Making progress toward MonthlyReport being standalone instead of Report STI
  • Standardize monthly reports to use the same REST conventions and filtered-index UX that workshop logs already use, so the two report types feel like siblings rather than parallel ad-hoc flows.
  • Reduce duplication between MonthlyReport and WorkshopLog by extracting their shared model behavior into a Reportable concern.

How did you approach the change?

  • Rewrote MonthlyReportsController against standard REST actions (index, show) and gave it a search/filter index that mirrors WorkshopLogsController: month/year, workshop, person, organization.
  • Added the index/results/skeleton/search-boxes/quotable partials to match the workshop log UX.
  • Extracted shared Report model behavior (associations, scopes, nested attrs, search, etc.) into app/models/concerns/reportable.rb, included by both MonthlyReport and the base Report.
  • Removed monthly_reports/edit.html.erb since the new REST flow doesn't surface MR editing here.
  • Updated routes: standard resources :monthly_reports, only: [ :index, :show ], plus a nested index under organizations. Dropped the legacy reports/monthly* routes.
  • Preserved the previous controller as monthly_reports_controller_old.rb for reference during the cutover — will be removed once we're confident the new flow covers all legacy entry points.
  • Beefed up the dummy dev seeds so the new index page has realistic data: ~89 monthly reports for Aisha (30 + a tapering tail), 5 for the admin, with form-field answers, occasional sectors, and occasional quotes.

UI Testing Checklist

  • /monthly_reports index renders and lists reports
  • Filters (month, year, workshop, person, organization) narrow results correctly
  • Clearing filters returns the full list
  • /monthly_reports/:id show renders for an existing report
  • Organization show page links to MR index filtered by org
  • Non-admin access matches policy (admin-or-auth)

Anything else to add?

  • The _old controller file is intentionally committed for the cutover and will be deleted in a follow-up once the legacy entry points are confirmed dead.
  • Follow-up PR will add the matching cross-model search additions (community_news, stories, event_registrations, story_ideas) and the organization "associated records" panel that links to all of these.

maebeale and others added 7 commits May 25, 2026 16:11
Refactors the MR controller to use standard REST resources and matches the
filter UX (month/year/workshop/person/organization) the workshop log index
already uses, so the two report types feel like siblings rather than
parallel ad-hoc flows. Extracts shared Report behaviors into a Reportable
concern that both MonthlyReport and WorkshopLog include, removing the
duplication that had built up between them. Old controller kept as
monthly_reports_controller_old.rb for reference during the cutover.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Prep work for retiring Report. MonthlyReport still inherits from Report
(STI dispatch is needed for polymorphic refs like sectorable_type='Report'),
but now declares its own associations, scopes, and methods so it can stand
on its own when Report goes away.

Dropped pieces that don't apply to MR:
- workshop (0/11,316 in prod)
- has_one :form / has_many :form_fields, through: :form (owner-based, unused)
- has_many :media_files (already converted to GalleryAsset)
- accepts_nested_attributes_for :primary_asset (unused)
- story? helper, form_builder / on_going_participants / new_participants
  (only used internally, dead once we stopped creating MRs)

Simplified users_admin_type to the MR-only branch, name to literal "Monthly
Report ##{id}".

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The _old file was a reference copy added during the REST refactor and is
no longer used. Removing it also clears the only remaining brakeman warning
(Mass Assignment via `params[:quotes].permit!`).

Drops the two obsolete brakeman.ignore entries that pointed at code that
no longer exists.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Reverts the file to its prior state at maebeale's request.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Keeps the pre-REST-refactor controller around for reference without
triggering Brakeman (which only scans .rb). Mirrors the original
snapshot header that pointed at commit f96a98a.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Report and MonthlyReport both define associations/scopes inline, so the
concern has no remaining includers.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
These were dropped during the REST refactor but are still referenced
by the participant-total aggregations on the index. Placed near the
bottom of the public methods so the canonical attribute readers stay
toward the top.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@maebeale maebeale marked this pull request as ready for review May 26, 2026 02:05
@maebeale maebeale merged commit 04157da into main May 26, 2026
3 checks passed
@maebeale maebeale deleted the maebeale/monthly-reports-index branch May 26, 2026 02:08
maebeale added a commit that referenced this pull request May 26, 2026
* Match WindowsType seed names to production (title case)

Production WindowsType records are stored with simple title-case names —
"Adult", "Children", "Combined" — but our seeds and factory were still
using the older verbose all-caps forms ("ADULT WINDOWS", etc.) that no
longer exist anywhere. That mismatch silently broke any code that looked
up a WindowsType by name (e.g. the workshop_variations form's "Combined"
default), and made the bookmarks_controller LIKE-match for "%COMBINED%"
unnecessarily fragile.

Aligns the seed/factory names with production and switches the bookmarks
LIKE query to a direct equality exclusion now that the name is a stable
single word. A matching tweak to reportable.rb's form_builder lookup
will follow once #1530 merges.

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

* Update report.rb and bookmark.rb to match new WindowsType names

Report#form_builder and Bookmark.windows_type were still comparing
against the older verbose names ("ADULT WORKSHOP LOG", "ADULT WORKSHOP",
etc.) that no longer exist on any WindowsType record. Both have been
silently broken — form_builder returned nil for every MonthlyReport, and
the bookmark windows_type filter returned no matches.

Updates both to use the title-case single-word names. Bookmark's filter
also switches from a case-sensitive LIKE pattern to direct equality now
that the name is a stable single word.

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

* Retrigger CI to check workshop_variations_spec failure stability

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.

1 participant