- Fix bank deposit/withdraw paths: /bank/deposit → /bank/deposit/item (and withdraw) - Fix cooldown error handling: 498 is "character not found" (raise immediately), 499 is "character in cooldown" (wait and retry) — was previously swapped - Fix events endpoint: use /events/active instead of /events for active game events - Fix action rate limiter: 7/2s → 20/2s to match actual API limits - Use page_size=10000 for static data pagination (items/monsters/resources/maps) to minimize API round-trips during cache refresh - Add missing character fields from API: wisdom, prospecting, initiative, threat, dmg, layer, map_id, effects, rune_slot, bag_slot, and *_max_xp for all skills - Fix skill bars to use actual max_xp from API instead of xp % 100 - Add rune_slot and bag_slot to equipment constants https://claude.ai/code/session_015BJtuNcKqcdqSJETj5xRjX
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
import logging
|
|
|
|
from fastapi import APIRouter, HTTPException, Request
|
|
from httpx import HTTPStatusError
|
|
|
|
from app.api.deps import get_user_client
|
|
from app.schemas.game import DashboardData
|
|
from app.services.character_service import CharacterService
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
router = APIRouter(prefix="/api", tags=["dashboard"])
|
|
|
|
|
|
def _get_service(request: Request) -> CharacterService:
|
|
return request.app.state.character_service
|
|
|
|
|
|
@router.get("/dashboard", response_model=DashboardData)
|
|
async def get_dashboard(request: Request) -> DashboardData:
|
|
"""Return aggregated dashboard data: all characters + server status."""
|
|
client = get_user_client(request)
|
|
service = _get_service(request)
|
|
|
|
try:
|
|
characters = await service.get_all(client)
|
|
except HTTPStatusError as exc:
|
|
raise HTTPException(
|
|
status_code=exc.response.status_code,
|
|
detail=f"Artifacts API error: {exc.response.text}",
|
|
) from exc
|
|
|
|
# Server status could be extended later (e.g., ping, event info)
|
|
server_status: dict | None = None
|
|
try:
|
|
events = await client.get_active_events()
|
|
server_status = {"events": events}
|
|
except Exception:
|
|
logger.warning("Failed to fetch server events for dashboard", exc_info=True)
|
|
|
|
return DashboardData(
|
|
characters=characters,
|
|
server_status=server_status,
|
|
)
|