Update routes/dashboard_home.py
Browse files- routes/dashboard_home.py +9 -17
routes/dashboard_home.py
CHANGED
@@ -235,30 +235,22 @@ def get_platform_users() -> Dict[str, Any]:
|
|
235 |
"""Obtém informações sobre usuários e estilistas da plataforma"""
|
236 |
try:
|
237 |
# Obter número total de usuários
|
238 |
-
users_url = f"{SUPABASE_URL}/rest/v1/User?select=
|
239 |
-
users_response = requests.get(
|
240 |
-
users_url,
|
241 |
-
headers={**SUPABASE_HEADERS, "Prefer": "count=exact"}
|
242 |
-
)
|
243 |
|
244 |
total_users = 0
|
245 |
if users_response.status_code == 200:
|
246 |
-
|
247 |
-
if count_header:
|
248 |
-
total_users = int(count_header.split("/")[1])
|
249 |
|
250 |
# Obter número total de estilistas
|
251 |
-
stylists_url = f"{SUPABASE_URL}/rest/v1/User?role=eq.stylist&select=
|
252 |
-
stylists_response = requests.get(
|
253 |
-
stylists_url,
|
254 |
-
headers={**SUPABASE_HEADERS, "Prefer": "count=exact"}
|
255 |
-
)
|
256 |
|
257 |
total_stylists = 0
|
258 |
if stylists_response.status_code == 200:
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
|
263 |
return {
|
264 |
"total_users": total_users,
|
@@ -272,7 +264,7 @@ def get_platform_users() -> Dict[str, Any]:
|
|
272 |
"total_stylists": 0,
|
273 |
"error": str(e)
|
274 |
}
|
275 |
-
|
276 |
@router.get("/admin/dashboard")
|
277 |
def get_admin_dashboard(
|
278 |
user_token: str = Header(None, alias="User-key"),
|
|
|
235 |
"""Obtém informações sobre usuários e estilistas da plataforma"""
|
236 |
try:
|
237 |
# Obter número total de usuários
|
238 |
+
users_url = f"{SUPABASE_URL}/rest/v1/User?select=id"
|
239 |
+
users_response = requests.get(users_url, headers=SUPABASE_HEADERS)
|
|
|
|
|
|
|
240 |
|
241 |
total_users = 0
|
242 |
if users_response.status_code == 200:
|
243 |
+
total_users = len(users_response.json())
|
|
|
|
|
244 |
|
245 |
# Obter número total de estilistas
|
246 |
+
stylists_url = f"{SUPABASE_URL}/rest/v1/User?role=eq.stylist&select=id"
|
247 |
+
stylists_response = requests.get(stylists_url, headers=SUPABASE_HEADERS)
|
|
|
|
|
|
|
248 |
|
249 |
total_stylists = 0
|
250 |
if stylists_response.status_code == 200:
|
251 |
+
total_stylists = len(stylists_response.json())
|
252 |
+
|
253 |
+
logger.info(f"Total de usuários: {total_users}, Total de estilistas: {total_stylists}")
|
254 |
|
255 |
return {
|
256 |
"total_users": total_users,
|
|
|
264 |
"total_stylists": 0,
|
265 |
"error": str(e)
|
266 |
}
|
267 |
+
|
268 |
@router.get("/admin/dashboard")
|
269 |
def get_admin_dashboard(
|
270 |
user_token: str = Header(None, alias="User-key"),
|