diff --git a/packages/core/src/ready-digest.ts b/packages/core/src/ready-digest.ts index f09f4a5c..9a15ebe5 100644 --- a/packages/core/src/ready-digest.ts +++ b/packages/core/src/ready-digest.ts @@ -10,11 +10,14 @@ import { formatTaskKey } from "@peppa/shared"; import { questionType, type MessageType } from "./questions.ts"; import { getSetting, setSetting } from "./settings.ts"; import { COMMENT_EVENT } from "./tasks.ts"; +import { splitParent } from "./task-decisions.ts"; -/** Does a person wait for this story (its «готово» goes at once)? */ -export async function taskAwaited(db: Db, taskId: number): Promise { +/** Does a person wait for this story (its «готово» goes at once)? A part of a split — when its first story is awaited. */ +export async function taskAwaited(db: Db, taskId: number, depth = 0): Promise { const [t] = await db.select({ origin: tasks.origin }).from(tasks).where(eq(tasks.id, taskId)); if (!t || t.origin === "human") return true; + const parent = depth < 3 ? await splitParent(db, taskId) : null; + if (parent && (await taskAwaited(db, parent, depth + 1))) return true; const [e] = await db .select({ id: events.id }) .from(events) diff --git a/packages/testkit/test/one-analyst.test.ts b/packages/testkit/test/one-analyst.test.ts index 1bf06305..8d081f26 100644 --- a/packages/testkit/test/one-analyst.test.ts +++ b/packages/testkit/test/one-analyst.test.ts @@ -124,6 +124,10 @@ describe("Готовые задачи сводкой", () => { // A comment makes the owner wait for the story: its «готово» goes at once. await core.addStoryComment(db, await core.resolveTask(db, a.key), owner, "Жду это"); assert.equal(await heldForDigest(db, open.find((q) => q.taskId === a.task.id)!, "review"), false); + // A part of a split of the owner's own story is awaited like the story itself. + const part = await core.createTask(db, { projectId: p.id, title: "Часть разбивки", origin: "analyst" }); + await core.markSplitPart(db, part.task.id, human.task.id); + assert.equal(await core.taskAwaited(db, part.task.id), true); delete process.env.PEPPA_READY_DIGEST; }); });