Commit 3284fc48 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: standings crash — Swiss API response wrapped in {data:[...]}

Controller was passing the raw response body (which has data + roundNumber
keys) directly to the view. The foreach iterated over the wrapper object
instead of the standings array.

Also fixed field name mappings: Swiss API uses 'name' not 'player_name',
'gamesPlayed' not 'games_played', 'tiebreakValues' array not 'tiebreak'.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent a22905bb
......@@ -74,7 +74,8 @@ class TournamentsController
if (in_array($tournament['status'], ['in_progress', 'completed']) && !empty($tournament['swiss_api_tournament_id'])) {
$response = SwissApiService::getStandings($tournament['swiss_api_tournament_id']);
if (SwissApiService::isSuccess($response)) {
$standings = $response['body'] ?? [];
$body = $response['body'] ?? [];
$standings = $body['data'] ?? $body ?? [];
}
}
......
......@@ -409,16 +409,16 @@ $tabs['arbiter'] = 'أدوات الحكم';
<tr class="<?= $i < 3 ? 'standing-top' : '' ?>">
<td>
<span class="standing-rank <?= $i === 0 ? 'rank-gold' : ($i === 1 ? 'rank-silver' : ($i === 2 ? 'rank-bronze' : '')) ?>">
<?= $standing['rank'] ?? ($i + 1) ?>
<?= (int)($standing['rank'] ?? ($i + 1)) ?>
</span>
</td>
<td class="font-medium"><?= View::e($standing['player_name'] ?? $standing['player_id'] ?? '-') ?></td>
<td class="font-medium"><?= View::e($standing['name'] ?? $standing['player_name'] ?? '-') ?></td>
<td class="tabular-nums font-medium"><?= $standing['points'] ?? 0 ?></td>
<td class="tabular-nums"><?= $standing['games_played'] ?? 0 ?></td>
<td class="tabular-nums"><?= $standing['gamesPlayed'] ?? $standing['games_played'] ?? 0 ?></td>
<td class="tabular-nums"><?= $standing['wins'] ?? 0 ?></td>
<td class="tabular-nums"><?= $standing['draws'] ?? 0 ?></td>
<td class="tabular-nums"><?= $standing['losses'] ?? 0 ?></td>
<td class="tabular-nums"><?= $standing['tiebreak'] ?? 0 ?></td>
<td class="tabular-nums"><?= is_array($standing['tiebreakValues'] ?? null) ? ($standing['tiebreakValues'][0] ?? 0) : ($standing['tiebreak'] ?? 0) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
......
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