diff --git a/src/api/DashboardApi.ts b/src/api/DashboardApi.ts index a8b3b0de..8e07ed9a 100644 --- a/src/api/DashboardApi.ts +++ b/src/api/DashboardApi.ts @@ -7,6 +7,7 @@ import { type RepoChanges, type LanguageWeight, type CommitLog, + type LinesTotal, } from './models/Dashboard'; const useDashboardQuery = ( @@ -47,15 +48,10 @@ export const useRepoCommits = () => // because the value is a SQL SUM it arrives as a string. Consumers unwrap and // coerce it (see useDashboardData). export const useLinesTotal = (params: { from: string; to: string }) => - useDashboardQuery<{ linesCommitted: number | string }>( - 'useLinesTotal', - '/lines/total', - undefined, - { - from: params.from, - to: params.to, - }, - ); + useDashboardQuery('useLinesTotal', '/lines/total', undefined, { + from: params.from, + to: params.to, + }); export const useInfiniteCommitLog = (options?: { refetchInterval?: number; diff --git a/src/api/models/Dashboard.ts b/src/api/models/Dashboard.ts index 0e59a35b..337296e2 100644 --- a/src/api/models/Dashboard.ts +++ b/src/api/models/Dashboard.ts @@ -90,6 +90,14 @@ export type LanguageWeight = { * * API endpoint: GET /dash/stats */ +/** + * Cumulative lines committed for a date range. + * API endpoint: GET /dash/lines/total + */ +export type LinesTotal = { + linesCommitted: number; +}; + export type Stats = { uniqueRepositories: string | number; totalLinesChanged: string | number; diff --git a/src/pages/dashboard/useDashboardData.ts b/src/pages/dashboard/useDashboardData.ts index 53cfdca1..d0283181 100644 --- a/src/pages/dashboard/useDashboardData.ts +++ b/src/pages/dashboard/useDashboardData.ts @@ -153,7 +153,7 @@ const useDashboardData = (range: TrendTimeRange) => { [datasets.prs.data], ); - const totalLinesCommitted = Number(linesTotalQuery.data?.linesCommitted) || 0; + const totalLinesCommitted = linesTotalQuery.data?.linesCommitted ?? 0; const kpis = useMemo( () =>