wait calls wrapped in Promise.all
This commit is contained in:
@@ -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' },
|
||||||
|
|||||||
@@ -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] =
|
||||||
with: { participants: { with: { team: true } }, mappool: { with: { slots: true } } },
|
await Promise.all([
|
||||||
orderBy: desc(match.createdAt),
|
db.query.match.findMany({
|
||||||
limit: 5
|
with: { participants: { with: { team: true } }, mappool: { with: { slots: true } } },
|
||||||
});
|
orderBy: desc(match.createdAt),
|
||||||
|
limit: 5
|
||||||
const liveMatches = await db.query.match.findMany({
|
}),
|
||||||
with: { participants: { with: { team: true } }, mappool: { with: { slots: true } } },
|
db.query.match.findMany({
|
||||||
where: inArray(match.state, ['LOBBY', 'ROLLING', 'PICKING', 'PLAYING'])
|
with: { participants: { with: { team: true } }, mappool: { with: { slots: true } } },
|
||||||
});
|
where: inArray(match.state, ['LOBBY', 'ROLLING', 'PICKING', 'PLAYING'])
|
||||||
|
}),
|
||||||
const [matchCount] = await db.select({ count: count() }).from(match);
|
db.select({ count: count() }).from(match),
|
||||||
const [teamCount] = await db.select({ count: count() }).from(team);
|
db.select({ count: count() }).from(team),
|
||||||
const [poolCount] = await db.select({ count: count() }).from(mappool);
|
db.select({ count: count() }).from(mappool),
|
||||||
const [finishedCount] = await db
|
db.select({ count: count() }).from(match).where(eq(match.state, 'FINISHED')),
|
||||||
.select({ count: count() })
|
getQueueStatus(locals.user.id)
|
||||||
.from(match)
|
]);
|
||||||
.where(eq(match.state, 'FINISHED'));
|
|
||||||
|
|
||||||
const queueStatus = await getQueueStatus(locals.user.id);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
authenticated: true as const,
|
authenticated: true as const,
|
||||||
|
|||||||
Reference in New Issue
Block a user