mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
fix: remove cummulative
This commit is contained in:
@ -53,17 +53,13 @@ export const getUserWithAtLeastOneDocumentSignedPerMonth = async () => {
|
||||
export type GetUserWithDocumentMonthlyGrowth = Array<{
|
||||
month: string;
|
||||
count: number;
|
||||
cume_count: number;
|
||||
signed_count: number;
|
||||
cume_signed_count: number;
|
||||
}>;
|
||||
|
||||
type GetUserWithDocumentMonthlyGrowthQueryResult = Array<{
|
||||
month: Date;
|
||||
count: bigint;
|
||||
cume_count: bigint;
|
||||
signed_count: bigint;
|
||||
cume_signed_count: bigint;
|
||||
}>;
|
||||
|
||||
export const getUserWithSignedDocumentMonthlyGrowth = async () => {
|
||||
@ -71,9 +67,7 @@ export const getUserWithSignedDocumentMonthlyGrowth = async () => {
|
||||
SELECT
|
||||
DATE_TRUNC('month', "Document"."createdAt") AS "month",
|
||||
COUNT(DISTINCT "Document"."userId") as "count",
|
||||
SUM(COUNT(DISTINCT "Document"."userId")) OVER (ORDER BY DATE_TRUNC('month', "Document"."createdAt")) as "cume_count",
|
||||
COUNT(DISTINCT CASE WHEN "Document"."status" = 'COMPLETED' THEN "Document"."userId" END) as "signed_count",
|
||||
SUM(COUNT(DISTINCT CASE WHEN "Document"."status" = 'COMPLETED' THEN "Document"."userId" END)) OVER (ORDER BY DATE_TRUNC('month', "Document"."createdAt")) as "cume_signed_count"
|
||||
COUNT(DISTINCT CASE WHEN "Document"."status" = 'COMPLETED' THEN "Document"."userId" END) as "signed_count"
|
||||
FROM "Document"
|
||||
GROUP BY "month"
|
||||
ORDER BY "month" DESC
|
||||
@ -83,8 +77,6 @@ export const getUserWithSignedDocumentMonthlyGrowth = async () => {
|
||||
return result.map((row) => ({
|
||||
month: DateTime.fromJSDate(row.month).toFormat('yyyy-MM'),
|
||||
count: Number(row.count),
|
||||
cume_count: Number(row.cume_count),
|
||||
signed_count: Number(row.signed_count),
|
||||
cume_signed_count: Number(row.cume_signed_count),
|
||||
}));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user