Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

/events/past: 33 queries and ~466ms median per render

已关闭
#2,887 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
rails, ruby

调研方向

首先重新测量 GET /events/past,并通过 paginated_events、load_events、fetch_past_events、EventPresenter.decorate_collection 和 EventCardComponent.with_collection 跟踪 EventsController#past。捕获装饰和渲染期间的查询,然后验证查询数量和中位耗时有所改善,同时 UNION 顺序和 ETag 行为保持不变;将结果与 #2888 进行比较。

由索引模型根据 Issue 内容生成。

描述

performance

Summary

GET /events/past (EventsController#past) takes a median 466ms per render (max 17.3s) and issues 33 queries (median db_runtime 80ms, view_runtime 118ms). The action sets an ETag via fresh_when, so conditional requests are cheap, but non-conditional clients (first visit, stale cache, most API clients) pay the full render every time.

The render path:

  1. paginated_events runs a UNION ALL across Workshops, Meetings, and Events, counts at the DB level, and returns only the 20 rows for the current page
  2. load_events runs three eager_load queries (workshops, meetings, events) for those rows
  3. fetch_past_events groups the rows by date and wraps each in a presenter (EventPresenter.decorate_collection)
  4. The view renders EventCardComponent.with_collection — each card is fragment-cached (event_card_component/* keys in Solid Cache)

33 queries is well over the handful that steps 1–2 need, so something in decoration or rendering loads associations the current eager loads don't cover.

Measured

3h window on 2026-09-16/17, from production canonical logs: 127 requests, median 466ms, max 17.3s. Stale by the time you read this — re-measure before starting.

Suggested directions

  1. Capture the 33 queries locally (Bullet or Prosopite against a production dump) and identify the associations touched during decoration and card rendering beyond the current eager_load calls
  2. Add the missing associations to the eager loads or batch them into a single preload, preserving the UNION order
  3. Check the hit rate on the per-event fragments before adding more caching — they may already absorb most of the view time

Verify

Query count and median duration drop; ETag behaviour unchanged.

Related

  • #2888 — the sibling /events/upcoming action, same code path; share findings
  • #2885 — same measurement window
主要语言
Ruby
星标
104
派生
205
平均合并
1 天 8 小时
30 天内合并 PR
67

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

codebar/planner 的其他 Issue

查看 codebar/planner 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。