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

Adding slots runs two queries per slot

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
sql, typescript
领域
backend, database

调研方向

Start with the three loops in addSlot, addSlotsBulk and createSignup, plus extractSlotAt and pickAvailableRef, and check how the signup lock is held. The work depends on #372 (withSignupWriteLock), so confirm that lands first. Done means a 500-row bulk add runs a fixed number of statements, pinned by a test, while slots.db.test.ts, signups.db.test.ts and the MCP tools.db.test.ts pass, and docs/telemetry.md reflects the new activity payload.

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

描述

enhancement

What happens

addSlot, addSlotsBulk and createSignup each loop over the rows. For each row they:

  1. run extractSlotAt
  2. run pickAvailableRef, which does a SELECT per attempt
  3. do a one-row INSERT

That is about 2N statements for N slots. A 500-row bulk add, or an add_slots call of that size, runs about 1,000, all while holding the signup lock.

createSignup also inserts its fields one at a time. The three loops are nearly the same code.

Fix, in outline

  • One insertSlots(tx, signup, fields, rows) that:

    • reads the signup's existing refs once
    • picks the new refs in memory
    • does one multi-row INSERT

    Every caller already holds the signup lock, or owns a signup nobody else can see yet. The slots_ref_unique constraint stays as the safety net.

  • addSlot becomes a thin call into the bulk path, keeping its capacity default of 1.

  • createSignup inserts its fields in one statement.

  • Use the ids made in code, not the order RETURNING gives back, for the beforeSlotId splice.

Watch for

  • A single add's activity payload becomes the bulk shape, { count, bulk: true, slotIds }. Nothing reads it, but docs/telemetry.md describes both shapes (after #356), so update it.
  • The format of the ref suffix may change. Refs are internal and never shown.

Order

After #372, which adds withSignupWriteLock.

Done when

  • A 500-row bulk add runs a fixed number of statements, pinned by a test.
  • slots.db.test.ts, signups.db.test.ts and the MCP tools.db.test.ts pass.
  • pnpm lint && pnpm typecheck && pnpm knip && pnpm test && pnpm test:db pass.
主要语言
TypeScript
星标
19
派生
4
平均合并
23 小时 28 分钟
30 天内合并 PR
173

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

richshaw/OpenSignup 的其他 Issue

查看 richshaw/OpenSignup 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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