-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-heatmap.js
More file actions
58 lines (47 loc) · 1.45 KB
/
Copy pathdebug-heatmap.js
File metadata and controls
58 lines (47 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const { format } = require("date-fns");
function seededRandom(seed) {
const x = Math.sin(seed++) * 10000;
return x - Math.floor(x);
}
function generateSampleHeatmapData() {
const days = [];
const demoYear = new Date().getFullYear();
// Stats
let completedCount = 0;
let totalDays = 0;
for (let month = 0; month < 12; month++) {
const daysInMonth = new Date(demoYear, month + 1, 0).getDate();
for (let day = 1; day <= daysInMonth; day++) {
totalDays++;
const date = new Date(demoYear, month, day);
const dateStr = format(date, "yyyy-MM-dd");
const startOfYear = new Date(demoYear, 0, 1);
const dayOfYear = Math.floor(
(date.getTime() - startOfYear.getTime()) / (1000 * 60 * 60 * 24)
);
// Matches current implementation in page.tsx
const seed = dayOfYear * 1337;
const rand = seededRandom(seed);
const isCompleted = rand > 0.25;
if (isCompleted) {
completedCount++;
}
days.push({
date: dateStr,
completed: isCompleted,
rand: rand,
});
}
}
console.log(`Total Days: ${totalDays}`);
console.log(`Completed Days: ${completedCount}`);
console.log(
`Percentage: ${((completedCount / totalDays) * 100).toFixed(2)}%`
);
// Show first few days
console.log("First 10 days:");
days
.slice(0, 10)
.forEach((d) => console.log(`${d.date}: ${d.completed} (rand=${d.rand})`));
}
generateSampleHeatmapData();