kaneo (minimalist kanban) fork to experiment adding a tangled integration github.com/usekaneo/kaneo
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 48 lines 1.1 kB view raw
1import { and, eq } from "drizzle-orm"; 2import { HTTPException } from "hono/http-exception"; 3import db from "../../database"; 4import { columnTable, taskTable } from "../../database/schema"; 5import { assertValidTaskStatus } from "../validate-task-fields"; 6 7async function updateTaskStatus({ 8 id, 9 status, 10}: { 11 id: string; 12 status: string; 13}) { 14 const existingTask = await db.query.taskTable.findFirst({ 15 where: eq(taskTable.id, id), 16 }); 17 18 if (!existingTask) { 19 throw new HTTPException(404, { 20 message: "Task not found", 21 }); 22 } 23 24 await assertValidTaskStatus(status, existingTask.projectId); 25 26 const column = await db.query.columnTable.findFirst({ 27 where: and( 28 eq(columnTable.projectId, existingTask.projectId), 29 eq(columnTable.slug, status), 30 ), 31 }); 32 33 const [updatedTask] = await db 34 .update(taskTable) 35 .set({ status, columnId: column?.id ?? null }) 36 .where(eq(taskTable.id, id)) 37 .returning(); 38 39 if (!updatedTask) { 40 throw new HTTPException(500, { 41 message: "Failed to update task status", 42 }); 43 } 44 45 return updatedTask; 46} 47 48export default updateTaskStatus;