Add active members tile and move /charts to /stats

This commit is contained in:
MartinBraquet
2025-10-14 19:09:56 +02:00
parent e33be41a93
commit b23efe4089
4 changed files with 16 additions and 3 deletions

View File

@@ -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)

View File

@@ -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 },
];
},
}

View File

@@ -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<Record<string, number | null>>({})
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 && <StatBox value={data.profiles} label={'Members'} />}
{!!data.bookmarked_searches && <StatBox value={data.bookmarked_searches} label={'Searches Bookmarked'} />}
{!!data.active_members && <StatBox value={data.active_members} label={'Active Members (last month)'} />}
{!!data.private_user_message_channels && <StatBox value={data.private_user_message_channels} label={'Discussions'} />}
{!!data.private_user_messages && <StatBox value={data.private_user_messages} label={'Messages'} />}
{!!data.bookmarked_searches && <StatBox value={data.bookmarked_searches} label={'Searches Bookmarked'} />}
{!!data.profile_comments && <StatBox value={data.profile_comments} label={'Endorsements'} />}
{!!data.love_compatibility_answers && <StatBox value={data.love_compatibility_answers} label={'Prompts Answered'} />}
</Col>

View File

@@ -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