Admin overview: include username (resolved from Cloudron user list)

This commit is contained in:
inference-bot committed 2026-09-14 16:53:34 -06:00
1 parent 9da67a9021
commit 8e4bf64199
1 file changed
+17
+17
View File
@@ -1097,6 +1097,22 @@ async def admin_overview(token: str):
).fetchall() ).fetchall()
conn.close() conn.close()
# Fetch Cloudron users once to map user_id → username (most provisioned
# members have username=None, so we surface it only when it exists).
usernames = {}
try:
async with httpx.AsyncClient(timeout=15.0) as client:
r = await client.get(
f"{CLOUDRON_API}/api/v1/users",
headers={"Authorization": f"Bearer {CLOUDRON_TOKEN}"},
)
r.raise_for_status()
for u in r.json().get("users", []):
if u.get("username"):
usernames[u.get("id")] = u["username"]
except Exception as e:
logger.warning("admin overview: cloudron users fetch failed: %s", e)
# Fetch team spend/budget from LiteLLM once. # Fetch team spend/budget from LiteLLM once.
teams = {} teams = {}
try: try:
@@ -1120,6 +1136,7 @@ async def admin_overview(token: str):
members.append( members.append(
{ {
"email": email, "email": email,
"username": usernames.get(user_id),
"active": bool(active), "active": bool(active),
"balance": float(balance) if balance is not None else MEMBER_BUDGET, "balance": float(balance) if balance is not None else MEMBER_BUDGET,
"spend": spend, "spend": spend,