diff --git a/src/components/ContributionHeatmap.tsx b/src/components/ContributionHeatmap.tsx index 6c759ea6..69b06ed8 100644 --- a/src/components/ContributionHeatmap.tsx +++ b/src/components/ContributionHeatmap.tsx @@ -15,7 +15,7 @@ interface ContributionData { interface ContributionHeatmapProps { data: ContributionData[]; - contributionsLast30Days: number; + contributionsShown: number; totalDaysShown: number; subtitle?: string; footerText?: string; @@ -28,9 +28,9 @@ interface ContributionHeatmapProps { const ContributionHeatmap: React.FC = ({ data, - contributionsLast30Days, + contributionsShown, totalDaysShown, - subtitle = 'network contribution(s) in the last 30 days', + subtitle = `network contribution(s) in the last ${totalDaysShown} day(s)`, footerText, emptyTitle = 'No contributions yet', emptySubtitle = 'Activity will appear here once PRs are merged', @@ -55,7 +55,7 @@ const ContributionHeatmap: React.FC = ({ lineHeight: 1, }} > - {contributionsLast30Days.toLocaleString()} + {contributionsShown.toLocaleString()} = ({ }; // Calculate contribution heatmap data - const { contributionData, contributionsLast30Days, totalDaysShown } = + const { contributionData, contributionsShown, totalDaysShown } = useMemo(() => { if (!prs || prs.length === 0) { return { contributionData: [], - contributionsLast30Days: 0, - totalDaysShown: 0, + contributionsShown: 0, + totalDaysShown: 1, }; } @@ -385,9 +385,6 @@ const MinerActivity: React.FC = ({ dataMap.set(format(subDays(today, i), 'yyyy-MM-dd'), 0); } - let last30Count = 0; - const thirtyDaysAgo = subDays(today, 30); - prs.forEach((pr) => { if (!pr.mergedAt) return; const date = new Date(pr.mergedAt); @@ -397,9 +394,13 @@ const MinerActivity: React.FC = ({ if (dataMap.has(dateStr)) { dataMap.set(dateStr, (dataMap.get(dateStr) || 0) + 1); } - if (date >= thirtyDaysAgo) last30Count++; }); + const shownCount = Array.from(dataMap.values()).reduce( + (total, count) => total + count, + 0, + ); + const data = Array.from(dataMap.entries()) .map(([date, count]) => { let level: 0 | 1 | 2 | 3 | 4 = 0; @@ -413,8 +414,8 @@ const MinerActivity: React.FC = ({ return { contributionData: data, - contributionsLast30Days: last30Count, - totalDaysShown: daysToShow, + contributionsShown: shownCount, + totalDaysShown: data.length, }; }, [prs]); @@ -660,9 +661,9 @@ const MinerActivity: React.FC = ({ >