Admin overview: include username (resolved from Cloudron user list)
This commit is contained in:
1 parent
9da67a9021
commit
8e4bf64199
1 file changed
+17
+17
@@ -1097,6 +1097,22 @@ async def admin_overview(token: str):
|
||||
).fetchall()
|
||||
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.
|
||||
teams = {}
|
||||
try:
|
||||
@@ -1120,6 +1136,7 @@ async def admin_overview(token: str):
|
||||
members.append(
|
||||
{
|
||||
"email": email,
|
||||
"username": usernames.get(user_id),
|
||||
"active": bool(active),
|
||||
"balance": float(balance) if balance is not None else MEMBER_BUDGET,
|
||||
"spend": spend,
|
||||
|
||||
Reference in new issue
Block a user