wait calls wrapped in Promise.all

This commit is contained in:
nicksales72
2026-03-11 20:41:26 -04:00
parent 423b1a1a34
commit 90096c2ca1
2 changed files with 18 additions and 21 deletions

View File

@@ -238,7 +238,7 @@
</div> </div>
<!-- Nav --> <!-- Nav -->
<nav class="mt-0 flex flex-1 flex-col gap-0.5 px-3" data-sveltekit-preload-data="hover"> <nav class="mt-0 flex flex-1 flex-col gap-0.5 px-3">
{#each [ {#each [
{ href: '/', label: 'Dashboard', icon: 'dashboard' }, { href: '/', label: 'Dashboard', icon: 'dashboard' },
{ href: '/matches', label: 'Matches', icon: 'matches' }, { href: '/matches', label: 'Matches', icon: 'matches' },

View File

@@ -17,26 +17,23 @@ export const load: PageServerLoad = async ({ locals }) => {
} }
// ── LOGGED IN → dashboard data ── // ── LOGGED IN → dashboard data ──
const recentMatches = await db.query.match.findMany({ const [recentMatches, liveMatches, [matchCount], [teamCount], [poolCount], [finishedCount], queueStatus] =
await Promise.all([
db.query.match.findMany({
with: { participants: { with: { team: true } }, mappool: { with: { slots: true } } }, with: { participants: { with: { team: true } }, mappool: { with: { slots: true } } },
orderBy: desc(match.createdAt), orderBy: desc(match.createdAt),
limit: 5 limit: 5
}); }),
db.query.match.findMany({
const liveMatches = await db.query.match.findMany({
with: { participants: { with: { team: true } }, mappool: { with: { slots: true } } }, with: { participants: { with: { team: true } }, mappool: { with: { slots: true } } },
where: inArray(match.state, ['LOBBY', 'ROLLING', 'PICKING', 'PLAYING']) where: inArray(match.state, ['LOBBY', 'ROLLING', 'PICKING', 'PLAYING'])
}); }),
db.select({ count: count() }).from(match),
const [matchCount] = await db.select({ count: count() }).from(match); db.select({ count: count() }).from(team),
const [teamCount] = await db.select({ count: count() }).from(team); db.select({ count: count() }).from(mappool),
const [poolCount] = await db.select({ count: count() }).from(mappool); db.select({ count: count() }).from(match).where(eq(match.state, 'FINISHED')),
const [finishedCount] = await db getQueueStatus(locals.user.id)
.select({ count: count() }) ]);
.from(match)
.where(eq(match.state, 'FINISHED'));
const queueStatus = await getQueueStatus(locals.user.id);
return { return {
authenticated: true as const, authenticated: true as const,