Q151: deleting a task first shows what goes with it, then waits for the result
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
809c67a54a
commit
18f1e1fcc3
13 files changed
+171
-5
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import type { TaskDeleteImpact } from "../../shared/domain";
|
||||
import type { DatabaseSync } from "node:sqlite";
|
||||
import { APPROVAL_STATE, RISK_LEVEL, TASK_STATUS, WRITING_MODE, type RiskLevel } from "../../shared/domain";
|
||||
import { createId } from "../../shared/ids";
|
||||
@@ -472,6 +473,10 @@ export class OrganizationService {
|
||||
this.tasks.update(input);
|
||||
}
|
||||
|
||||
taskDeleteImpact(orgId: string, taskId: string): TaskDeleteImpact {
|
||||
return this.tasks.deleteImpact(orgId, taskId);
|
||||
}
|
||||
|
||||
setTaskBlocked(input: SetTaskBlockedInput): void {
|
||||
this.tasks.setBlocked(input);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { TaskDeleteImpact } from "../../shared/domain";
|
||||
import type { DatabaseSync } from "node:sqlite";
|
||||
import { RISK_LEVEL, TASK_STATUS, type TaskPriority } from "../../shared/domain";
|
||||
import type { CreateTaskInput, DeleteTaskInput, SetTaskBlockedInput, UpdateTaskInput } from "../../shared/commands";
|
||||
@@ -70,6 +71,20 @@ export class TaskMutations {
|
||||
});
|
||||
}
|
||||
|
||||
/** What deleting the task would remove, keep and close, counted from the database. */
|
||||
deleteImpact(orgId: string, taskId: string): TaskDeleteImpact {
|
||||
this.requireTask(orgId, taskId);
|
||||
const count = (sql: string) => (this.db.prepare(sql).get(taskId, orgId) as { n: number }).n;
|
||||
return {
|
||||
runs: count("select count(*) as n from task_runs where task_id = ? and org_id = ?"),
|
||||
running: count("select count(*) as n from task_runs where task_id = ? and org_id = ? and state = 'running'"),
|
||||
subtasks: count("select count(*) as n from tasks where parent_task_id = ? and org_id = ?"),
|
||||
documents: count("select count(*) as n from documents where task_id = ? and org_id = ?"),
|
||||
openReviews: count("select count(*) as n from tasks where review_of_task_id = ? and org_id = ? and status <> 'done'"),
|
||||
pendingApprovals: count("select count(*) as n from approvals where source_entity_type = 'task' and source_entity_id = ? and org_id = ? and state = 'pending'"),
|
||||
};
|
||||
}
|
||||
|
||||
/** Blocks the task with a reason (no session starts, queued ones are superseded) or unblocks it with null. */
|
||||
setBlocked(input: SetTaskBlockedInput): void {
|
||||
const reason = input.reason === null ? null : input.reason.trim();
|
||||
|
||||
Reference in new issue
Block a user