You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extract the events list UNION query out of EventsController #2937
EventsController builds the paginated upcoming/past events listing inside the controller: paginated_events (~80 lines) constructs a raw Arel UNION ALL across workshops, meetings, and events, plus a separate COUNT query and manual Pagy wiring, and load_events re-hydrates AR objects from the returned id/type pairs. fetch_upcoming_events and fetch_past_events are also near-duplicates of each other.
This is query logic, not HTTP coordination, and it makes the controller the largest non-admin one in the app. The repo already has app/queries/ (DashboardQuery, SponsorsSearch) — this work belongs there.
Proposed change
Move the UNION ALL construction, count, pagination, and re-hydration into a single query class, e.g. app/queries/events_feed_query.rb, with an upcoming: flag so fetch_upcoming_events / fetch_past_events collapse into one method.
Controller keeps only: parse params[:page], call the query, assign for the view.
Acceptance
EventsController#upcoming / #past are a few lines each and contain no Arel.
Existing behaviour unchanged: same ordering, grouping by date, 20 rows/page, DB-level count and pagination.
bundle exec rspec spec/controllers/events_controller_spec.rb (and the feature specs touching the events pages) pass.
Activity
davidmillen50 commentedon Oct 13, 2026
WIP #3035