mirror of
https://github.com/documenso/documenso.git
synced 2025-11-19 11:12:06 +10:00
chore: cleanup
This commit is contained in:
@ -9,7 +9,6 @@ import {
|
|||||||
Mail,
|
Mail,
|
||||||
MailOpen,
|
MailOpen,
|
||||||
PenTool,
|
PenTool,
|
||||||
UserCheck,
|
|
||||||
UserPlus,
|
UserPlus,
|
||||||
UserSquare2,
|
UserSquare2,
|
||||||
Users,
|
Users,
|
||||||
@ -22,14 +21,13 @@ import {
|
|||||||
getMonthlyActiveUsers,
|
getMonthlyActiveUsers,
|
||||||
getUserWithSignedDocumentMonthlyGrowth,
|
getUserWithSignedDocumentMonthlyGrowth,
|
||||||
getUsersCount,
|
getUsersCount,
|
||||||
getUsersWithLastSignedInCount,
|
|
||||||
getUsersWithSubscriptionsCount,
|
getUsersWithSubscriptionsCount,
|
||||||
} from '@documenso/lib/server-only/admin/get-users-stats';
|
} from '@documenso/lib/server-only/admin/get-users-stats';
|
||||||
import { getSignerConversionMonthly } from '@documenso/lib/server-only/user/get-signer-conversion';
|
import { getSignerConversionMonthly } from '@documenso/lib/server-only/user/get-signer-conversion';
|
||||||
|
|
||||||
import { CardMetric } from '~/components/(dashboard)/metric-card/metric-card';
|
import { CardMetric } from '~/components/(dashboard)/metric-card/metric-card';
|
||||||
|
|
||||||
import { MonthlyActiveUsersChart } from './mau';
|
import { MonthlyActiveUsersChart } from './monthly-active-users-chart';
|
||||||
import { SignerConversionChart } from './signer-conversion-chart';
|
import { SignerConversionChart } from './signer-conversion-chart';
|
||||||
import { UserWithDocumentChart } from './user-with-document';
|
import { UserWithDocumentChart } from './user-with-document';
|
||||||
|
|
||||||
@ -47,8 +45,7 @@ export default async function AdminStatsPage() {
|
|||||||
// userWithAtLeastOneDocumentPerMonth,
|
// userWithAtLeastOneDocumentPerMonth,
|
||||||
// userWithAtLeastOneDocumentSignedPerMonth,
|
// userWithAtLeastOneDocumentSignedPerMonth,
|
||||||
MONTHLY_USERS_SIGNED,
|
MONTHLY_USERS_SIGNED,
|
||||||
usersWithLastSignedInCount,
|
MONTHLY_ACTIVE_USERS,
|
||||||
monthlyActiveUsers,
|
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getUsersCount(),
|
getUsersCount(),
|
||||||
getUsersWithSubscriptionsCount(),
|
getUsersWithSubscriptionsCount(),
|
||||||
@ -58,7 +55,6 @@ export default async function AdminStatsPage() {
|
|||||||
// getUserWithAtLeastOneDocumentPerMonth(),
|
// getUserWithAtLeastOneDocumentPerMonth(),
|
||||||
// getUserWithAtLeastOneDocumentSignedPerMonth(),
|
// getUserWithAtLeastOneDocumentSignedPerMonth(),
|
||||||
getUserWithSignedDocumentMonthlyGrowth(),
|
getUserWithSignedDocumentMonthlyGrowth(),
|
||||||
getUsersWithLastSignedInCount(),
|
|
||||||
getMonthlyActiveUsers(),
|
getMonthlyActiveUsers(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -76,11 +72,6 @@ export default async function AdminStatsPage() {
|
|||||||
title={_(msg`Active Subscriptions`)}
|
title={_(msg`Active Subscriptions`)}
|
||||||
value={usersWithSubscriptionsCount}
|
value={usersWithSubscriptionsCount}
|
||||||
/>
|
/>
|
||||||
<CardMetric
|
|
||||||
icon={UserCheck}
|
|
||||||
title={_(msg`MAU (signed in)`)}
|
|
||||||
value={usersWithLastSignedInCount}
|
|
||||||
/>
|
|
||||||
<CardMetric
|
<CardMetric
|
||||||
icon={FileCog}
|
icon={FileCog}
|
||||||
title={_(msg`App Version`)}
|
title={_(msg`App Version`)}
|
||||||
@ -144,14 +135,11 @@ export default async function AdminStatsPage() {
|
|||||||
<Trans>Charts</Trans>
|
<Trans>Charts</Trans>
|
||||||
</h3>
|
</h3>
|
||||||
<div className="mt-5 grid grid-cols-2 gap-8">
|
<div className="mt-5 grid grid-cols-2 gap-8">
|
||||||
<MonthlyActiveUsersChart
|
<MonthlyActiveUsersChart title={_(msg`MAU (signed in)`)} data={MONTHLY_ACTIVE_USERS} />
|
||||||
title={_(msg`Monthly Active Users (signed in)`)}
|
|
||||||
data={monthlyActiveUsers}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<MonthlyActiveUsersChart
|
<MonthlyActiveUsersChart
|
||||||
title={_(msg`Cumulative MAU (signed in)`)}
|
title={_(msg`Cumulative MAU (signed in)`)}
|
||||||
data={monthlyActiveUsers}
|
data={MONTHLY_ACTIVE_USERS}
|
||||||
cummulative
|
cummulative
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@ -50,16 +50,6 @@ export const getUserWithAtLeastOneDocumentSignedPerMonth = async () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getUsersWithLastSignedInCount = async () => {
|
|
||||||
return await prisma.user.count({
|
|
||||||
where: {
|
|
||||||
lastSignedIn: {
|
|
||||||
gte: DateTime.now().minus({ months: 1 }).toJSDate(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export type GetUserWithDocumentMonthlyGrowth = Array<{
|
export type GetUserWithDocumentMonthlyGrowth = Array<{
|
||||||
month: string;
|
month: string;
|
||||||
count: number;
|
count: number;
|
||||||
|
|||||||
@ -1,62 +0,0 @@
|
|||||||
import { DateTime } from 'luxon';
|
|
||||||
|
|
||||||
import { hashSync } from '@documenso/lib/server-only/auth/hash';
|
|
||||||
|
|
||||||
import { prisma } from '.';
|
|
||||||
import { Role } from './client';
|
|
||||||
|
|
||||||
const USERS_PER_MONTH = 20;
|
|
||||||
const MONTHS_OF_HISTORY = 12;
|
|
||||||
|
|
||||||
export const seedMAUData = async () => {
|
|
||||||
const now = DateTime.now();
|
|
||||||
|
|
||||||
for (let monthsAgo = MONTHS_OF_HISTORY - 1; monthsAgo >= 0; monthsAgo--) {
|
|
||||||
const monthStart = now.minus({ months: monthsAgo }).startOf('month');
|
|
||||||
const monthEnd = monthStart.endOf('month');
|
|
||||||
|
|
||||||
console.log(`Seeding users for ${monthStart.toFormat('yyyy-MM')}`);
|
|
||||||
|
|
||||||
const users = await Promise.all(
|
|
||||||
Array.from({ length: USERS_PER_MONTH }).map(async (_, index) => {
|
|
||||||
const createdAt = DateTime.fromMillis(
|
|
||||||
monthStart.toMillis() + Math.random() * (monthEnd.toMillis() - monthStart.toMillis()),
|
|
||||||
).toJSDate();
|
|
||||||
|
|
||||||
const lastSignedIn =
|
|
||||||
Math.random() > 0.3
|
|
||||||
? DateTime.fromMillis(
|
|
||||||
createdAt.getTime() + Math.random() * (now.toMillis() - createdAt.getTime()),
|
|
||||||
).toJSDate()
|
|
||||||
: createdAt;
|
|
||||||
|
|
||||||
return prisma.user.create({
|
|
||||||
data: {
|
|
||||||
name: `MAU Test User ${monthsAgo}-${index}`,
|
|
||||||
email: `mau-test-${monthsAgo}-${index}@documenso.com`,
|
|
||||||
password: hashSync('password'),
|
|
||||||
emailVerified: createdAt,
|
|
||||||
createdAt,
|
|
||||||
lastSignedIn,
|
|
||||||
roles: [Role.USER],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(`Created ${users.length} users for ${monthStart.toFormat('yyyy-MM')}`);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Run the seed if this file is executed directly
|
|
||||||
if (require.main === module) {
|
|
||||||
seedMAUData()
|
|
||||||
.then(() => {
|
|
||||||
console.log('MAU seed completed successfully');
|
|
||||||
process.exit(0);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error('Error seeding MAU data:', error);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -15,8 +15,7 @@
|
|||||||
"prisma:migrate-deploy": "prisma migrate deploy",
|
"prisma:migrate-deploy": "prisma migrate deploy",
|
||||||
"prisma:migrate-reset": "prisma migrate reset",
|
"prisma:migrate-reset": "prisma migrate reset",
|
||||||
"prisma:seed": "prisma db seed",
|
"prisma:seed": "prisma db seed",
|
||||||
"prisma:studio": "prisma studio",
|
"prisma:studio": "prisma studio"
|
||||||
"prisma:seed-mau": "tsx ./mau-seed.ts"
|
|
||||||
},
|
},
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"seed": "tsx ./seed-database.ts"
|
"seed": "tsx ./seed-database.ts"
|
||||||
|
|||||||
Reference in New Issue
Block a user