feat(workbench): add dynamic task approval lifecycle
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Optional project-local schedule, work-order and alert projections."""
|
||||
"""Optional project-local alert projection."""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
@@ -8,7 +8,6 @@ from psycopg import AsyncConnection
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class WorkbenchOperationsAvailability:
|
||||
work_orders: bool
|
||||
alerts: bool
|
||||
schedules: bool = False
|
||||
|
||||
@@ -23,34 +22,14 @@ class WorkbenchOperationsRepository:
|
||||
async with conn.cursor() as cur:
|
||||
await cur.execute(
|
||||
"""
|
||||
SELECT
|
||||
to_regclass('workbench.work_orders') IS NOT NULL AS work_orders,
|
||||
to_regclass('workbench.alerts') IS NOT NULL AS alerts
|
||||
SELECT to_regclass('workbench.alerts') IS NOT NULL AS alerts
|
||||
"""
|
||||
)
|
||||
row = await cur.fetchone()
|
||||
return WorkbenchOperationsAvailability(
|
||||
work_orders=bool(row and row["work_orders"]),
|
||||
alerts=bool(row and row["alerts"]),
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
async def list_work_orders(
|
||||
conn: AsyncConnection, project_id: str, *, limit: int = 100
|
||||
) -> list[dict[str, Any]]:
|
||||
async with conn.cursor() as cur:
|
||||
await cur.execute(
|
||||
"""
|
||||
SELECT document
|
||||
FROM workbench.work_orders
|
||||
WHERE project_id = %s
|
||||
ORDER BY updated_at DESC, work_order_id
|
||||
LIMIT %s
|
||||
""",
|
||||
(project_id, limit),
|
||||
)
|
||||
return [row["document"] for row in await cur.fetchall()]
|
||||
|
||||
@staticmethod
|
||||
async def list_alerts(
|
||||
conn: AsyncConnection, project_id: str, *, limit: int = 100
|
||||
|
||||
Reference in New Issue
Block a user