chore(rls): stage projects canary path
All checks were successful
Code Review / ai-code-review (push) Successful in 10s
CD Pipeline / tests (push) Successful in 1m8s
CD Pipeline / build-and-deploy (push) Successful in 3m49s
CD Pipeline / post-deploy-checks (push) Successful in 1m25s

This commit is contained in:
Your Name
2026-05-12 21:25:24 +08:00
parent b7af597459
commit 7d92f0acd7
5 changed files with 210 additions and 11 deletions

View File

@@ -336,7 +336,7 @@ async def _get_tenant_budget_limit(project_id: str) -> Decimal | None:
try:
from sqlalchemy import text
from src.db.base import get_db_context
async with get_db_context() as db:
async with get_db_context(project_id) as db:
row = await db.execute(
text("SELECT budget_limit_usd FROM awooop_projects WHERE project_id = :pid"),
{"pid": project_id},

View File

@@ -15,7 +15,7 @@ from uuid import UUID
import structlog
from fastapi import HTTPException, status
from sqlalchemy import func, select, update
from sqlalchemy import func, select, text, update
from sqlalchemy import or_ as sa_or
from src.db.awooop_models import (
@@ -23,7 +23,6 @@ from src.db.awooop_models import (
AwoooPConversationEvent,
AwoooPMcpGatewayAudit,
AwoooPOutboundMessage,
AwoooPProject,
AwoooPRunState,
AwoooPRunStepJournal,
)
@@ -49,18 +48,27 @@ async def list_tenants() -> dict[str, Any]:
"""列出所有 AwoooP 租戶Operator Console不依 RLS 過濾)。"""
async with get_db_context("awoooi") as db:
result = await db.execute(
select(AwoooPProject).order_by(AwoooPProject.created_at.asc())
text("""
SELECT
project_id,
display_name,
migration_mode,
budget_limit_usd,
is_active,
created_at
FROM awooop_operator_list_projects()
""")
)
rows = list(result.scalars().all())
rows = list(result.mappings().all())
tenants = [
{
"project_id": r.project_id,
"display_name": r.display_name,
"migration_mode": r.migration_mode,
"budget_limit_usd": r.budget_limit_usd,
"is_active": r.is_active,
"created_at": r.created_at,
"project_id": r["project_id"],
"display_name": r["display_name"],
"migration_mode": r["migration_mode"],
"budget_limit_usd": r["budget_limit_usd"],
"is_active": r["is_active"],
"created_at": r["created_at"],
}
for r in rows
]