feat: add bpm and totalLength fields to mappool slots and display average star rating in mappools list

This commit is contained in:
2026-03-01 04:36:06 +01:00
parent e0c021782c
commit 6861c6c178
3 changed files with 8 additions and 1 deletions

View File

@@ -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()
});

View File

@@ -53,7 +53,9 @@
<div class="mt-6 flex flex-col gap-3">
{#each data.mappools as pool}
<a
{@const rated = pool.slots.filter((s: any) => s.starRating != null)}
{@const avgSr = rated.length > 0 ? (rated.reduce((sum: number, s: any) => sum + s.starRating, 0) / rated.length).toFixed(2) : null}
<a
href="/mappools/{pool.id}"
class="group flex items-center justify-between rounded-lg border border-border bg-surface-800 p-4 transition-colors hover:border-accent/40 hover:bg-surface-700"
>
@@ -61,6 +63,7 @@
<h2 class="text-sm font-600">{pool.name}</h2>
<p class="mt-1 text-xs text-text-secondary">
{pool.slots.length} map{pool.slots.length !== 1 ? 's' : ''}
{#if avgSr}· ★ {avgSr}{/if}
· Created {new Date(pool.createdAt).toLocaleDateString()}
</p>
</div>

View File

@@ -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]
});