Skip to content

Commit 40d5bcb

Browse files
authored
Merge pull request #7 from Paca-AI/fix/fix-duplicated-uuid-error
refactor: remove uuid dependency and update checklist/item creation q…
2 parents c3bda1a + 900bca1 commit 40d5bcb

5 files changed

Lines changed: 19 additions & 19 deletions

File tree

backend/checklists.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55

66
plugin "github.com/Paca-AI/plugin-sdk-go"
7-
"github.com/google/uuid"
87
)
98

109
// ── Domain types ──────────────────────────────────────────────────────────────
@@ -142,17 +141,20 @@ func (p *checklistPlugin) createChecklist(req *plugin.Request, res *plugin.Respo
142141
nextPos = sc.intVal("next_pos")
143142
}
144143

145-
id := uuid.New().String()
146144
now := nowStr()
147-
_, err = p.db.Exec(
148-
`INSERT INTO task_checklists (id, task_id, title, position, created_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7)`,
149-
id, taskID, b.Title, nextPos, req.Caller.CallerID, now, now,
145+
inserted, err := p.db.Query(
146+
`INSERT INTO task_checklists (task_id, title, position, created_by, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id`,
147+
taskID, b.Title, nextPos, req.Caller.CallerID, now, now,
150148
)
151-
if err != nil {
152-
p.log.Error("createChecklist insert: " + err.Error())
149+
if err != nil || len(inserted.Rows) == 0 {
150+
if err != nil {
151+
p.log.Error("createChecklist insert: " + err.Error())
152+
}
153153
res.Error(500, "failed to create checklist")
154154
return
155155
}
156+
idSC := newRowScanner(inserted.Columns, inserted.Rows[0])
157+
id := idSC.str("id")
156158
cl := checklist{
157159
ID: id,
158160
TaskID: taskID,

backend/go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ module github.com/Paca-AI/first-party/checklist
33
go 1.24
44

55
require github.com/Paca-AI/plugin-sdk-go v0.2.0
6-
7-
require github.com/google/uuid v1.6.0

backend/go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
github.com/Paca-AI/plugin-sdk-go v0.2.0 h1:Fur6p+OQoC5imq7qmvaQtJnZ3SRVRskx8KcT/rqFHj4=
22
github.com/Paca-AI/plugin-sdk-go v0.2.0/go.mod h1:5WeC6cSEf2wM1ovICZbDaVky9oi5id/Qpdfc5LDAQnw=
3-
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
4-
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=

backend/items.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
plugin "github.com/Paca-AI/plugin-sdk-go"
5-
"github.com/google/uuid"
65
)
76

87
// ── Item route handlers ───────────────────────────────────────────────────────
@@ -46,17 +45,20 @@ func (p *checklistPlugin) createItem(req *plugin.Request, res *plugin.Response)
4645
nextPos = sc.intVal("next_pos")
4746
}
4847

49-
id := uuid.New().String()
5048
now := nowStr()
51-
_, err = p.db.Exec(
52-
`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)`,
53-
id, checklistID, b.Title, false, nil, nextPos, req.Caller.CallerID, now, now,
49+
inserted, err := p.db.Query(
50+
`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`,
51+
checklistID, b.Title, false, nil, nextPos, req.Caller.CallerID, now, now,
5452
)
55-
if err != nil {
56-
p.log.Error("createItem insert: " + err.Error())
53+
if err != nil || len(inserted.Rows) == 0 {
54+
if err != nil {
55+
p.log.Error("createItem insert: " + err.Error())
56+
}
5757
res.Error(500, "failed to create item")
5858
return
5959
}
60+
idSC := newRowScanner(inserted.Columns, inserted.Rows[0])
61+
id := idSC.str("id")
6062
item := checklistItem{
6163
ID: id,
6264
ChecklistID: checklistID,

frontend/src/ChecklistsSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ function ChecklistsSectionInner({
160160
checklist={cl}
161161
canEdit={canEdit}
162162
onRename={(id, title) =>
163-
api.pluginPatch(PLUGIN_ID, `/tasks/${taskId}/checklists/${id}`, { title }).then(invalidate)
163+
api.pluginPatch(PLUGIN_ID, `/projects/${projectId}/tasks/${taskId}/checklists/${id}`, { title }).then(invalidate)
164164
}
165165
onDelete={(id) => deleteChecklist.mutate(id)}
166166
onCreateItem={(checklistId, title) =>

0 commit comments

Comments
 (0)