Extract the events list UNION query out of EventsController
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Read EventsController and compare the existing app/queries/DashboardQuery and app/queries/SponsorsSearch patterns. Start with spec/controllers/events_controller_spec.rb and the feature specs touching the events pages; done means the controller has no Arel, behavior remains unchanged, and the specified specs pass.
由索引模型根据 Issue 内容生成。
描述
Problem
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 anupcoming:flag sofetch_upcoming_events/fetch_past_eventscollapse into one method. - Controller keeps only: parse
params[:page], call the query, assign for the view.
Acceptance
EventsController#upcoming/#pastare 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.
- 主要语言
- Ruby
- 星标
- 106
- 派生
- 208
- 平均合并
- 19 小时 31 分钟
- 30 天内合并 PR
- 84
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
codebar/planner 的其他 Issue
-
DashboardQuery eager-loads workshop_host with :sponsors in one join (same host-loss trap as #2975)未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
Dual Invitiation issue可能已有人在做 @mroderick 于 3 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 42/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 28/100
codebar/planner#3008 · 2 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
Windows: packaged_agent_ruby? never matches 'Puppet Labs\Puppet', so the openvox gem is not found未关闭
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 85/100
temporalio/sdk-ruby#625 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 94/100
zerocracy/judges-action#2803 ·
维护者通常 5 天内回复
-
empty tone.rb未关闭
难度 1/5 1 小时以内 新手友好度 78/100