fixed the heatmap cells being too sensitive compared to the original forgejo heatmap

This commit is contained in:
dvorakmortonxd 2026-05-15 23:58:50 +02:00
commit d7ea83d031

View file

@ -43,10 +43,13 @@ export default function ContributionHeatmap() {
const data: HeatmapData[] = await res.json();
const map = new Map<string, number>();
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 });