mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 01:32:06 +10:00
feat: add envelope editor
This commit is contained in:
@ -15,7 +15,7 @@ export const adminFindDocuments = async ({
|
||||
page = 1,
|
||||
perPage = 10,
|
||||
}: AdminFindDocumentsOptions) => {
|
||||
const termFilters: Prisma.EnvelopeWhereInput | undefined = !query
|
||||
let termFilters: Prisma.EnvelopeWhereInput | undefined = !query
|
||||
? undefined
|
||||
: {
|
||||
title: {
|
||||
@ -24,6 +24,34 @@ export const adminFindDocuments = async ({
|
||||
},
|
||||
};
|
||||
|
||||
if (query && query.startsWith('envelope_')) {
|
||||
termFilters = {
|
||||
id: {
|
||||
equals: query,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (query && query.startsWith('document_')) {
|
||||
termFilters = {
|
||||
secondaryId: {
|
||||
equals: query,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (query) {
|
||||
const isQueryAnInteger = !isNaN(parseInt(query));
|
||||
|
||||
if (isQueryAnInteger) {
|
||||
termFilters = {
|
||||
secondaryId: {
|
||||
equals: `document_${query}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const [data, count] = await Promise.all([
|
||||
prisma.envelope.findMany({
|
||||
where: {
|
||||
|
||||
@ -32,12 +32,13 @@ type GetUserWithDocumentMonthlyGrowthQueryResult = Array<{
|
||||
export const getUserWithSignedDocumentMonthlyGrowth = async () => {
|
||||
const result = await prisma.$queryRaw<GetUserWithDocumentMonthlyGrowthQueryResult>`
|
||||
SELECT
|
||||
DATE_TRUNC('month', "Document"."createdAt") AS "month",
|
||||
COUNT(DISTINCT "Document"."userId") as "count",
|
||||
COUNT(DISTINCT CASE WHEN "Document"."status" = 'COMPLETED' THEN "Document"."userId" END) as "signed_count"
|
||||
FROM "Document"
|
||||
INNER JOIN "Team" ON "Document"."teamId" = "Team"."id"
|
||||
DATE_TRUNC('month', "Envelope"."createdAt") AS "month",
|
||||
COUNT(DISTINCT "Envelope"."userId") as "count",
|
||||
COUNT(DISTINCT CASE WHEN "Envelope"."status" = 'COMPLETED' THEN "Envelope"."userId" END) as "signed_count"
|
||||
FROM "Envelope"
|
||||
INNER JOIN "Team" ON "Envelope"."teamId" = "Team"."id"
|
||||
INNER JOIN "Organisation" ON "Team"."organisationId" = "Organisation"."id"
|
||||
WHERE "Envelope"."type" = 'DOCUMENT'::"EnvelopeType"
|
||||
GROUP BY "month"
|
||||
ORDER BY "month" DESC
|
||||
LIMIT 12
|
||||
|
||||
Reference in New Issue
Block a user