Make group round grouping configurable
SteamWarCI Build successful

- Add round grouping time and prefix to group view config
- Use the new settings in group display and editor defaults
This commit is contained in:
2026-05-07 16:28:51 +02:00
parent fc53376c73
commit b98f197d14
3 changed files with 60 additions and 10 deletions
+6 -7
View File
@@ -15,12 +15,10 @@
config: GroupViewConfig;
} = $props();
// Groups fights into rounds: a round starts at the first fight's start;
// all fights starting within 10 minutes (600_000 ms) of that are in the same round.
function detectRounds(fights: EventFight[]): EventFight[][] {
function detectRounds(fights: EventFight[], groupingTimeMinutes: number): EventFight[][] {
if (!fights || fights.length === 0) return [];
const TEN_MIN_MS = 10 * 60 * 1000;
const groupingTimeMs = Math.max(1, Math.floor(groupingTimeMinutes || 10)) * 60 * 1000;
const sorted = [...fights].sort((a, b) => a.start - b.start);
const rounds: EventFight[][] = [];
@@ -28,7 +26,7 @@
let roundStart = sorted[0].start;
for (const fight of sorted) {
if (fight.start - roundStart <= TEN_MIN_MS) {
if (fight.start - roundStart <= groupingTimeMs) {
currentRound.push(fight);
} else {
if (currentRound.length) rounds.push(currentRound);
@@ -61,8 +59,9 @@
{#each config.groups as groupId}
{@const group = event.groups.find((g) => g.id === groupId)!!}
{@const fights = event.fights.filter((f) => f.group?.id === groupId)}
{@const rounds = detectRounds(fights)}
{@const rounds = detectRounds(fights, config.roundGroupingTimeMinutes ?? 10)}
{@const roundRows = config.roundRows ?? 1}
{@const roundPrefix = config.roundPrefix ?? "Runde"}
{@const roundRowsChunked = chunkIntoRows(rounds, roundRows)}
<div class="flex">
<div>
@@ -83,7 +82,7 @@
{@const roundIndex = rounds.indexOf(round)}
{@const teams = Array.from(new Set(round.flatMap((f) => [f.redTeam, f.blueTeam])))}
<div class="{hover.currentHover && !teams.some((t) => t?.id === hover.currentHover) ? 'opacity-30' : ''} transition-opacity">
<EventCard title="Runde {roundIndex + 1}">
<EventCard title={`${roundPrefix} ${roundIndex + 1}`}>
{#each round as fight}
<EventFightChip {event} {fight} {group} />
{/each}
+2
View File
@@ -4,6 +4,8 @@ export const GroupViewSchema = z.object({
type: z.literal("GROUP"),
groups: z.array(z.number()),
roundRows: z.number().int().positive().optional().default(1),
roundGroupingTimeMinutes: z.number().int().positive().optional().default(10),
roundPrefix: z.enum(["Runde", "Tag"]).optional().default("Runde"),
});
export type GroupViewConfig = z.infer<typeof GroupViewSchema>;