3 Commits

Author SHA1 Message Date
yohlo
dce31905fc fixes 2025-10-18 23:09:57 -05:00
yohlo
e58ed86d3b fixes 2025-10-17 19:22:07 -05:00
yohlo
d833e5f1a1 Merge branch 'caro/badges-stats' 2025-10-16 15:41:36 -05:00
3 changed files with 43 additions and 7 deletions

View File

@@ -31,7 +31,7 @@ const TeamListItem = React.memo(({ team }: TeamListItemProps) => {
return (
<Group justify="space-between" w="100%" wrap="nowrap">
<Text fw={500} size={teamNameSize} style={{ flexShrink: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
<Text fw={500} size={teamNameSize} style={{ flexShrink: 1, minWidth: 0, maxWidth: 170, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{`${team.name}`}
</Text>
<Stack ml="auto" gap={0} style={{ flexShrink: 0 }}>

View File

@@ -19,7 +19,7 @@ const Header = ({ name, logo, id }: HeaderProps) => {
src={logo && id ? `/api/files/teams/${id}/${logo}` : undefined}
/>
<Flex align="center" justify="center" gap={4} pb={20} w="100%">
<Title ta="center" order={1}>
<Title ta="center" order={name.length > 25 ? 2 : 1}>
{name}
</Title>
</Flex>

View File

@@ -175,6 +175,20 @@ export function createBadgesService(pb: PocketBase) {
const tournamentsAttended = tournamentIds.size;
if (criteria.tournaments_attended !== undefined) {
if (tournamentsAttended === 0 && criteria.tournaments_attended === 0) {
const teams = await pb.collection("teams").getFullList({
filter: `players.id ?~ "${playerId}"`,
expand: 'tournaments',
});
const hasEnrollment = teams.some((team: any) => {
const tournaments = team.tournaments || [];
return tournaments.length > 0;
});
return 0;
}
return tournamentsAttended;
}
@@ -363,9 +377,31 @@ export function createBadgesService(pb: PocketBase) {
for (const tournament of tournaments) {
if (!tournamentIds.has(tournament.id)) continue;
if (tournament.winner_id === playerId) {
consecutiveWins++;
maxConsecutiveWins = Math.max(maxConsecutiveWins, consecutiveWins);
const tournamentMatches = await pb.collection("matches").getFullList({
filter: `tournament = "${tournament.id}" && status = "ended"`,
expand: 'home,away,home.players,away.players',
});
const winnersMatches = tournamentMatches.filter(m => !m.is_losers_bracket);
const finalsMatch = winnersMatches.reduce((highest: any, current: any) =>
(!highest || current.lid > highest.lid) ? current : highest, null);
if (finalsMatch && finalsMatch.status === 'ended') {
const finalsWinnerId = (finalsMatch.home_cups > finalsMatch.away_cups) ? finalsMatch.home : finalsMatch.away;
const winningTeam = finalsMatch.expand?.[finalsWinnerId === finalsMatch.home ? 'home' : 'away'];
const winningPlayers = winningTeam?.expand?.players || winningTeam?.players || [];
const playerWon = winningPlayers.some((p: any) =>
(typeof p === 'string' ? p : p.id) === playerId
);
if (playerWon) {
consecutiveWins++;
maxConsecutiveWins = Math.max(maxConsecutiveWins, consecutiveWins);
} else {
consecutiveWins = 0;
}
} else {
consecutiveWins = 0;
}
@@ -433,8 +469,8 @@ export function createBadgesService(pb: PocketBase) {
const badges = await this.listBadges();
const playerStats = await pb.collection("player_stats").getFullList<PlayerStats>();
const uniquePlayers = new Set(playerStats.map(s => s.player_id));
const allPlayers = await pb.collection("players").getFullList();
const uniquePlayers = new Set(allPlayers.map((p: any) => p.id));
let totalProgressRecords = 0;
let totalBadgesEarned = 0;