fix: scope team page scorers by teamId instead of filtering global top 200

Teams with few goals (e.g. Qatar) were missing from the sidebar because
topScorers(limit:200) only returned all-time top scorers. Now the query
filters by teamId in SQL so every team shows their own scorers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-14 21:11:16 +02:00
parent 9b8e266f88
commit 6e6e819718
3 changed files with 11 additions and 11 deletions
+4 -6
View File
@@ -56,18 +56,16 @@ export default function TeamPage({ params }: { params: Promise<{ slug: string }>
skip: !team?.id,
})
// Load all scorers to filter by team
const { data: scorerData } = useQuery(gql`
query TeamScorers {
topScorers(limit: 200) {
query TeamScorers($teamId: Int!) {
topScorers(teamId: $teamId, limit: 30) {
playerName goals penalties ownGoals tournaments
team { id name iso2 }
}
}
`)
`, { variables: { teamId: team?.id ?? 0 }, skip: !team?.id })
const allScorers = scorerData?.topScorers ?? []
const teamScorers = team ? allScorers.filter((s: { team?: { id: number } | null }) => s.team?.id === team.id).slice(0, 15) : []
const teamScorers = scorerData?.topScorers ?? []
const teamMatches: MatchRow[] = matchesData?.matches ?? []
// Group matches by year for the history display