Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/api/DashboardApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
type RepoChanges,
type LanguageWeight,
type CommitLog,
type LinesTotal,
} from './models/Dashboard';

const useDashboardQuery = <TResponse = void, TSelect = TResponse>(
Expand Down Expand Up @@ -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<LinesTotal>('useLinesTotal', '/lines/total', undefined, {
from: params.from,
to: params.to,
});

export const useInfiniteCommitLog = (options?: {
refetchInterval?: number;
Expand Down
8 changes: 8 additions & 0 deletions src/api/models/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/dashboard/useDashboardData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
() =>
Expand Down
Loading