Commit e87eca4e authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: chess bots not showing - extract bots array from API response

API returns {bots: [...], count: N} not a flat array.
Also fixed pool stats mapping (pool_alive/pool_idle) and portrait URLs
to use full Stockfish API base URL.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 7bd2a58e
......@@ -8,7 +8,7 @@ class ChessBotsController
$bots = [];
if ($response['status'] === 200 && is_array($response['body'])) {
$bots = $response['body'];
$bots = $response['body']['bots'] ?? $response['body'];
}
$poolResponse = ApiProxy::stockfish('GET', '/api/manage/pool');
......
......@@ -14,7 +14,7 @@
</div>
<div class="stat-card-content">
<span class="stat-card-label">المحركات النشطة</span>
<span class="stat-card-value" id="poolActive"><?= $pool['active_engines'] ?? '-' ?></span>
<span class="stat-card-value" id="poolActive"><?= $pool['pool_alive'] ?? '-' ?></span>
</div>
</div>
<div class="stat-card">
......@@ -23,7 +23,7 @@
</div>
<div class="stat-card-content">
<span class="stat-card-label">المحركات المتاحة</span>
<span class="stat-card-value" id="poolAvailable"><?= $pool['available_engines'] ?? '-' ?></span>
<span class="stat-card-value" id="poolAvailable"><?= $pool['pool_idle'] ?? '-' ?></span>
</div>
</div>
<div class="stat-card">
......@@ -32,7 +32,7 @@
</div>
<div class="stat-card-content">
<span class="stat-card-label">المحركات المشغولة</span>
<span class="stat-card-value" id="poolBusy"><?= $pool['busy_engines'] ?? '-' ?></span>
<span class="stat-card-value" id="poolBusy"><?= ($pool['pool_alive'] ?? 0) - ($pool['pool_idle'] ?? 0) ?></span>
</div>
</div>
<div class="stat-card">
......@@ -40,8 +40,8 @@
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20V10"/><path d="M18 20V4"/><path d="M6 20v-4"/></svg>
</div>
<div class="stat-card-content">
<span class="stat-card-label">الطلبات/دقيقة</span>
<span class="stat-card-value" id="poolRpm"><?= $pool['requests_per_minute'] ?? '-' ?></span>
<span class="stat-card-label">الاستخدام</span>
<span class="stat-card-value" id="poolRpm"><?= $pool['pool_utilization'] ?? '-' ?></span>
</div>
</div>
</div>
......@@ -61,7 +61,7 @@
<div class="bot-card-header">
<div class="bot-portrait">
<?php if (!empty($bot['portrait_url'])): ?>
<img src="<?= View::e($bot['portrait_url'] ?? '') ?>" alt="<?= View::e($bot['name'] ?? '') ?>">
<img src="<?= STOCKFISH_API_URL . View::e($bot['portrait_url']) ?>" alt="<?= View::e($bot['name'] ?? '') ?>">
<?php else: ?>
<div class="bot-portrait-placeholder">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2a3 3 0 0 0-3 3v1a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"/><path d="M19 10H5a2 2 0 0 0-2 2v1a7 7 0 0 0 14 0v-1a2 2 0 0 0-2-2z"/><line x1="12" y1="18" x2="12" y2="22"/></svg>
......
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