From b23efe40894c119c6bf911f259740a9b4d0b1f6e Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Tue, 14 Oct 2025 19:09:56 +0200 Subject: [PATCH] Add active members tile and move /charts to /stats --- web/lib/supabase/users.ts | 10 ++++++++++ web/next.config.js | 1 + web/pages/{charts.tsx => stats.tsx} | 6 ++++-- web/public/md/faq.md | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) rename web/pages/{charts.tsx => stats.tsx} (92%) diff --git a/web/lib/supabase/users.ts b/web/lib/supabase/users.ts index ba432ab4..bf492c92 100644 --- a/web/lib/supabase/users.ts +++ b/web/lib/supabase/users.ts @@ -4,6 +4,7 @@ import {api, APIError} from 'web/lib/api' import {unauthedApi} from 'common/util/api' import type {DisplayUser} from 'common/api/user-types' import {MIN_BIO_LENGTH} from "common/constants"; +import {MONTH_MS} from "common/util/time"; export type {DisplayUser} @@ -82,6 +83,15 @@ export async function getCount(table: string) { const result = await api('get-messages-count') return result.count } + if (table == 'active_members') { + const {count} = await run( + db + .from('user_activity') + .select('*', {count: 'exact', head: true}) + .gt('last_online_time', new Date(Date.now() - MONTH_MS).toISOString()) // last month + ) + return count; + } const {count} = await run( db .from(table) diff --git a/web/next.config.js b/web/next.config.js index 2a974f7e..cf2710d1 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -74,6 +74,7 @@ module.exports = { { source: '/patreon', destination: 'https://patreon.com/CompassMeet', permanent: false }, { source: '/paypal', destination: 'https://www.paypal.com/paypalme/CompassConnections', permanent: false }, { source: '/github', destination: "https://github.com/CompassConnections/Compass", permanent: false }, + { source: '/charts', destination: "/stats", permanent: true }, ]; }, } diff --git a/web/pages/charts.tsx b/web/pages/stats.tsx similarity index 92% rename from web/pages/charts.tsx rename to web/pages/stats.tsx index 18310b35..3a3b69af 100644 --- a/web/pages/charts.tsx +++ b/web/pages/stats.tsx @@ -6,13 +6,14 @@ import StatBox from "web/components/widgets/stat-box"; import clsx from "clsx"; import {Col} from "web/components/layout/col"; -export default function Charts() { +export default function Stats() { const [data, setData] = useState>({}) useEffect(() => { async function load() { const tables = [ 'profiles', + 'active_members', 'bookmarked_searches', 'private_user_message_channels', 'private_user_messages', @@ -49,9 +50,10 @@ export default function Charts() { )} > {!!data.profiles && } - {!!data.bookmarked_searches && } + {!!data.active_members && } {!!data.private_user_message_channels && } {!!data.private_user_messages && } + {!!data.bookmarked_searches && } {!!data.profile_comments && } {!!data.love_compatibility_answers && } diff --git a/web/public/md/faq.md b/web/public/md/faq.md index 68237c44..3d7bff0a 100644 --- a/web/public/md/faq.md +++ b/web/public/md/faq.md @@ -109,7 +109,7 @@ We chose the name Compass because our goal is to help people orient themselves t ### How fast is Compass growing? -Compass has officially **launched** in October 2025 and is growing fast. You can explore real-time stats and transparent community data on our [**Growth & Stats page**](/charts). It includes information such as: +Compass has officially **launched** in October 2025 and is growing fast. You can explore real-time stats and transparent community data on our [**Growth & Stats page**](/stats). It includes information such as: * Community growth over time * Messages sent