Add issue resolution confirmation workflow
This commit is contained in:
@@ -400,6 +400,27 @@ def init_db() -> None:
|
||||
)
|
||||
"""
|
||||
)
|
||||
conn.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS portal_item_activity (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
item_id INTEGER NOT NULL,
|
||||
event_type TEXT NOT NULL,
|
||||
actor_username TEXT NOT NULL,
|
||||
actor_role TEXT NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
metadata_json TEXT,
|
||||
created_at TEXT NOT NULL,
|
||||
FOREIGN KEY(item_id) REFERENCES portal_items(id) ON DELETE CASCADE
|
||||
)
|
||||
"""
|
||||
)
|
||||
conn.execute(
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS idx_portal_item_activity_item
|
||||
ON portal_item_activity (item_id, created_at ASC, id ASC)
|
||||
"""
|
||||
)
|
||||
conn.execute(
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS idx_requests_cache_created_at
|
||||
@@ -3580,6 +3601,91 @@ def list_portal_comments(item_id: int, *, include_internal: bool = True, limit:
|
||||
return [_portal_comment_from_row(row) for row in rows]
|
||||
|
||||
|
||||
def add_portal_item_activity(
|
||||
item_id: int,
|
||||
*,
|
||||
event_type: str,
|
||||
actor_username: str,
|
||||
actor_role: str,
|
||||
message: str,
|
||||
metadata_json: Optional[str] = None,
|
||||
) -> Dict[str, Any]:
|
||||
now = datetime.now(timezone.utc).isoformat()
|
||||
with _connect() as conn:
|
||||
cursor = conn.execute(
|
||||
"""
|
||||
INSERT INTO portal_item_activity (
|
||||
item_id,
|
||||
event_type,
|
||||
actor_username,
|
||||
actor_role,
|
||||
message,
|
||||
metadata_json,
|
||||
created_at
|
||||
)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
item_id,
|
||||
event_type,
|
||||
actor_username,
|
||||
actor_role,
|
||||
message,
|
||||
metadata_json,
|
||||
now,
|
||||
),
|
||||
)
|
||||
activity_id = cursor.lastrowid
|
||||
row = conn.execute(
|
||||
"""
|
||||
SELECT id, item_id, event_type, actor_username, actor_role, message, metadata_json, created_at
|
||||
FROM portal_item_activity
|
||||
WHERE id = ?
|
||||
""",
|
||||
(activity_id,),
|
||||
).fetchone()
|
||||
if not row:
|
||||
raise RuntimeError("Portal activity could not be loaded after insert.")
|
||||
return {
|
||||
"id": row[0],
|
||||
"item_id": row[1],
|
||||
"event_type": row[2],
|
||||
"actor_username": row[3],
|
||||
"actor_role": row[4],
|
||||
"message": row[5],
|
||||
"metadata_json": row[6],
|
||||
"created_at": row[7],
|
||||
}
|
||||
|
||||
|
||||
def list_portal_item_activity(item_id: int, *, limit: int = 300) -> list[Dict[str, Any]]:
|
||||
safe_limit = max(1, min(int(limit), 500))
|
||||
with _connect() as conn:
|
||||
rows = conn.execute(
|
||||
"""
|
||||
SELECT id, item_id, event_type, actor_username, actor_role, message, metadata_json, created_at
|
||||
FROM portal_item_activity
|
||||
WHERE item_id = ?
|
||||
ORDER BY created_at ASC, id ASC
|
||||
LIMIT ?
|
||||
""",
|
||||
(item_id, safe_limit),
|
||||
).fetchall()
|
||||
return [
|
||||
{
|
||||
"id": row[0],
|
||||
"item_id": row[1],
|
||||
"event_type": row[2],
|
||||
"actor_username": row[3],
|
||||
"actor_role": row[4],
|
||||
"message": row[5],
|
||||
"metadata_json": row[6],
|
||||
"created_at": row[7],
|
||||
}
|
||||
for row in rows
|
||||
]
|
||||
|
||||
|
||||
def get_portal_overview() -> Dict[str, Any]:
|
||||
with _connect() as conn:
|
||||
kind_rows = conn.execute(
|
||||
|
||||
Reference in New Issue
Block a user