diff --git a/src/app/components/ContributionHeatmap.tsx b/src/app/components/ContributionHeatmap.tsx index 0a7526a..81482de 100644 --- a/src/app/components/ContributionHeatmap.tsx +++ b/src/app/components/ContributionHeatmap.tsx @@ -43,10 +43,13 @@ export default function ContributionHeatmap() { const data: HeatmapData[] = await res.json(); const map = new Map(); let total = 0; + let maxContribs = 0; data.forEach((item) => { const d = new Date(item.timestamp * 1000); const dateStr = d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0") + "-" + String(d.getDate()).padStart(2, "0"); - map.set(dateStr, (map.get(dateStr) || 0) + item.contributions); + const currentDayTotal = (map.get(dateStr) || 0) + item.contributions; + map.set(dateStr, currentDayTotal); + if (currentDayTotal > maxContribs) maxContribs = currentDayTotal; total += item.contributions; }); @@ -64,10 +67,12 @@ export default function ContributionHeatmap() { const contribs = map.get(dateStr) || 0; let level = 0; - if (contribs > 0) level = 1; - if (contribs >= 3) level = 2; - if (contribs >= 6) level = 3; - if (contribs >= 10) level = 4; + if (contribs > 0) { + level = 1; + if (contribs > maxContribs * 0.25) level = 2; + if (contribs > maxContribs * 0.5) level = 3; + if (contribs > maxContribs * 0.75) level = 4; + } currentWeek.push({ date: dateStr, contribs, level });