feat: add bpm and totalLength fields to mappool slots and display average star rating in mappools list
This commit is contained in:
@@ -58,6 +58,8 @@ export const mappoolSlot = pgTable('mappool_slot', {
|
|||||||
orderInCategory: integer('order_in_category').notNull(),
|
orderInCategory: integer('order_in_category').notNull(),
|
||||||
beatmapId: text('beatmap_id').notNull(),
|
beatmapId: text('beatmap_id').notNull(),
|
||||||
starRating: real('star_rating'),
|
starRating: real('star_rating'),
|
||||||
|
bpm: real('bpm'),
|
||||||
|
totalLength: integer('total_length'),
|
||||||
mods: text('mods').array().default([]).notNull()
|
mods: text('mods').array().default([]).notNull()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,9 @@
|
|||||||
|
|
||||||
<div class="mt-6 flex flex-col gap-3">
|
<div class="mt-6 flex flex-col gap-3">
|
||||||
{#each data.mappools as pool}
|
{#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}"
|
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"
|
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>
|
<h2 class="text-sm font-600">{pool.name}</h2>
|
||||||
<p class="mt-1 text-xs text-text-secondary">
|
<p class="mt-1 text-xs text-text-secondary">
|
||||||
{pool.slots.length} map{pool.slots.length !== 1 ? 's' : ''}
|
{pool.slots.length} map{pool.slots.length !== 1 ? 's' : ''}
|
||||||
|
{#if avgSr}· ★ {avgSr}{/if}
|
||||||
· Created {new Date(pool.createdAt).toLocaleDateString()}
|
· Created {new Date(pool.createdAt).toLocaleDateString()}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ export const actions: Actions = {
|
|||||||
category,
|
category,
|
||||||
orderInCategory: existing.length + 1,
|
orderInCategory: existing.length + 1,
|
||||||
starRating: beatmap.difficulty_rating,
|
starRating: beatmap.difficulty_rating,
|
||||||
|
bpm: beatmap.bpm,
|
||||||
|
totalLength: beatmap.total_length,
|
||||||
mods: category === 'NM' || category === 'TB' || category === 'FM' ? [] : [category]
|
mods: category === 'NM' || category === 'TB' || category === 'FM' ? [] : [category]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user