From 6861c6c1787dabd91700c6ae439c7aa0aca3b314 Mon Sep 17 00:00:00 2001 From: Stan Runge Date: Sun, 1 Mar 2026 04:36:06 +0100 Subject: [PATCH] feat: add bpm and totalLength fields to mappool slots and display average star rating in mappools list --- src/lib/server/db/schema.ts | 2 ++ src/routes/(app)/mappools/+page.svelte | 5 ++++- src/routes/(app)/mappools/[id]/+page.server.ts | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/server/db/schema.ts b/src/lib/server/db/schema.ts index 5db2b77..ff6ba5a 100644 --- a/src/lib/server/db/schema.ts +++ b/src/lib/server/db/schema.ts @@ -58,6 +58,8 @@ export const mappoolSlot = pgTable('mappool_slot', { orderInCategory: integer('order_in_category').notNull(), beatmapId: text('beatmap_id').notNull(), starRating: real('star_rating'), + bpm: real('bpm'), + totalLength: integer('total_length'), mods: text('mods').array().default([]).notNull() }); diff --git a/src/routes/(app)/mappools/+page.svelte b/src/routes/(app)/mappools/+page.svelte index e91c78f..3d8a7b3 100644 --- a/src/routes/(app)/mappools/+page.svelte +++ b/src/routes/(app)/mappools/+page.svelte @@ -53,7 +53,9 @@
{#each data.mappools as pool} - s.starRating != null)} + {@const avgSr = rated.length > 0 ? (rated.reduce((sum: number, s: any) => sum + s.starRating, 0) / rated.length).toFixed(2) : null} + @@ -61,6 +63,7 @@

{pool.name}

{pool.slots.length} map{pool.slots.length !== 1 ? 's' : ''} + {#if avgSr}· ★ {avgSr}{/if} · Created {new Date(pool.createdAt).toLocaleDateString()}

diff --git a/src/routes/(app)/mappools/[id]/+page.server.ts b/src/routes/(app)/mappools/[id]/+page.server.ts index f582417..ebc2fcd 100644 --- a/src/routes/(app)/mappools/[id]/+page.server.ts +++ b/src/routes/(app)/mappools/[id]/+page.server.ts @@ -110,6 +110,8 @@ export const actions: Actions = { category, orderInCategory: existing.length + 1, starRating: beatmap.difficulty_rating, + bpm: beatmap.bpm, + totalLength: beatmap.total_length, mods: category === 'NM' || category === 'TB' || category === 'FM' ? [] : [category] });