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
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:
1 parent
e50c04c96f
commit
a99d4a8974
15 files changed
+709
-130
No files matched your search
@@ -0,0 +1,21 @@
|
||||
-- AP1.12c: Backlog sort_order für Reorder im Plan-Modus
|
||||
|
||||
ALTER TABLE backlog_items
|
||||
ADD COLUMN IF NOT EXISTS sort_order INT NOT NULL DEFAULT 0;
|
||||
|
||||
WITH ranked AS (
|
||||
SELECT
|
||||
id,
|
||||
(ROW_NUMBER() OVER (
|
||||
PARTITION BY tenant_id, initiative_id
|
||||
ORDER BY created_at ASC, id ASC
|
||||
) - 1) * 10 AS next_order
|
||||
FROM backlog_items
|
||||
)
|
||||
UPDATE backlog_items bi
|
||||
SET sort_order = ranked.next_order
|
||||
FROM ranked
|
||||
WHERE bi.id = ranked.id;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_backlog_items_sort
|
||||
ON backlog_items (tenant_id, initiative_id, sort_order);
|
||||
@@ -19,6 +19,7 @@ class BacklogCreateRequest(BaseModel):
|
||||
status: Literal["new", "triaged", "accepted", "rejected"] = "new"
|
||||
priority: Literal["low", "normal", "high"] = "normal"
|
||||
roadmap_item_id: Optional[str] = None
|
||||
sort_order: Optional[int] = None
|
||||
|
||||
|
||||
class BacklogUpdateRequest(BaseModel):
|
||||
@@ -28,6 +29,7 @@ class BacklogUpdateRequest(BaseModel):
|
||||
priority: Optional[Literal["low", "normal", "high"]] = None
|
||||
roadmap_item_id: Optional[str] = None
|
||||
clear_roadmap_item: bool = False
|
||||
sort_order: Optional[int] = None
|
||||
|
||||
|
||||
class BacklogConvertRequest(BaseModel):
|
||||
@@ -64,6 +66,7 @@ def update_backlog_item(
|
||||
priority=body.priority,
|
||||
roadmap_item_id=body.roadmap_item_id,
|
||||
clear_roadmap_item=body.clear_roadmap_item,
|
||||
sort_order=body.sort_order,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -247,6 +247,29 @@ def test_backlog_crud(client):
|
||||
assert deleted.status_code == 204
|
||||
|
||||
|
||||
def test_backlog_sort_order(client):
|
||||
user = provision_user_in_tenant(tenant_role="member")
|
||||
token = _login(client, user)
|
||||
initiative_id = _create_initiative(client, token).json()["id"]
|
||||
first = _create_backlog(client, token, initiative_id, title="First").json()
|
||||
second = _create_backlog(client, token, initiative_id, title="Second").json()
|
||||
assert first["sort_order"] < second["sort_order"]
|
||||
|
||||
patched = client.patch(
|
||||
f"/api/backlog/{second['id']}",
|
||||
json={"sort_order": 0},
|
||||
headers=_auth(token),
|
||||
)
|
||||
assert patched.status_code == 200
|
||||
assert patched.json()["sort_order"] == 0
|
||||
|
||||
listed = client.get(
|
||||
f"/api/initiatives/{initiative_id}/backlog",
|
||||
headers=_auth(token),
|
||||
).json()
|
||||
assert [row["title"] for row in listed[:2]] == ["Second", "First"]
|
||||
|
||||
|
||||
def test_milestone_crud(client):
|
||||
user = provision_user_in_tenant(tenant_role="member")
|
||||
token = _login(client, user)
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
APP_VERSION = "0.16.6-ap1.12b"
|
||||
DB_SCHEMA_VERSION = "014"
|
||||
APP_VERSION = "0.16.7-ap1.12c"
|
||||
DB_SCHEMA_VERSION = "015"
|
||||
APP_NAME = "jinkendo-kairo"
|
||||
Reference in new issue
Block a user