From 900bca1bea8eac5567343c083526ca36daa01ba2 Mon Sep 17 00:00:00 2001 From: pikann22 Date: Wed, 17 Jun 2026 06:46:39 +0000 Subject: [PATCH] refactor: remove uuid dependency and update checklist/item creation queries to return generated IDs --- backend/checklists.go | 16 +++++++++------- backend/go.mod | 2 -- backend/go.sum | 2 -- backend/items.go | 16 +++++++++------- frontend/src/ChecklistsSection.tsx | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/backend/checklists.go b/backend/checklists.go index 6c7c74a..e3281bb 100644 --- a/backend/checklists.go +++ b/backend/checklists.go @@ -4,7 +4,6 @@ import ( "fmt" plugin "github.com/Paca-AI/plugin-sdk-go" - "github.com/google/uuid" ) // ── Domain types ────────────────────────────────────────────────────────────── @@ -142,17 +141,20 @@ func (p *checklistPlugin) createChecklist(req *plugin.Request, res *plugin.Respo nextPos = sc.intVal("next_pos") } - id := uuid.New().String() now := nowStr() - _, err = p.db.Exec( - `INSERT INTO task_checklists (id, task_id, title, position, created_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7)`, - id, taskID, b.Title, nextPos, req.Caller.CallerID, now, now, + inserted, err := p.db.Query( + `INSERT INTO task_checklists (task_id, title, position, created_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id`, + taskID, b.Title, nextPos, req.Caller.CallerID, now, now, ) - if err != nil { - p.log.Error("createChecklist insert: " + err.Error()) + if err != nil || len(inserted.Rows) == 0 { + if err != nil { + p.log.Error("createChecklist insert: " + err.Error()) + } res.Error(500, "failed to create checklist") return } + idSC := newRowScanner(inserted.Columns, inserted.Rows[0]) + id := idSC.str("id") cl := checklist{ ID: id, TaskID: taskID, diff --git a/backend/go.mod b/backend/go.mod index d8b5aa4..0900e3a 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -3,5 +3,3 @@ module github.com/Paca-AI/first-party/checklist go 1.24 require github.com/Paca-AI/plugin-sdk-go v0.2.0 - -require github.com/google/uuid v1.6.0 diff --git a/backend/go.sum b/backend/go.sum index bede9ea..8389b8f 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -1,4 +1,2 @@ github.com/Paca-AI/plugin-sdk-go v0.2.0 h1:Fur6p+OQoC5imq7qmvaQtJnZ3SRVRskx8KcT/rqFHj4= github.com/Paca-AI/plugin-sdk-go v0.2.0/go.mod h1:5WeC6cSEf2wM1ovICZbDaVky9oi5id/Qpdfc5LDAQnw= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/backend/items.go b/backend/items.go index 95cd9a1..024c8fd 100644 --- a/backend/items.go +++ b/backend/items.go @@ -2,7 +2,6 @@ package main import ( plugin "github.com/Paca-AI/plugin-sdk-go" - "github.com/google/uuid" ) // ── Item route handlers ─────────────────────────────────────────────────────── @@ -46,17 +45,20 @@ func (p *checklistPlugin) createItem(req *plugin.Request, res *plugin.Response) nextPos = sc.intVal("next_pos") } - id := uuid.New().String() now := nowStr() - _, err = p.db.Exec( - `INSERT INTO task_checklist_items (id, checklist_id, title, is_checked, assignee_id, position, created_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)`, - id, checklistID, b.Title, false, nil, nextPos, req.Caller.CallerID, now, now, + inserted, err := p.db.Query( + `INSERT INTO task_checklist_items (checklist_id, title, is_checked, assignee_id, position, created_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id`, + checklistID, b.Title, false, nil, nextPos, req.Caller.CallerID, now, now, ) - if err != nil { - p.log.Error("createItem insert: " + err.Error()) + if err != nil || len(inserted.Rows) == 0 { + if err != nil { + p.log.Error("createItem insert: " + err.Error()) + } res.Error(500, "failed to create item") return } + idSC := newRowScanner(inserted.Columns, inserted.Rows[0]) + id := idSC.str("id") item := checklistItem{ ID: id, ChecklistID: checklistID, diff --git a/frontend/src/ChecklistsSection.tsx b/frontend/src/ChecklistsSection.tsx index 6411829..a2b4a91 100644 --- a/frontend/src/ChecklistsSection.tsx +++ b/frontend/src/ChecklistsSection.tsx @@ -160,7 +160,7 @@ function ChecklistsSectionInner({ checklist={cl} canEdit={canEdit} onRename={(id, title) => - api.pluginPatch(PLUGIN_ID, `/tasks/${taskId}/checklists/${id}`, { title }).then(invalidate) + api.pluginPatch(PLUGIN_ID, `/projects/${projectId}/tasks/${taskId}/checklists/${id}`, { title }).then(invalidate) } onDelete={(id) => deleteChecklist.mutate(id)} onCreateItem={(checklistId, title) =>