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 { MATCH_STATES } from './types';
import { createMatch } from './engine';
import { selectMappoolForRating } from './rating';
const QUEUE_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes
@@ -202,6 +201,11 @@ async function selectMappoolForRating(avgElo: number) {
return bestPool;
}
function getAverageMappoolSR(pool): number {
return pool.slots.reduce((acc, slot) => acc + slot.starRating!, 0) / pool.slots.length;
function getAverageMappoolSR(pool: { slots: { starRating: number | null }[] }): number {
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>
{#if m.mappool}
<p class="text-xs text-text-secondary">
<a
href="/mappools/{m.mappool.id}"
onclick={(e) => e.stopPropagation()}
class="hover:text-accent hover:underline">{m.mappool.name}</a
<button
onclick={(e) => {
e.preventDefault();
e.stopPropagation();
window.location.href = `/mappools/${m.mappool!.id}`;
}}
class="hover:text-accent hover:underline">{m.mappool.name}</button
>{#if avgSR(m.mappool)}
({avgSR(m.mappool)}★){/if}
</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 ──
const recentHighScores = await db
@@ -131,7 +131,7 @@ export const load: PageServerLoad = async () => {
matchId: s.game.matchId
};
})
).then((rows) => rows.filter(Boolean));
).then((rows) => rows.filter((x): x is NonNullable<typeof x> => Boolean(x)));
return {
topPlayers: playersWithUsers,

View File

@@ -55,15 +55,22 @@
const MOD_ORDER = ['NM', 'HD', 'HR', 'DT', 'FM', 'TB'];
// Group mappool slots by category
type MappoolSlot = {
id: string;
beatmapId: string;
category: string;
orderInCategory: number;
starRating: number | null;
};
const groupedSlots = $derived(() => {
if (!m.mappool?.slots) return {};
const groups: Record<string, unknown[]> = {};
for (const slot of m.mappool.slots) {
if (!m.mappool?.slots) return {} as Record<string, MappoolSlot[]>;
const groups: Record<string, MappoolSlot[]> = {};
for (const slot of m.mappool.slots as MappoolSlot[]) {
if (!groups[slot.category]) groups[slot.category] = [];
groups[slot.category].push(slot);
}
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 Object.fromEntries(
@@ -97,10 +104,10 @@
// Mappool avg SR
const mappoolAvgSR = $derived(() => {
const slots = m.mappool?.slots;
const slots = m.mappool?.slots as MappoolSlot[] | undefined;
if (!slots?.length) return null;
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);
});

View File

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