mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
Improves the existing document rejection process by actually marking a document as completed cancelling further actions. ## Related Issue N/A ## Changes Made - Added a new rejection status for documents - Updated a million areas that check for document completion - Updated email sending, so rejection is confirmed for the rejecting recipient while other recipients are notified that the document is now cancelled. ## Testing Performed - Ran the testing suite to ensure there are no regressions. - Performed manual testing of current core flows.
28 lines
715 B
TypeScript
28 lines
715 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-document-status';
|
|
|
|
export const getDocumentStats = async () => {
|
|
const counts = await prisma.document.groupBy({
|
|
by: ['status'],
|
|
_count: {
|
|
_all: true,
|
|
},
|
|
});
|
|
|
|
const stats: Record<Exclude<ExtendedDocumentStatus, 'INBOX'>, number> = {
|
|
[ExtendedDocumentStatus.DRAFT]: 0,
|
|
[ExtendedDocumentStatus.PENDING]: 0,
|
|
[ExtendedDocumentStatus.COMPLETED]: 0,
|
|
[ExtendedDocumentStatus.REJECTED]: 0,
|
|
[ExtendedDocumentStatus.ALL]: 0,
|
|
};
|
|
|
|
counts.forEach((stat) => {
|
|
stats[stat.status] = stat._count._all;
|
|
|
|
stats.ALL += stat._count._all;
|
|
});
|
|
|
|
return stats;
|
|
};
|