chore(rls): stage projects canary path
This commit is contained in:
@@ -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},
|
||||
|
||||
@@ -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
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user