mirror of
https://github.com/documenso/documenso.git
synced 2026-07-14 06:47:10 +10:00
138d663c25
Merge origin/main into feat/external-2fa-codes. Resolve formatting conflicts caused by biome rollout; preserve both feature streams: PR's external 2FA token + signing-session 2FA proof additions plus main's RateLimit/RecipientExpired/signingReminders/date-auto-insert. In complete-document-with-token.ts, drop the duplicate early field-fetching block introduced when main moved that logic later with date auto-insert support; keep the EXTERNAL_TWO_FACTOR_AUTH check using derivedRecipientActionAuth.
33 lines
830 B
TypeScript
33 lines
830 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
import { ReadStatus, SendStatus, SigningStatus } from '@prisma/client';
|
|
|
|
export const getRecipientsStats = async () => {
|
|
const results = await prisma.recipient.groupBy({
|
|
by: ['readStatus', 'signingStatus', 'sendStatus'],
|
|
_count: true,
|
|
});
|
|
|
|
const stats = {
|
|
TOTAL_RECIPIENTS: 0,
|
|
[ReadStatus.OPENED]: 0,
|
|
[ReadStatus.NOT_OPENED]: 0,
|
|
[SigningStatus.SIGNED]: 0,
|
|
[SigningStatus.NOT_SIGNED]: 0,
|
|
[SigningStatus.REJECTED]: 0,
|
|
[SendStatus.SENT]: 0,
|
|
[SendStatus.NOT_SENT]: 0,
|
|
};
|
|
|
|
results.forEach((result) => {
|
|
const { readStatus, signingStatus, sendStatus, _count } = result;
|
|
|
|
stats[readStatus] += _count;
|
|
stats[signingStatus] += _count;
|
|
stats[sendStatus] += _count;
|
|
|
|
stats.TOTAL_RECIPIENTS += _count;
|
|
});
|
|
|
|
return stats;
|
|
};
|