fix(tasktree): align active timeline presentation
This commit is contained in:
@@ -154,7 +154,12 @@ export class TaskTreeStore {
|
||||
LEFT JOIN tasktree_tasks t ON t.group_id=g.id
|
||||
LEFT JOIN tasktree_execution_reports r ON r.task_id=t.id
|
||||
GROUP BY g.id
|
||||
ORDER BY g.updated_at DESC, g.name
|
||||
ORDER BY GREATEST(
|
||||
g.updated_at,
|
||||
COALESCE(MAX(t.updated_at),g.updated_at),
|
||||
COALESCE(MAX(r.created_at),g.updated_at),
|
||||
COALESCE((SELECT MAX(m.created_at) FROM tasktree_milestones m WHERE m.group_id=g.id),g.updated_at)
|
||||
) DESC, g.name
|
||||
`);
|
||||
return result.rows.map(overviewRow);
|
||||
}
|
||||
@@ -338,11 +343,25 @@ export class TaskTreeStore {
|
||||
|
||||
async createReport(input: { taskId: string; title: string; body: string; status?: string }): Promise<ExecutionReport> {
|
||||
await this.ensureSchema();
|
||||
const result = await this.pool.query(
|
||||
"INSERT INTO tasktree_execution_reports (id,task_id,title,body,status) VALUES ($1,$2,$3,$4,$5) RETURNING *",
|
||||
[`tr_${randomUUID()}`, input.taskId, input.title, input.body, input.status ?? "succeeded"]
|
||||
);
|
||||
return reportRow(result.rows[0]);
|
||||
const client = await this.pool.connect();
|
||||
try {
|
||||
await client.query("BEGIN");
|
||||
const result = await client.query(
|
||||
"INSERT INTO tasktree_execution_reports (id,task_id,title,body,status) VALUES ($1,$2,$3,$4,$5) RETURNING *",
|
||||
[`tr_${randomUUID()}`, input.taskId, input.title, input.body, input.status ?? "succeeded"]
|
||||
);
|
||||
await client.query(
|
||||
"UPDATE tasktree_groups g SET updated_at=now() FROM tasktree_tasks t WHERE t.id=$1 AND g.id=t.group_id",
|
||||
[input.taskId]
|
||||
);
|
||||
await client.query("COMMIT");
|
||||
return reportRow(result.rows[0]);
|
||||
} catch (error) {
|
||||
await client.query("ROLLBACK").catch(() => {});
|
||||
throw error;
|
||||
} finally {
|
||||
client.release();
|
||||
}
|
||||
}
|
||||
|
||||
async listReports(taskId: string): Promise<ExecutionReport[]> {
|
||||
|
||||
Reference in New Issue
Block a user