Commit d7626367 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: profile API uses select=* to avoid missing column errors

Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent ed5f1c6c
...@@ -19,12 +19,13 @@ $method = $_SERVER['REQUEST_METHOD']; ...@@ -19,12 +19,13 @@ $method = $_SERVER['REQUEST_METHOD'];
if ($method === 'GET') { if ($method === 'GET') {
$targetId = $_GET['id'] ?? $userId; $targetId = $_GET['id'] ?? $userId;
$db = supabase($token); $db = supabase($token);
$profile = $db->getOne('profiles', ['id' => 'eq.' . $targetId, 'select' => 'id,username,display_name,display_name_ar,avatar_url,frame_id,border_color,level,xp,coins,gems,country_code,is_online,elo_bullet,elo_blitz,elo_rapid,elo_classical,games_played,games_won,games_lost,games_drawn,current_streak,best_streak,created_at']); $profiles = $db->get('profiles', ['id' => 'eq.' . $targetId, 'select' => '*', 'limit' => 1]);
if (!$profile || isset($profile['error'])) { if (!is_array($profiles) || isset($profiles['error']) || empty($profiles)) {
jsonError('Profile not found', 404); jsonError('Profile not found', 404);
} }
$profile = $profiles[0];
$ratings = $db->get('player_game_ratings', ['player_id' => 'eq.' . $targetId, 'select' => 'game_key,time_control,rating,games_played,wins,losses,draws']); $ratings = $db->get('player_game_ratings', ['player_id' => 'eq.' . $targetId, 'select' => 'game_key,time_control,rating,games_played,wins,losses,draws']);
$profile['ratings'] = is_array($ratings) && !isset($ratings['error']) ? $ratings : []; $profile['ratings'] = is_array($ratings) && !isset($ratings['error']) ? $ratings : [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment