feat(19-01): add tablo status column, batch progress query, and sqlc regen
- Add migration 0010_tablo_status.sql with reversible goose Up/Down - Update all tablo SQL queries to include status column in SELECT/RETURNING/GROUP BY - Add ListTabloProgressByIDs batch aggregation query (D-06) - sqlc regenerated locally (files gitignored — regen via sqlc generate)
This commit is contained in:
parent
c3b470a1a7
commit
c1928e312f
2 changed files with 24 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
-- name: ListTablosByUser :many
|
||||
SELECT id, user_id, title, description, color, created_at, updated_at
|
||||
SELECT id, user_id, title, description, color, created_at, updated_at, status
|
||||
FROM tablos
|
||||
WHERE user_id = $1
|
||||
ORDER BY created_at DESC;
|
||||
|
|
@ -12,6 +12,7 @@ SELECT tablos.id,
|
|||
tablos.color,
|
||||
tablos.created_at,
|
||||
tablos.updated_at,
|
||||
tablos.status,
|
||||
COALESCE(count(unread_messages.id), 0)::bigint AS discussion_unread_count
|
||||
FROM tablos
|
||||
LEFT JOIN discussion_read_states AS read_state
|
||||
|
|
@ -27,24 +28,35 @@ LEFT JOIN discussion_messages AS unread_messages
|
|||
OR unread_messages.created_at > last_read_message.created_at
|
||||
)
|
||||
WHERE tablos.user_id = sqlc.arg(user_id)
|
||||
GROUP BY tablos.id, tablos.user_id, tablos.title, tablos.description, tablos.color, tablos.created_at, tablos.updated_at
|
||||
GROUP BY tablos.id, tablos.user_id, tablos.title, tablos.description, tablos.color, tablos.created_at, tablos.updated_at, tablos.status
|
||||
ORDER BY tablos.created_at DESC;
|
||||
|
||||
-- name: GetTabloByID :one
|
||||
SELECT id, user_id, title, description, color, created_at, updated_at
|
||||
SELECT id, user_id, title, description, color, created_at, updated_at, status
|
||||
FROM tablos
|
||||
WHERE id = $1 AND user_id = $2;
|
||||
|
||||
-- name: InsertTablo :one
|
||||
INSERT INTO tablos (user_id, title, description, color)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, user_id, title, description, color, created_at, updated_at;
|
||||
RETURNING id, user_id, title, description, color, created_at, updated_at, status;
|
||||
|
||||
-- name: UpdateTablo :one
|
||||
UPDATE tablos
|
||||
SET title = $2, description = $3, color = $4, updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING id, user_id, title, description, color, created_at, updated_at;
|
||||
RETURNING id, user_id, title, description, color, created_at, updated_at, status;
|
||||
|
||||
-- name: DeleteTablo :exec
|
||||
DELETE FROM tablos WHERE id = $1 AND user_id = $2;
|
||||
|
||||
-- name: ListTabloProgressByIDs :many
|
||||
-- Batch aggregation: one query for all tablos on the dashboard (D-06).
|
||||
-- Counts all tasks regardless of etape assignment.
|
||||
SELECT
|
||||
tablo_id,
|
||||
COUNT(*) FILTER (WHERE status = 'done')::int AS done_tasks,
|
||||
COUNT(*)::int AS total_tasks
|
||||
FROM tasks
|
||||
WHERE tablo_id = ANY(@tablo_ids::uuid[])
|
||||
GROUP BY tablo_id;
|
||||
|
|
|
|||
7
backend/migrations/0010_tablo_status.sql
Normal file
7
backend/migrations/0010_tablo_status.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- +goose Up
|
||||
ALTER TABLE tablos
|
||||
ADD COLUMN status text NOT NULL DEFAULT 'active'
|
||||
CHECK (status IN ('active', 'archived'));
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE tablos DROP COLUMN status;
|
||||
Loading…
Reference in a new issue