make bun run check pass

This commit is contained in:
2026-03-13 17:29:59 +01:00
parent ed11001e8d
commit 893309b308
5 changed files with 30 additions and 15 deletions

View File

@@ -3,7 +3,6 @@ import { match, matchQueue, matchParticipantPlayer, playerRating } from '$lib/se
import { eq, asc, sql, inArray, lt } from 'drizzle-orm'; import { eq, asc, sql, inArray, lt } from 'drizzle-orm';
import { MATCH_STATES } from './types'; import { MATCH_STATES } from './types';
import { createMatch } from './engine'; import { createMatch } from './engine';
import { selectMappoolForRating } from './rating';
const QUEUE_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes const QUEUE_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes
@@ -202,6 +201,11 @@ async function selectMappoolForRating(avgElo: number) {
return bestPool; return bestPool;
} }
function getAverageMappoolSR(pool): number { function getAverageMappoolSR(pool: { slots: { starRating: number | null }[] }): number {
return pool.slots.reduce((acc, slot) => acc + slot.starRating!, 0) / pool.slots.length; return (
pool.slots.reduce(
(acc: number, slot: { starRating: number | null }) => acc + (slot.starRating ?? 0),
0
) / pool.slots.length
);
} }

View File

@@ -366,10 +366,13 @@
</p> </p>
{#if m.mappool} {#if m.mappool}
<p class="text-xs text-text-secondary"> <p class="text-xs text-text-secondary">
<a <button
href="/mappools/{m.mappool.id}" onclick={(e) => {
onclick={(e) => e.stopPropagation()} e.preventDefault();
class="hover:text-accent hover:underline">{m.mappool.name}</a e.stopPropagation();
window.location.href = `/mappools/${m.mappool!.id}`;
}}
class="hover:text-accent hover:underline">{m.mappool.name}</button
>{#if avgSR(m.mappool)} >{#if avgSR(m.mappool)}
({avgSR(m.mappool)}★){/if} ({avgSR(m.mappool)}★){/if}
</p> </p>

View File

@@ -80,7 +80,7 @@ export const load: PageServerLoad = async () => {
}) })
); );
const topTeams = teamsWithDetails.filter(Boolean); const topTeams = teamsWithDetails.filter((x): x is NonNullable<typeof x> => Boolean(x));
// ── High scores — sorted by pp (nulls last) then score ── // ── High scores — sorted by pp (nulls last) then score ──
const recentHighScores = await db const recentHighScores = await db
@@ -131,7 +131,7 @@ export const load: PageServerLoad = async () => {
matchId: s.game.matchId matchId: s.game.matchId
}; };
}) })
).then((rows) => rows.filter(Boolean)); ).then((rows) => rows.filter((x): x is NonNullable<typeof x> => Boolean(x)));
return { return {
topPlayers: playersWithUsers, topPlayers: playersWithUsers,

View File

@@ -55,15 +55,22 @@
const MOD_ORDER = ['NM', 'HD', 'HR', 'DT', 'FM', 'TB']; const MOD_ORDER = ['NM', 'HD', 'HR', 'DT', 'FM', 'TB'];
// Group mappool slots by category // Group mappool slots by category
type MappoolSlot = {
id: string;
beatmapId: string;
category: string;
orderInCategory: number;
starRating: number | null;
};
const groupedSlots = $derived(() => { const groupedSlots = $derived(() => {
if (!m.mappool?.slots) return {}; if (!m.mappool?.slots) return {} as Record<string, MappoolSlot[]>;
const groups: Record<string, unknown[]> = {}; const groups: Record<string, MappoolSlot[]> = {};
for (const slot of m.mappool.slots) { for (const slot of m.mappool.slots as MappoolSlot[]) {
if (!groups[slot.category]) groups[slot.category] = []; if (!groups[slot.category]) groups[slot.category] = [];
groups[slot.category].push(slot); groups[slot.category].push(slot);
} }
for (const cat of Object.keys(groups)) { for (const cat of Object.keys(groups)) {
groups[cat].sort((a: unknown, b: unknown) => a.orderInCategory - b.orderInCategory); groups[cat].sort((a, b) => a.orderInCategory - b.orderInCategory);
} }
// Return entries sorted by canonical mod order // Return entries sorted by canonical mod order
return Object.fromEntries( return Object.fromEntries(
@@ -97,10 +104,10 @@
// Mappool avg SR // Mappool avg SR
const mappoolAvgSR = $derived(() => { const mappoolAvgSR = $derived(() => {
const slots = m.mappool?.slots; const slots = m.mappool?.slots as MappoolSlot[] | undefined;
if (!slots?.length) return null; if (!slots?.length) return null;
const avg = const avg =
slots.reduce((sum: number, s: unknown) => sum + (s.starRating ?? 0), 0) / slots.length; slots.reduce((sum: number, s: MappoolSlot) => sum + (s.starRating ?? 0), 0) / slots.length;
return avg.toFixed(2); return avg.toFixed(2);
}); });

View File

@@ -161,6 +161,7 @@
class="mb-3 flex items-center gap-2" class="mb-3 flex items-center gap-2"
> >
<input type="hidden" name="teamId" value={t.id} /> <input type="hidden" name="teamId" value={t.id} />
<!-- svelte-ignore a11y_autofocus -->
<input <input
type="text" type="text"
name="name" name="name"