From 5d8c4818bef7b6ba71053604fa6d5247261d4d73 Mon Sep 17 00:00:00 2001 From: Jeffdev Date: Mon, 2 Mar 2026 12:03:38 -0700 Subject: [PATCH 1/6] Add live total card --- .../(home)/stats/_components/live-matches-tab.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/(home)/stats/_components/live-matches-tab.tsx b/src/app/(home)/stats/_components/live-matches-tab.tsx index b684149..2ffa888 100644 --- a/src/app/(home)/stats/_components/live-matches-tab.tsx +++ b/src/app/(home)/stats/_components/live-matches-tab.tsx @@ -46,20 +46,21 @@ export function LiveMatchesTab() { onData: (event) => setLiveQueues(event.data), }) - const queues = sortAndFilterQueues(liveQueues ?? initialQueues ?? []) + const allQueues = liveQueues ?? initialQueues ?? [] + const queues = sortAndFilterQueues(allQueues) + const total = allQueues.reduce((sum, q) => sum + q.active_matches, 0) return (
+ {queues.map((queue) => ( - + ))}
) } -function QueueCard({ queue }: { queue: ActiveMatchQueue }) { - const count = queue.active_matches - +function QueueCard({ label, count }: { label: string; count: number }) { return ( @@ -68,7 +69,7 @@ function QueueCard({ queue }: { queue: ActiveMatchQueue }) { - {queue.queue_name} + {label} From d7fc7fd44c09e5334dee47c10895429da770c285 Mon Sep 17 00:00:00 2001 From: Jeffdev Date: Mon, 2 Mar 2026 12:11:56 -0700 Subject: [PATCH 2/6] Remove the sorting and filtering by site The bot api does this now --- .../stats/_components/live-matches-tab.tsx | 35 ++----------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/src/app/(home)/stats/_components/live-matches-tab.tsx b/src/app/(home)/stats/_components/live-matches-tab.tsx index 2ffa888..c2d0325 100644 --- a/src/app/(home)/stats/_components/live-matches-tab.tsx +++ b/src/app/(home)/stats/_components/live-matches-tab.tsx @@ -3,38 +3,8 @@ import { useState } from 'react' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import type { ActiveMatchQueue } from '@/server/services/botlatro.service' -import { - CASUAL_QUEUE_ID, - LEGACY_QUEUE_ID, - RANKED_QUEUE_ID, - SANDBOX_QUEUE_ID, - SMALLWORLD_QUEUE_ID, - VANILLA_QUEUE_ID, -} from '@/shared/constants' import { api } from '@/trpc/react' -const QUEUE_ORDER = [ - Number(RANKED_QUEUE_ID), - Number(LEGACY_QUEUE_ID), - Number(SMALLWORLD_QUEUE_ID), - Number(SANDBOX_QUEUE_ID), - Number(CASUAL_QUEUE_ID), -] - -const HIDDEN_QUEUES = new Set([Number(VANILLA_QUEUE_ID)]) - -function sortAndFilterQueues(queues: ActiveMatchQueue[]): ActiveMatchQueue[] { - return queues - .filter((q) => !HIDDEN_QUEUES.has(q.queue_id)) - .sort((a, b) => { - const ai = QUEUE_ORDER.indexOf(a.queue_id) - const bi = QUEUE_ORDER.indexOf(b.queue_id) - const aOrder = ai === -1 ? QUEUE_ORDER.length : ai - const bOrder = bi === -1 ? QUEUE_ORDER.length : bi - return aOrder - bOrder - }) -} - export function LiveMatchesTab() { const [liveQueues, setLiveQueues] = useState(null) const { data: initialQueues } = api.playerState.getActiveMatches.useQuery( @@ -46,9 +16,8 @@ export function LiveMatchesTab() { onData: (event) => setLiveQueues(event.data), }) - const allQueues = liveQueues ?? initialQueues ?? [] - const queues = sortAndFilterQueues(allQueues) - const total = allQueues.reduce((sum, q) => sum + q.active_matches, 0) + const queues = liveQueues ?? initialQueues ?? [] + const total = queues.reduce((sum, q) => sum + q.active_matches, 0) return (
From 20c5060114eee1138e0a80f3473a6069b2e275b1 Mon Sep 17 00:00:00 2001 From: Jeffdev Date: Mon, 2 Mar 2026 12:19:05 -0700 Subject: [PATCH 3/6] Fix formatting --- src/app/(home)/stats/_components/live-matches-tab.tsx | 4 +++- src/server/api/routers/player-state.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/(home)/stats/_components/live-matches-tab.tsx b/src/app/(home)/stats/_components/live-matches-tab.tsx index c2d0325..5c756c1 100644 --- a/src/app/(home)/stats/_components/live-matches-tab.tsx +++ b/src/app/(home)/stats/_components/live-matches-tab.tsx @@ -23,7 +23,9 @@ export function LiveMatchesTab() {
{queues.map((queue) => ( - + ))}
) diff --git a/src/server/api/routers/player-state.ts b/src/server/api/routers/player-state.ts index 072b4d1..48a4396 100644 --- a/src/server/api/routers/player-state.ts +++ b/src/server/api/routers/player-state.ts @@ -61,7 +61,9 @@ export const playerStateRouter = createTRPCRouter({ ) yield tracked('initial', await botlatro_service.get_active_matches()) for await (const _ of iterator) { - yield tracked(Date.now().toString(), await botlatro_service.get_active_matches()) + yield tracked( + Date.now().toString(), + await botlatro_service.get_active_matches()) } }), }) From 640b756cc8228a34a280c894bebcf8ee469f0228 Mon Sep 17 00:00:00 2001 From: Jeffdev Date: Mon, 2 Mar 2026 12:27:33 -0700 Subject: [PATCH 4/6] Formatting fix and remeda --- .../(home)/stats/_components/live-matches-tab.tsx | 12 +++++++----- src/server/api/routers/player-state.ts | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/app/(home)/stats/_components/live-matches-tab.tsx b/src/app/(home)/stats/_components/live-matches-tab.tsx index 5c756c1..9b5cfac 100644 --- a/src/app/(home)/stats/_components/live-matches-tab.tsx +++ b/src/app/(home)/stats/_components/live-matches-tab.tsx @@ -4,6 +4,7 @@ import { useState } from 'react' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import type { ActiveMatchQueue } from '@/server/services/botlatro.service' import { api } from '@/trpc/react' +import { sumBy } from 'remeda' export function LiveMatchesTab() { const [liveQueues, setLiveQueues] = useState(null) @@ -17,15 +18,16 @@ export function LiveMatchesTab() { }) const queues = liveQueues ?? initialQueues ?? [] - const total = queues.reduce((sum, q) => sum + q.active_matches, 0) + const total = sumBy(queues, (q) => q.active_matches) return (
- {queues.map((queue) => ( - + {queues.map((queue) => ( + ))}
) diff --git a/src/server/api/routers/player-state.ts b/src/server/api/routers/player-state.ts index 48a4396..e446380 100644 --- a/src/server/api/routers/player-state.ts +++ b/src/server/api/routers/player-state.ts @@ -63,7 +63,8 @@ export const playerStateRouter = createTRPCRouter({ for await (const _ of iterator) { yield tracked( Date.now().toString(), - await botlatro_service.get_active_matches()) + await botlatro_service.get_active_matches() + ) } }), }) From 12da81205fadfa96bda1a4acb882446fc8523a0b Mon Sep 17 00:00:00 2001 From: Jeffdev Date: Mon, 2 Mar 2026 12:33:12 -0700 Subject: [PATCH 5/6] Yet another formatting fix --- .../(home)/stats/_components/live-matches-tab.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/(home)/stats/_components/live-matches-tab.tsx b/src/app/(home)/stats/_components/live-matches-tab.tsx index 9b5cfac..91af4b4 100644 --- a/src/app/(home)/stats/_components/live-matches-tab.tsx +++ b/src/app/(home)/stats/_components/live-matches-tab.tsx @@ -1,10 +1,10 @@ 'use client' import { useState } from 'react' +import { sumBy } from 'remeda' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import type { ActiveMatchQueue } from '@/server/services/botlatro.service' import { api } from '@/trpc/react' -import { sumBy } from 'remeda' export function LiveMatchesTab() { const [liveQueues, setLiveQueues] = useState(null) @@ -23,12 +23,12 @@ export function LiveMatchesTab() { return (
- {queues.map((queue) => ( - ( + - ))} + count={queue.active_matches} + /> + ))}
) } From 7c558d7894f14934783908a0097051b13451c182 Mon Sep 17 00:00:00 2001 From: Jeffdev Date: Mon, 2 Mar 2026 13:36:18 -0700 Subject: [PATCH 6/6] Update live-matches-tab.tsx --- src/app/(home)/stats/_components/live-matches-tab.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/(home)/stats/_components/live-matches-tab.tsx b/src/app/(home)/stats/_components/live-matches-tab.tsx index 91af4b4..37e78f4 100644 --- a/src/app/(home)/stats/_components/live-matches-tab.tsx +++ b/src/app/(home)/stats/_components/live-matches-tab.tsx @@ -24,11 +24,12 @@ export function LiveMatchesTab() {
{queues.map((queue) => ( - - ))} + /> + ))}
) }