diff --git a/ui/src/components/ContributionGraph.tsx b/ui/src/components/ContributionGraph.tsx
index 6250b90..e816520 100644
--- a/ui/src/components/ContributionGraph.tsx
+++ b/ui/src/components/ContributionGraph.tsx
@@ -1,8 +1,13 @@
-import { useMemo } from 'react';
-import { useQuery } from '@tanstack/react-query';
-import { useNavigate } from 'react-router-dom';
+import { useMemo } from "react";
+import { useQuery } from "@tanstack/react-query";
+import { useNavigate } from "react-router-dom";
-import { fetchDailyCounts, fetchLanguageDailyCounts, fetchProjects, fetchSources } from '../api/client';
+import {
+ fetchDailyCounts,
+ fetchLanguageDailyCounts,
+ fetchProjects,
+ fetchSources,
+} from "../api/client";
const CELL_SIZE = 12;
const GAP = 3;
@@ -11,11 +16,24 @@ const ROWS = 7;
const LEFT_LABEL_WIDTH = 28;
const TOP_LABEL_HEIGHT = 16;
-const DAY_LABELS = ['', 'mon', '', 'wed', '', 'fri', ''];
-const MONTH_LABELS = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
+const DAY_LABELS = ["", "mon", "", "wed", "", "fri", ""];
+const MONTH_LABELS = [
+ "jan",
+ "feb",
+ "mar",
+ "apr",
+ "may",
+ "jun",
+ "jul",
+ "aug",
+ "sep",
+ "oct",
+ "nov",
+ "dec",
+];
-const EMPTY_COLOR = 'rgba(255,255,255,0.05)';
-const FALLBACK_COLOR = '#39d353';
+const EMPTY_COLOR = "rgba(255,255,255,0.05)";
+const FALLBACK_COLOR = "#39d353";
/** Daily contribution graph — last 1 year, one circle per day. */
export function ContributionGraph() {
@@ -27,19 +45,19 @@ export function ContributionGraph() {
const toStr = fmt(to);
const dailyQ = useQuery({
- queryKey: ['daily-counts', fromStr, toStr],
+ queryKey: ["daily-counts", fromStr, toStr],
queryFn: () => fetchDailyCounts(fromStr, toStr),
staleTime: 5 * 60_000,
});
const langQ = useQuery({
- queryKey: ['language-daily', fromStr, toStr],
+ queryKey: ["language-daily", fromStr, toStr],
queryFn: () => fetchLanguageDailyCounts(fromStr, toStr),
staleTime: 5 * 60_000,
});
const projectsQ = useQuery({
- queryKey: ['projects'],
+ queryKey: ["projects"],
queryFn: fetchProjects,
staleTime: 60_000,
});
@@ -49,7 +67,9 @@ export function ContributionGraph() {
const fromMs = from.getTime();
const toMs = to.getTime();
return projectsQ.data.filter((p) => {
- const first = p.first_activity ? new Date(p.first_activity).getTime() : Infinity;
+ const first = p.first_activity
+ ? new Date(p.first_activity).getTime()
+ : Infinity;
const last = p.last_activity ? new Date(p.last_activity).getTime() : 0;
return last >= fromMs && first <= toMs;
}).length;
@@ -69,14 +89,15 @@ export function ContributionGraph() {
const start = new Date(from);
start.setDate(start.getDate() - start.getDay());
- const weeks: { date: string; count: number; col: number; row: number }[][] = [];
+ const weeks: { date: string; count: number; col: number; row: number }[][] =
+ [];
const monthMarkers: { col: number; label: string }[] = [];
let col = 0;
let prevMonth = -1;
const cursor = new Date(start);
while (cursor <= to) {
- const week: typeof weeks[0] = [];
+ const week: (typeof weeks)[0] = [];
for (let row = 0; row < ROWS; row++) {
const dateStr = fmt(cursor);
const count = countMap.get(dateStr) ?? 0;
@@ -94,7 +115,10 @@ export function ContributionGraph() {
col++;
}
- const nonZero = counts.map((d) => d.count).filter((c) => c > 0).sort((a, b) => a - b);
+ const nonZero = counts
+ .map((d) => d.count)
+ .filter((c) => c > 0)
+ .sort((a, b) => a - b);
const thresholds = computeThresholds(nonZero);
const totalCount = counts.reduce((sum, d) => sum + d.count, 0);
@@ -105,17 +129,23 @@ export function ContributionGraph() {
const svgWidth = LEFT_LABEL_WIDTH + cols * (CELL_SIZE + GAP);
const svgHeight = TOP_LABEL_HEIGHT + ROWS * (CELL_SIZE + GAP);
- if (dailyQ.isLoading) return
loading contribution graph...
;
+ if (dailyQ.isLoading)
+ return loading contribution graph...
;
if (dailyQ.isError) return null;
return (
-
- {totalCount} contributions in the last year
- {repoCount > 0 && ` in ${repoCount} repositories`}
+
+ {new Intl.NumberFormat().format(totalCount)} contributions
+ {repoCount > 0 && `, across ${repoCount} repositories, `}
+ in the last year
-