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

refactor(leaderboard): split recompute-all-skills.ts, 210 LOC over the 200 LOC limit

未关闭 适合新手
#27 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
backend

调研方向

先阅读 apps/web/app/lib/leaderboard/recompute-all-skills.ts,尤其是第 31 行的 recomputeBatch,以及大约从第 139 行开始的逐 skill 循环。将该循环提取到一个专注的 helper 中,不要重复 scoring 函数,然后使用 wc -l 验证每个生成的文件都少于 200 行,同时保留 batch 编排和返回行为。

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

描述

refactor

Summary

apps/web/app/lib/leaderboard/recompute-all-skills.ts is 210 lines, above the 200 LOC per-file limit in the project conventions. The bulk recompute path is the only leaderboard module over that limit.

Evidence

  • wc -l apps/web/app/lib/leaderboard/recompute-all-skills.ts → 210
  • CLAUDE.md, section "Important Caveats": "Max 200 LOC per file — split into focused modules if exceeded."
  • The code review measured 243 lines before the N+1 rework; the file is still over the limit after that change, so the rework reduced but did not resolve it.
  • Neighbouring modules for comparison: apps/web/app/routes/api.admin.recompute.ts is 131 lines and apps/web/app/lib/leaderboard/recompute-skill-scores.ts is a separate single-skill path.

Expected behavior

Split the module so each file stays under 200 lines. The per-skill compute-and-update loop (roughly lines 139-176, from for (const skill of batch) through the db.update(...) call) is the natural extraction, leaving recomputeBatch responsible for offset resolution, state persistence, and the return value.

Flow

flowchart LR
  A[recomputeBatch] --> B[resolve offset from KV]
  B --> C[global stats + batch fetch]
  C --> D[per-skill compute loop 210 LOC total]
  D --> E[persist KV state]

The loop labelled D is the extraction candidate; everything else is batch orchestration.

Evidence

  • Affected code: apps/web/app/lib/leaderboard/recompute-all-skills.ts:31 (recomputeBatch), apps/web/app/lib/leaderboard/recompute-all-skills.ts:139 (start of the per-skill loop)
  • Related: plans/reports/code-reviewer-260306-1531-admin-recompute-endpoint.md, section "5. recompute-all-skills.ts exceeds 200 LOC limit"

Open questions

  • Should the extracted helper move to a new recompute-skill-update.ts, or should the aggregate fetch block be the part that moves instead?

Notes

  • The extraction is mechanical and behavior-preserving. The scoring functions in leaderboard-scoring.ts are already shared with the single-skill path, so the split should not duplicate scoring logic.
主要语言
TypeScript
星标
189
派生
40
平均合并
6 小时 54 分钟
30 天内合并 PR
24

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

nextlevelbuilder/skillx 的其他 Issue

查看 nextlevelbuilder/skillx 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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