From 240bef1a668adc0039ed11bc098af506aa412ed7 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Wed, 3 Jun 2026 16:15:59 +1000 Subject: [PATCH] fix: add org insight document complete stat (#2920) --- .../app/components/tables/organisation-insights-table.tsx | 4 ++-- .../server-only/admin/get-organisation-detailed-insights.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/remix/app/components/tables/organisation-insights-table.tsx b/apps/remix/app/components/tables/organisation-insights-table.tsx index 30d52b859..417ee2b46 100644 --- a/apps/remix/app/components/tables/organisation-insights-table.tsx +++ b/apps/remix/app/components/tables/organisation-insights-table.tsx @@ -207,7 +207,7 @@ export const OrganisationInsightsTable = ({ )} @@ -269,7 +269,7 @@ const SummaryCard = ({ }: { icon: React.ComponentType<{ className?: string }>; title: string; - value: number; + value: number | string; subtitle?: string; }) => (
diff --git a/packages/lib/server-only/admin/get-organisation-detailed-insights.ts b/packages/lib/server-only/admin/get-organisation-detailed-insights.ts index 49c268bd2..769aefa5d 100644 --- a/packages/lib/server-only/admin/get-organisation-detailed-insights.ts +++ b/packages/lib/server-only/admin/get-organisation-detailed-insights.ts @@ -10,6 +10,7 @@ export type OrganisationSummary = { activeDocuments: number; completedDocuments: number; volumeThisPeriod: number; + documentsThisPeriod: number; volumeAllTime: number; }; @@ -305,6 +306,10 @@ async function getOrganisationSummary( ? sql`count(case when e.status = 'COMPLETED' and e."createdAt" >= ${createdAtFrom} then 1 end)` : sql`count(case when e.status = 'COMPLETED' then 1 end)` ).as('volumeThisPeriod'), + (createdAtFrom + ? sql`count(case when e."createdAt" >= ${createdAtFrom} then 1 end)` + : sql`count(e.id)` + ).as('documentsThisPeriod'), ]) .executeTakeFirst(); @@ -321,6 +326,7 @@ async function getOrganisationSummary( activeDocuments: Number(envelopeStats?.activeDocuments || 0), completedDocuments: Number(envelopeStats?.completedDocuments || 0), volumeThisPeriod: Number(envelopeStats?.volumeThisPeriod || 0), + documentsThisPeriod: Number(envelopeStats?.documentsThisPeriod || 0), volumeAllTime: Number(envelopeStats?.volumeAllTime || 0), }; }