Fix battle-logs returning 0 results — replace SQB field names with TSS name field
bestTeamName and canonicalTeamName were checking tag_name/short_name/long_name (SQB API fields) which don't exist on TSS team objects. Every team resolved to an empty string so fetchRecentTssGames bailed out immediately with no matches. Also clean up all other references to those dead fields throughout the component. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+13
-18
@@ -104,7 +104,7 @@ function formatDate(timestamp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function bestTeamName(team) {
|
function bestTeamName(team) {
|
||||||
return team?.tag_name || team?.short_name || team?.long_name || ''
|
return team?.name || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
function teamDetailLooksReal(detail) {
|
function teamDetailLooksReal(detail) {
|
||||||
@@ -125,7 +125,7 @@ function teamDetailLooksReal(detail) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function canonicalTeamName(detail, fallback = '') {
|
function canonicalTeamName(detail, fallback = '') {
|
||||||
return detail?.tag_name || detail?.short_name || detail?.long_name || fallback
|
return detail?.name || fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeAnalyticsPreferences(value) {
|
function normalizeAnalyticsPreferences(value) {
|
||||||
@@ -564,8 +564,7 @@ async function fetchRecentTssGames(teams, signal) {
|
|||||||
|
|
||||||
bySession.set(game.session_id, {
|
bySession.set(game.session_id, {
|
||||||
...game,
|
...game,
|
||||||
team_name: data.tag_name || name,
|
team_name: data.name || name,
|
||||||
long_name: data.long_name || '',
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -1067,8 +1066,8 @@ function AppContent() {
|
|||||||
const results = (data.teams || data.results || [])
|
const results = (data.teams || data.results || [])
|
||||||
.map((team) => ({
|
.map((team) => ({
|
||||||
name: bestTeamName(team),
|
name: bestTeamName(team),
|
||||||
detail: team.long_name || team.short_name || '',
|
detail: '',
|
||||||
aliases: [team.tag_name, team.short_name, team.long_name].filter(Boolean),
|
aliases: [team.name].filter(Boolean),
|
||||||
}))
|
}))
|
||||||
.filter((team) => team.name)
|
.filter((team) => team.name)
|
||||||
.slice(0, 10)
|
.slice(0, 10)
|
||||||
@@ -1079,8 +1078,8 @@ function AppContent() {
|
|||||||
if (!controller.signal.aborted) {
|
if (!controller.signal.aborted) {
|
||||||
fetchJson(apiEndpoints.resolve(query), controller.signal)
|
fetchJson(apiEndpoints.resolve(query), controller.signal)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
const name = data.tag_name || data.short_name || data.long_name || ''
|
const name = data.name || ''
|
||||||
setTeamSearchResults(name ? [{ name, detail: data.long_name || data.short_name || '', aliases: [name] }] : [])
|
setTeamSearchResults(name ? [{ name, detail: '', aliases: [name] }] : [])
|
||||||
setSearchHint(name ? { status: 'ready', name } : { status: 'error', name: '' })
|
setSearchHint(name ? { status: 'ready', name } : { status: 'error', name: '' })
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@@ -1440,8 +1439,8 @@ function AppContent() {
|
|||||||
return teams
|
return teams
|
||||||
.map((team) => {
|
.map((team) => {
|
||||||
const name = bestTeamName(team)
|
const name = bestTeamName(team)
|
||||||
const aliases = [team.tag_name, team.short_name, team.long_name].filter(Boolean)
|
const aliases = [team.name].filter(Boolean)
|
||||||
return { name, detail: team.long_name || team.short_name || '', aliases }
|
return { name, detail: '', aliases }
|
||||||
})
|
})
|
||||||
.filter(({ name, aliases }) => {
|
.filter(({ name, aliases }) => {
|
||||||
if (!name || seen.has(name)) return false
|
if (!name || seen.has(name)) return false
|
||||||
@@ -1466,7 +1465,7 @@ function AppContent() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const resolved = await fetchJson(apiEndpoints.resolve(name))
|
const resolved = await fetchJson(apiEndpoints.resolve(name))
|
||||||
const resolvedName = resolved.tag_name || resolved.short_name || resolved.long_name
|
const resolvedName = resolved.name
|
||||||
if (!resolvedName) throw new Error('Team not found')
|
if (!resolvedName) throw new Error('Team not found')
|
||||||
|
|
||||||
const detail = await fetchJson(apiEndpoints.detail(resolvedName))
|
const detail = await fetchJson(apiEndpoints.detail(resolvedName))
|
||||||
@@ -2846,9 +2845,6 @@ function TeamsPage({ leaderboard, navigate, teams }) {
|
|||||||
<span className="text-sm font-semibold text-fury-cyan">#{index + 1}</span>
|
<span className="text-sm font-semibold text-fury-cyan">#{index + 1}</span>
|
||||||
<span className="min-w-0">
|
<span className="min-w-0">
|
||||||
<span className="block truncate text-lg font-semibold">{name}</span>
|
<span className="block truncate text-lg font-semibold">{name}</span>
|
||||||
<span className="block truncate text-xs text-text-soft">
|
|
||||||
{team.long_name || team.short_name || 'Unresolved'}
|
|
||||||
</span>
|
|
||||||
</span>
|
</span>
|
||||||
<span className="text-sm">{formatNumber(team.player_count)} players</span>
|
<span className="text-sm">{formatNumber(team.player_count)} players</span>
|
||||||
<span className="text-sm">{formatNumber(team.total_battles)} battles</span>
|
<span className="text-sm">{formatNumber(team.total_battles)} battles</span>
|
||||||
@@ -2879,8 +2875,7 @@ function TeamProfilePage({ navigate, profile, requestedTeam, teams }) {
|
|||||||
const ratingHourly = profile.history.data?.rating_hourly || []
|
const ratingHourly = profile.history.data?.rating_hourly || []
|
||||||
const latestRating = ratingHourly.at(-1)?.rating || summary?.points?.total_points
|
const latestRating = ratingHourly.at(-1)?.rating || summary?.points?.total_points
|
||||||
const leaderboardTeam = teams.find((team) => bestTeamName(team) === requestedTeam)
|
const leaderboardTeam = teams.find((team) => bestTeamName(team) === requestedTeam)
|
||||||
const displayName = detail?.tag_name || bestTeamName(leaderboardTeam) || requestedTeam
|
const displayName = detail?.name || bestTeamName(leaderboardTeam) || requestedTeam
|
||||||
const longName = detail?.long_name || leaderboardTeam?.long_name || ''
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="space-y-6 pt-24 sm:pt-28">
|
<section className="space-y-6 pt-24 sm:pt-28">
|
||||||
@@ -2900,7 +2895,7 @@ function TeamProfilePage({ navigate, profile, requestedTeam, teams }) {
|
|||||||
</p>
|
</p>
|
||||||
<h1 className="mt-1 text-4xl font-bold">{displayName}</h1>
|
<h1 className="mt-1 text-4xl font-bold">{displayName}</h1>
|
||||||
<p className="mt-2 text-sm text-text-soft">
|
<p className="mt-2 text-sm text-text-soft">
|
||||||
{profile.detail.error || longName || profile.detail.status}
|
{profile.detail.error || ''}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-2 gap-3 text-sm sm:grid-cols-3">
|
<div className="grid grid-cols-2 gap-3 text-sm sm:grid-cols-3">
|
||||||
@@ -3090,7 +3085,7 @@ function BattleLogsPage({ live, matches }) {
|
|||||||
<p className="truncate font-semibold text-fury-cyan">
|
<p className="truncate font-semibold text-fury-cyan">
|
||||||
{match.team_name || 'TSS team'}
|
{match.team_name || 'TSS team'}
|
||||||
</p>
|
</p>
|
||||||
<p className="truncate text-xs text-text-soft">{match.long_name || 'TSS battle record'}</p>
|
<p className="truncate text-xs text-text-soft">TSS battle record</p>
|
||||||
</div>
|
</div>
|
||||||
<p
|
<p
|
||||||
className={`w-fit rounded-md px-3 py-1 text-sm font-semibold ${String(match.result).toLowerCase() === 'win'
|
className={`w-fit rounded-md px-3 py-1 text-sm font-semibold ${String(match.result).toLowerCase() === 'win'
|
||||||
|
|||||||
Reference in New Issue
Block a user