-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathroadmap.data.js
More file actions
65 lines (56 loc) · 1.62 KB
/
roadmap.data.js
File metadata and controls
65 lines (56 loc) · 1.62 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
59
60
61
62
63
64
65
const REPO = "zarr-developers/geozarr-spec";
export default {
async load() {
const response = await fetch(
`https://api.github.com/repos/${REPO}/issues?state=all&per_page=100`,
{
headers: {
Accept: "application/vnd.github+json",
...(process.env.GITHUB_TOKEN && {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
}),
},
}
);
if (!response.ok) {
console.warn(
`GitHub API returned ${response.status}, falling back to empty data`
);
return { milestones: [] };
}
const issues = await response.json();
// Group issues by milestone
const milestoneMap = new Map();
for (const issue of issues) {
if (!issue.milestone || issue.pull_request) continue;
const ms = issue.milestone;
if (!milestoneMap.has(ms.number)) {
milestoneMap.set(ms.number, {
number: ms.number,
title: ms.title,
description: ms.description,
dueOn: ms.due_on,
issues: [],
});
}
milestoneMap.get(ms.number).issues.push({
number: issue.number,
title: issue.title,
state: issue.state,
url: issue.html_url,
labels: issue.labels.map((l) => ({
name: l.name,
color: l.color,
})),
});
}
// Sort milestones by number, issues by number within each
const milestones = [...milestoneMap.values()]
.sort((a, b) => a.number - b.number)
.map((ms) => ({
...ms,
issues: ms.issues.sort((a, b) => a.number - b.number),
}));
return { milestones };
},
};