From a6e69fe00e4bbd198a358f04b13c11b3bc9d4233 Mon Sep 17 00:00:00 2001 From: openhands Date: Sat, 29 Aug 2026 21:26:30 +0200 Subject: [PATCH] perf: declutter home page by removing duplicated sections and queries The landing page showed the same information more than once. Drop the second avatar grid (latest users) and its DB query, move the online users grid into the left column, remove the register banner card and the bottom join CTA so registration is only offered once in the hero, and show the online count a single time in the hero badge instead of also in the stats row. The online users query now fetches 12 rows instead of 30, saving bandwidth on every uncached render. The avatar presentation contract test now expects one thumbnail call site on the home page. --- src/app/(site)/page.tsx | 226 ++++-------------- .../shared/public-avatar-contract.test.ts | 2 +- 2 files changed, 53 insertions(+), 175 deletions(-) diff --git a/src/app/(site)/page.tsx b/src/app/(site)/page.tsx index 479bcbac7f..f69f9cb95a 100644 --- a/src/app/(site)/page.tsx +++ b/src/app/(site)/page.tsx @@ -29,57 +29,43 @@ async function getHotelData() { siteSettings.get("cms_logo", ""), ]); - const [ - online, - users, - rooms, - articles, - recentUsers, - recentPhotos, - latestUsers, - ] = await Promise.all([ - cached("online_count", 10_000, () => - db - .select({ total: count() }) - .from(User) - .where(eq(User.online, "1")) - .then((rows) => rows[0]?.total ?? 0), - ).catch(() => 0), - cached("total_users", 300_000, () => - db - .select({ total: count() }) - .from(User) - .then((rows) => rows[0]?.total ?? 0), - ).catch(() => 0), - cached("total_rooms", 300_000, () => - db - .select({ total: count() }) - .from(Rooms) - .then((rows) => rows[0]?.total ?? 0), - ).catch(() => 0), - getNewsList(4), - cached("home_online_users", 15_000, () => - db - .select({ username: User.username, look: User.look }) - .from(User) - .where(eq(User.online, "1")) - .limit(30), - ).catch(() => []), - cached("home_recent_photos", 60_000, () => - db - .select({ id: CameraWeb.id, url: CameraWeb.url }) - .from(CameraWeb) - .orderBy(desc(CameraWeb.timestamp)) - .limit(4), - ).catch(() => []), - cached("home_latest_users", 60_000, () => - db - .select({ username: User.username, look: User.look }) - .from(User) - .orderBy(desc(User.accountCreated)) - .limit(8), - ).catch(() => []), - ]); + const [online, users, rooms, articles, recentUsers, recentPhotos] = + await Promise.all([ + cached("online_count", 10_000, () => + db + .select({ total: count() }) + .from(User) + .where(eq(User.online, "1")) + .then((rows) => rows[0]?.total ?? 0), + ).catch(() => 0), + cached("total_users", 300_000, () => + db + .select({ total: count() }) + .from(User) + .then((rows) => rows[0]?.total ?? 0), + ).catch(() => 0), + cached("total_rooms", 300_000, () => + db + .select({ total: count() }) + .from(Rooms) + .then((rows) => rows[0]?.total ?? 0), + ).catch(() => 0), + getNewsList(4), + cached("home_online_users", 15_000, () => + db + .select({ username: User.username, look: User.look }) + .from(User) + .where(eq(User.online, "1")) + .limit(12), + ).catch(() => []), + cached("home_recent_photos", 60_000, () => + db + .select({ id: CameraWeb.id, url: CameraWeb.url }) + .from(CameraWeb) + .orderBy(desc(CameraWeb.timestamp)) + .limit(4), + ).catch(() => []), + ]); return { hotelName, @@ -89,7 +75,6 @@ async function getHotelData() { articles, recentUsers, recentPhotos, - latestUsers, logo, }; } @@ -108,7 +93,6 @@ export default async function Home() { articles, recentUsers, recentPhotos, - latestUsers, logo, } = await getHotelData(); @@ -303,13 +287,8 @@ export default async function Home() { {/* ── Stats ── */} -
+
{[ - { - value: online, - label: tp("statsOnline"), - icon: "/assets/images/icons/online-friends.png", - }, { value: users, label: tp("statsCitizens"), @@ -365,7 +344,7 @@ export default async function Home() { {/* ── Login + News ── */}
- {/* Left: Login & Register */} + {/* Left: Login & Online users */} - - - Register - - - {tp("register")} - - - - {latestUsers.length > 0 && ( + {recentUsers.length > 0 && (
- {latestUsers.map((u) => ( + {recentUsers.map((u) => (
{u.username} @@ -501,91 +464,6 @@ export default async function Home() {
- {/* ── Online users ── */} - {recentUsers.length > 0 && ( - - -
- {recentUsers.slice(0, 12).map((u) => ( -
- - - {u.username} - -
- ))} -
-
-
- )} - - {/* ── Bottom CTA ── */} - -
-

- {tp("joinNow", { hotelName })} -

-

- {tp("welcomeBody")} -

- - - {tp("register")} - -
-
- {/* ── Recent photos ── */} {recentPhotos.length > 0 && ( diff --git a/src/components/shared/public-avatar-contract.test.ts b/src/components/shared/public-avatar-contract.test.ts index de5681e854..c3367bae09 100644 --- a/src/components/shared/public-avatar-contract.test.ts +++ b/src/components/shared/public-avatar-contract.test.ts @@ -10,7 +10,7 @@ const compactCallSites = new Map([ ["src/app/(site)/login/page.tsx", 2], ["src/app/(site)/me/page.tsx", 1], ["src/app/(site)/messages/page.tsx", 2], - ["src/app/(site)/page.tsx", 2], + ["src/app/(site)/page.tsx", 1], ["src/app/(site)/radio/leaderboard/page.tsx", 1], ["src/app/(site)/radio/shouts/page.tsx", 1], ["src/app/(site)/rankings/page.tsx", 1],