diff --git a/pipeline_service/storage.py b/pipeline_service/storage.py index 0dc4c8b..56e2c4f 100644 --- a/pipeline_service/storage.py +++ b/pipeline_service/storage.py @@ -206,10 +206,12 @@ async def list_tasks(tenant_id: str, pipeline_id: str = None, limit: int = 100) """List tasks for a tenant.""" db, dbname = _get_db() async with db.sqlorContext(dbname) as sor: - filters = {'tenant_id': tenant_id} if pipeline_id: - filters['pipeline_id'] = pipeline_id - recs = await sor.R('pipeline_tasks', filters, sort='created_at desc') + sql = "SELECT * FROM pipeline_tasks WHERE tenant_id=${tenant_id}$ AND pipeline_id=${pipeline_id}$ ORDER BY created_at DESC" + recs = await sor.sqlExe(sql, {'tenant_id': tenant_id, 'pipeline_id': pipeline_id}) + else: + sql = "SELECT * FROM pipeline_tasks WHERE tenant_id=${tenant_id}$ ORDER BY created_at DESC" + recs = await sor.sqlExe(sql, {'tenant_id': tenant_id}) result = [] for rec in (recs or [])[:limit]: if hasattr(rec, '__dict__'):