AP1.12c: Reorder für Projekte und Backlog per sort_order.
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Failing after 1m46s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped

Migration 015 für Backlog sort_order; DnD auf Desktop, Pfeile auf Mobile; PATCH-Batches für Geschwister.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-09 11:35:08 +02:00
1 parent e50c04c96f
commit a99d4a8974
15 files changed
+709 -130

No files matched your search

+28 -5
View File
@@ -18,7 +18,7 @@ BACKLOG_STATUSES = frozenset({"new", "triaged", "accepted", "rejected", "convert
_BACKLOG_COLUMNS = """
id, tenant_id, initiative_id, title, description, status,
priority, roadmap_item_id, converted_action_id, created_at, updated_at
priority, roadmap_item_id, converted_action_id, sort_order, created_at, updated_at
"""
@@ -53,6 +53,7 @@ def create_backlog_item(
status: BacklogStatus = "new",
priority: str = "normal",
roadmap_item_id: Optional[str] = None,
sort_order: Optional[int] = None,
user_id: Optional[str] = None,
) -> dict[str, Any]:
title = title.strip()
@@ -72,16 +73,34 @@ def create_backlog_item(
initiative_id=initiative_id,
roadmap_item_id=roadmap_item_id,
)
cur.execute(
"""
SELECT COALESCE(MAX(sort_order), -10) + 10 AS next_order
FROM backlog_items
WHERE tenant_id = %s AND initiative_id = %s
""",
(tenant_id, initiative_id),
)
next_order = int(cur.fetchone()["next_order"])
cur.execute(
f"""
INSERT INTO backlog_items (
tenant_id, initiative_id, title, description, status, priority,
roadmap_item_id
roadmap_item_id, sort_order
)
VALUES (%s, %s, %s, %s, %s, %s, %s)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
RETURNING {_BACKLOG_COLUMNS}
""",
(tenant_id, initiative_id, title, description, status, priority, roadmap_item_id),
(
tenant_id,
initiative_id,
title,
description,
status,
priority,
roadmap_item_id,
sort_order if sort_order is not None else next_order,
),
)
row = _serialize_row(dict(cur.fetchone()))
conn.commit()
@@ -109,7 +128,7 @@ def list_backlog_for_initiative(*, tenant_id: str, initiative_id: str) -> list[d
SELECT {_BACKLOG_COLUMNS}
FROM backlog_items
WHERE tenant_id = %s AND initiative_id = %s
ORDER BY updated_at DESC, title
ORDER BY sort_order ASC, created_at ASC, title
""",
(tenant_id, initiative_id),
)
@@ -147,6 +166,7 @@ def update_backlog_item(
priority: Optional[str] = None,
roadmap_item_id: Optional[str] = None,
clear_roadmap_item: bool = False,
sort_order: Optional[int] = None,
) -> Optional[dict[str, Any]]:
existing = get_backlog_item(tenant_id=tenant_id, backlog_item_id=backlog_item_id)
if not existing:
@@ -191,6 +211,9 @@ def update_backlog_item(
conn.close()
updates.append("roadmap_item_id = %s")
params.append(roadmap_item_id)
if sort_order is not None:
updates.append("sort_order = %s")
params.append(sort_order)
if not updates:
return existing