fix(A1): Übungen an Stufen binden, Gates entkoppeln, Tages-Abschluss
Deploy Development / deploy (push) Successful in 49s
Test Suite / pytest-backend (push) Failing after 4m46s
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 49s
Test Suite / pytest-backend (push) Failing after 4m46s
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
Activity Set pro Stufe statt Gate-Titel-Recurring; Single-Active-Stufe bei Reopen; Complete heute schliesst Next Action; Heute-Panel fuer alle Uebungen der aktiven Stufe. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b7d88ce24a
commit
19e962d8ec
17 files changed
+620
-209
No files matched your search
@@ -14,10 +14,7 @@ from steering.strategies.next_action.execution_ready import (
|
||||
from steering.strategies.next_action.product_milestone_driven import (
|
||||
ProductMilestoneDrivenStrategy,
|
||||
)
|
||||
from steering.strategies.next_action.recurring_helpers import (
|
||||
active_recurring_candidates,
|
||||
recurring_due_candidates,
|
||||
)
|
||||
from steering.strategies.next_action.recurring_helpers import recurring_due_candidates
|
||||
from steering.strategies.next_action.registry import (
|
||||
get_next_action_strategy,
|
||||
register_next_action_strategy,
|
||||
@@ -44,8 +41,6 @@ class MaturityProgressionStrategy:
|
||||
return _default.evaluate(ctx, limit=limit)
|
||||
|
||||
recurring = recurring_due_candidates(ctx, initiative_id, limit=limit)
|
||||
if not recurring:
|
||||
recurring = active_recurring_candidates(ctx, initiative_id, limit=1)
|
||||
|
||||
remaining = limit - len(recurring)
|
||||
gate_scope = first_active_gate_id(ctx, initiative_id)
|
||||
|
||||
@@ -8,6 +8,46 @@ from db import get_connection
|
||||
from psycopg2.extras import RealDictCursor
|
||||
from tenant_context import TenantContext
|
||||
|
||||
_PRACTICE_DUE_SQL = """
|
||||
SELECT
|
||||
'recurring_due' AS kind,
|
||||
re.title AS title,
|
||||
COALESCE(NULLIF(re.description, ''), 'Heutige Übung') AS summary,
|
||||
re.initiative_id,
|
||||
re.id AS recurring_id,
|
||||
NULL::uuid AS action_id,
|
||||
NULL::uuid AS backlog_item_id,
|
||||
'recurring_due' AS reason_code,
|
||||
'Übung heute erledigen' AS recommended_action
|
||||
FROM recurring_elements re
|
||||
LEFT JOIN roadmap_items ri
|
||||
ON ri.id = re.roadmap_item_id AND ri.tenant_id = re.tenant_id
|
||||
WHERE re.tenant_id = %s AND re.initiative_id = %s
|
||||
AND re.status = 'active'
|
||||
AND (re.next_due_at IS NULL OR re.next_due_at <= NOW())
|
||||
AND (re.roadmap_item_id IS NULL OR (ri.status = 'active' AND ri.item_type = 'maturity_stage'))
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM cadence_instances ci
|
||||
WHERE ci.recurring_element_id = re.id
|
||||
AND ci.tenant_id = re.tenant_id
|
||||
AND ci.status = 'completed'
|
||||
AND ci.completed_at >= CURRENT_DATE
|
||||
)
|
||||
ORDER BY re.next_due_at ASC NULLS FIRST, re.title
|
||||
LIMIT %s
|
||||
"""
|
||||
|
||||
|
||||
def _serialize_recurring_rows(rows) -> list[dict[str, Any]]:
|
||||
items: list[dict[str, Any]] = []
|
||||
for row in rows:
|
||||
item = dict(row)
|
||||
item["initiative_id"] = str(item["initiative_id"])
|
||||
if item.get("recurring_id"):
|
||||
item["recurring_id"] = str(item["recurring_id"])
|
||||
items.append(item)
|
||||
return items
|
||||
|
||||
|
||||
def recurring_due_candidates(
|
||||
ctx: TenantContext, initiative_id: str, *, limit: int
|
||||
@@ -15,36 +55,8 @@ def recurring_due_candidates(
|
||||
conn = get_connection()
|
||||
try:
|
||||
with conn.cursor(cursor_factory=RealDictCursor) as cur:
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT
|
||||
'recurring_due' AS kind,
|
||||
re.title AS title,
|
||||
'Wiederkehrendes Element fällig' AS summary,
|
||||
re.initiative_id,
|
||||
re.id AS recurring_id,
|
||||
NULL::uuid AS action_id,
|
||||
NULL::uuid AS backlog_item_id,
|
||||
'recurring_due' AS reason_code,
|
||||
'Übung heute erledigen' AS recommended_action
|
||||
FROM recurring_elements re
|
||||
WHERE re.tenant_id = %s AND re.initiative_id = %s
|
||||
AND re.status = 'active'
|
||||
AND re.next_due_at IS NOT NULL
|
||||
AND re.next_due_at <= NOW()
|
||||
ORDER BY re.next_due_at ASC
|
||||
LIMIT %s
|
||||
""",
|
||||
(ctx.tenant_id, initiative_id, limit),
|
||||
)
|
||||
items: list[dict[str, Any]] = []
|
||||
for row in cur.fetchall():
|
||||
item = dict(row)
|
||||
item["initiative_id"] = str(item["initiative_id"])
|
||||
if item.get("recurring_id"):
|
||||
item["recurring_id"] = str(item["recurring_id"])
|
||||
items.append(item)
|
||||
return items
|
||||
cur.execute(_PRACTICE_DUE_SQL, (ctx.tenant_id, initiative_id, limit))
|
||||
return _serialize_recurring_rows(cur.fetchall())
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
@@ -52,37 +64,5 @@ def recurring_due_candidates(
|
||||
def active_recurring_candidates(
|
||||
ctx: TenantContext, initiative_id: str, *, limit: int = 1
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Active recurring as 'heutige Übung' when nothing is due yet."""
|
||||
conn = get_connection()
|
||||
try:
|
||||
with conn.cursor(cursor_factory=RealDictCursor) as cur:
|
||||
cur.execute(
|
||||
"""
|
||||
SELECT
|
||||
'recurring_due' AS kind,
|
||||
re.title AS title,
|
||||
'Heutige Übung / Routine' AS summary,
|
||||
re.initiative_id,
|
||||
re.id AS recurring_id,
|
||||
NULL::uuid AS action_id,
|
||||
NULL::uuid AS backlog_item_id,
|
||||
'recurring_active' AS reason_code,
|
||||
'Übung heute erledigen' AS recommended_action
|
||||
FROM recurring_elements re
|
||||
WHERE re.tenant_id = %s AND re.initiative_id = %s
|
||||
AND re.status = 'active'
|
||||
ORDER BY re.next_due_at ASC NULLS LAST, re.title
|
||||
LIMIT %s
|
||||
""",
|
||||
(ctx.tenant_id, initiative_id, limit),
|
||||
)
|
||||
items: list[dict[str, Any]] = []
|
||||
for row in cur.fetchall():
|
||||
item = dict(row)
|
||||
item["initiative_id"] = str(item["initiative_id"])
|
||||
if item.get("recurring_id"):
|
||||
item["recurring_id"] = str(item["recurring_id"])
|
||||
items.append(item)
|
||||
return items
|
||||
finally:
|
||||
conn.close()
|
||||
"""Due practices only — no fallback when already completed today."""
|
||||
return recurring_due_candidates(ctx, initiative_id, limit=limit)
|
||||
Reference in new issue
Block a user