Route memory action

This commit is contained in:
2026-04-27 16:37:42 +02:00
parent 57313c002a
commit c5c6de0281
2 changed files with 257 additions and 11 deletions

View File

@@ -132,6 +132,26 @@ def upsert_client(name, notes="", status="actif"):
return row_to_dict(db.execute("SELECT * FROM clients WHERE id = ?", (client_id,)).fetchone())
def deactivate_client(name):
name = clean_text(name)
if not name:
raise ValueError("Nom de client manquant")
with connect() as db:
row = find_client(db, name)
if not row:
return None
db.execute(
"""
UPDATE clients
SET status = 'inactif', updated_at = CURRENT_TIMESTAMP
WHERE id = ?
""",
(row["id"],),
)
return row_to_dict(row)
def upsert_project(name, client_name="", status="actif", summary="", next_action=""):
name = clean_text(name)
if not name:
@@ -198,7 +218,12 @@ def add_task(title, client_name="", project_name="", details="", due_at=""):
def list_clients(limit=100):
with connect() as db:
rows = db.execute(
"SELECT * FROM clients ORDER BY name COLLATE NOCASE LIMIT ?",
"""
SELECT * FROM clients
WHERE status != 'inactif'
ORDER BY name COLLATE NOCASE
LIMIT ?
""",
(limit,),
).fetchall()
return [row_to_dict(row) for row in rows]
@@ -212,6 +237,7 @@ def get_memory_snapshot(limit=25):
COUNT(t.id) AS open_task_count
FROM clients c
LEFT JOIN tasks t ON t.client_id = c.id AND t.done = 0
WHERE c.status != 'inactif'
GROUP BY c.id
ORDER BY c.name COLLATE NOCASE
LIMIT ?