refactor(lolstats): switch from MCP to op.gg REST API for fresh data

- Profile now fetched via REST API (summoner lookup + summary endpoint)
- Match history via REST API games endpoint (proper JSON, no parser)
- All 10 players per game returned directly (no separate detail fetch)
- DDragon champion ID→name mapping loaded at startup
- Fixed summoner_id lookup to use # separator (was using - which failed)
- MCP kept as fallback for match detail and edge cases
- Frontend: find "me" by summoner name instead of assuming index 0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel 2026-03-06 21:41:48 +01:00
parent f4c8cce2f9
commit 87279933c3
2 changed files with 406 additions and 326 deletions

View file

@ -266,10 +266,18 @@ export default function LolstatsTab({ data }: { data: any }) {
doSearch(r.game_name, r.tag_line, r.region);
}, [doSearch]);
// ── Find "me" in participants ──
const findMe = useCallback((match: MatchEntry): MatchParticipant | null => {
if (!profile) return match.participants?.[0] ?? null;
const myName = profile.game_name.toLowerCase();
return match.participants?.find(
p => p.summoner?.game_name?.toLowerCase() === myName,
) ?? match.participants?.[0] ?? null;
}, [profile]);
// ── Render Match Row ──
const renderMatch = (match: MatchEntry) => {
// The participant is the target summoner (first and only in list from matches endpoint)
const me = match.participants?.[0];
const me = findMe(match);
if (!me) return null;
const isWin = me.stats?.result === 'WIN';