rubyforgood / rubyforgood/awbw
Deduplicate the registrant CSV row builder (events vs event_registrations exports)
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 15
- Forks
- 26
- Avg merge
- 12h 42m
- Merged PRs (30d)
- 242
Description
🤖 From Claude: follow-up noted during the events-IA refactor (PR #2113); out of scope there.
Summary
Two controllers build essentially the same per-registrant CSV row from scratch:
EventsController#event_registration_csv_row(app/controllers/events_controller.rb, ~L876) — the per-event Manage roster export.Events::EventRegistrationsController#csv_export(app/controllers/event_registrations_controller.rb, ~L365) — the cross-event registrations export.
Both emit the same columns — first name, last name, email, phone, org(s), scholarship (yes/no), scholarship completed, payment status, intends to pay, payment total, and CE status/paid/due — with only minor differences:
- The cross-event export adds an Event column and uses
attendance_status_label; the per-event one omits Event and gates payment oncost_required. - Org names: the per-event builder derives active-affiliation org names in Ruby; the cross-event one omits orgs.
- CE columns are always present cross-event; conditional (
include_ce) per-event.
They share csv_dollars, allocations_sum, scholarships.any?, payment_status_label, etc. — so the cell logic is duplicated and can drift (a change to how, say, scholarship-completed or CE-due is computed must be made in both).
Proposed approach
Extract a single row/column builder (e.g. an EventRegistrationCsvRow PORO or a shared concern) that takes an EventRegistration plus options (include_event_column:, include_ce:, cost_required:) and returns the header + row. Both controllers call it. Keep the two call sites' column-set differences as explicit options rather than divergent implementations.
Tasks
- Extract the shared header + row builder.
- Point both controllers at it (preserving each export's current columns exactly).
- Spec the builder directly; keep the existing controller CSV request specs green (byte-for-byte output unchanged).
Out of scope
- No new columns or format changes — pure dedup.
References
- PR #2113 — the events-IA refactor that surfaced this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with EventsController#event_registration_csv_row in app/controllers/events_controller.rb and Events::EventRegistrationsController#csv_export in app/controllers/event_registrations_controller.rb. Compare their headers and row logic, then review the existing controller CSV request specs before choosing the shared builder shape. Done means both controllers use the builder, a direct builder spec covers its options, and existing CSV output remains byte-for-byte unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100