refactor(leaderboard): split recompute-all-skills.ts, 210 LOC over the 200 LOC limit
维护者通常 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 内容生成。
描述
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→210CLAUDE.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.tsis 131 lines andapps/web/app/lib/leaderboard/recompute-skill-scores.tsis 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.tsexceeds 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.tsare 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,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nextlevelbuilder/skillx 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
nextlevelbuilder/skillx#49 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
nextlevelbuilder/skillx#28 ·
维护者通常 1 天内回复
-
Harden personal kit proposal scanning before enabling the API flag可能已有人在做 @mrgoonie 于 1 天前认领。 未关闭
nextlevelbuilder/skillx#86 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 18/100
nextlevelbuilder/skillx#84 ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 12/100
nextlevelbuilder/skillx#81 ·
维护者通常 1 天内回复
查看 nextlevelbuilder/skillx 的全部 Issue
相似的 Issue
-
area:ui effort:S enhancement priority:P2
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
QuantumNous/new-api#7839 ·
维护者通常 1 天内回复
-
good first issue maintenance
难度 2/5 1-3 小时 新手友好度 62/100
dark-princezz/stellar-hooks#1010 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
interledger/rhyza#352 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复