From ba6defa87ccdf0acd1eaa7b2fdf2ecfb0619a234 Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Fri, 21 Nov 2025 06:03:34 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8Add=20request=20by=20day=20chart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auditLogs/queryRequestAnalytics.ts | 1 + src/components/LogAnalyticsData.tsx | 52 ++++--------------- src/components/ui/chart.tsx | 20 +++++-- 3 files changed, 28 insertions(+), 45 deletions(-) diff --git a/server/routers/auditLogs/queryRequestAnalytics.ts b/server/routers/auditLogs/queryRequestAnalytics.ts index adf5db4a..796ec5ed 100644 --- a/server/routers/auditLogs/queryRequestAnalytics.ts +++ b/server/routers/auditLogs/queryRequestAnalytics.ts @@ -121,6 +121,7 @@ async function query(query: Q) { totalCount: sql`COUNT(*)`.as("total_count") }) .from(requestAuditLog) + .where(and(baseConditions)) .groupBy(groupByDayFunction) .orderBy(groupByDayFunction); diff --git a/src/components/LogAnalyticsData.tsx b/src/components/LogAnalyticsData.tsx index 9cc980b9..8c4b9566 100644 --- a/src/components/LogAnalyticsData.tsx +++ b/src/components/LogAnalyticsData.tsx @@ -347,6 +347,9 @@ function RequestChart(props: RequestChartProps) { }); const chartConfig = { + day: { + label: t("requestsByDay") + }, blockedCount: { label: t("blocked"), color: "var(--chart-5)" @@ -367,49 +370,14 @@ function RequestChart(props: RequestChartProps) { { + indicator="dot" + labelFormatter={(value, payload) => { const formattedDate = new Date( - item.payload.day + payload[0].payload.day ).toLocaleDateString(navigator.language, { dateStyle: "medium" }); - - const value_str = numberFormatter.format( - value as number - ); - - const config = - chartConfig[ - name as keyof typeof chartConfig - ]; - - return ( -
- {index === 0 && ( - {formattedDate} - )} - -
-
-
- - {config.label} - -
-
- {value_str} -
-
-
- ); + return formattedDate; }} /> } @@ -486,13 +454,15 @@ function RequestChart(props: RequestChartProps) { diff --git a/src/components/ui/chart.tsx b/src/components/ui/chart.tsx index 76f339f0..58d6a270 100644 --- a/src/components/ui/chart.tsx +++ b/src/components/ui/chart.tsx @@ -180,7 +180,7 @@ const ChartTooltipContent = React.forwardRef<
@@ -190,6 +190,7 @@ const ChartTooltipContent = React.forwardRef< .filter((item) => item.type !== "none") .map((item, index) => { const key = `${nameKey || item.name || item.dataKey || "value"}`; + const itemConfig = getPayloadConfigFromPayload( config, item, @@ -224,7 +225,7 @@ const ChartTooltipContent = React.forwardRef< !hideIndicator && (
{item.value && ( - {item.value.toLocaleString()} + {!isNaN( + item.value as number + ) + ? new Intl.NumberFormat( + navigator.language, + { + maximumFractionDigits: 0 + } + ).format( + item.value as number + ) + : item.value.toLocaleString()} )}