Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,21 @@ async function GenerateHtml() {
'25': '0.13.0',
};
let repoHistories = [];
const repoFields = [
'forks',
'stars',
'watchers',
'open_pulls',
'closed_pulls',
'merged_pulls',
'open_issues',
'closed_issues',
];
{
const rs = await client.execute(
`
SELECT
created_at,
forks,
stars,
watchers,
open_pulls,
closed_pulls,
merged_pulls,
open_issues,
closed_issues
created_at, ${repoFields.join(', ')}
FROM
repo_histories
ORDER BY
Expand All @@ -203,9 +205,9 @@ limit 1000
}

const idsToShow = [
'25', // 0.13.0
'23', // 0.12.0
// '20', // '0.14.0',
// '25', // 0.13.0
// '23', // 0.12.0
'20', // '0.14.0',
// '19', // '0.15.0',
];

Expand Down Expand Up @@ -237,6 +239,7 @@ limit 1000
repoHistoriesStr: JSON.stringify(repoHistories),
idToTitle: idToTitle,
idsToShow: idsToShow,
repoFields: repoFields,
});
fs.writeFileSync('web/raw.html', body, fileOpts);
}
Expand Down
12 changes: 9 additions & 3 deletions template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
const repoHistories = <%- repoHistoriesStr %>;
window.onload = function() {
const charts = [
renderRepoChart(repoHistories, "repo-chart"),
<% for(const [index, field] of repoFields.entries()) { %>
renderRepoChart(repoHistories, '<%= field %>', <%= index+1 %>),
<% } %>

<% for(const id of idsToShow) { %>
renderMilestoneChart(historiesById, <%= id %>),
<% } %>
Expand All @@ -31,8 +34,6 @@
<body>
<main>
<h1><a href="https://github.com/ziglang/zig/milestones">Zig Milestone</a> Monitor</h1>
<h3><a href="https://github.com/ziglang/zig">Zig repository</a></h3>
<div class="chart" id="repo-chart"></div>
<% for(const id of idsToShow) { %>
<section>
<h3><a href="https://github.com/ziglang/zig/milestone/<%= id %>"><%= idToTitle[id] %></a></h3>
Expand All @@ -55,6 +56,11 @@
</section>
<% } %>

<h3><a href="https://github.com/ziglang/zig">Zig repository</a></h3>
<% for(const field of repoFields) { %>
<div class="chart" id="repo-<%= field %>"></div>
<% } %>

<footer> &copy; 2024 <a href="https://ziglang.cc">ZigCC</a>
| <a href="https://github.com/zigcc/zig-milestone">GitHub</a>
| <a href="mailto:[email protected]">Feedback</a>
Expand Down
44 changes: 11 additions & 33 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const commonChartOpts = {
boundaryGap: false,
},
yAxis: {
type: 'value'
type: 'value',
scale: true,
},
dataZoom: [{
start: 0,
Expand Down Expand Up @@ -81,45 +82,22 @@ function renderMilestoneChart(historiesById, milestoneId) {
}


function renderRepoChart(repoHistories, repoId) {
const dom = document.getElementById(`${repoId}`);
function renderRepoChart(repoHistories, repoField, fieldIdx) {
const dom = document.getElementById(`repo-${repoField}`);
const chart = echarts.init(dom, null, {
renderer: 'canvas',
useDirtyRect: false
});
const columns = [
'forks',
'stars',
'watchers',
'open_pulls',
'closed_pulls',
'merged_pulls',
'open_issues',
'closed_issues',
];
var opt = {...commonChartOpts};
const series = columns.map((col, colIdx) => {
let series = {
name: col, type: 'line', stack: 'Total',
data: [],
};
for(const row of repoHistories) {
// first col is timestamp, shift by one.
series['data'].push([row[0], row[colIdx+1]]);
}

return series;
});
opt['legend'] = {
selected: columns.reduce((acc, curr) => {
// By default only show stars
acc[curr] = curr === 'stars';
return acc;
}, {}),
data: columns,
data: [repoField],
};
opt['toolbox'] = {};
opt['series'] = series;
opt['series'] = [{
name: repoField,
type: 'line',
stack: 'Total',
data: repoHistories.map((item) => [item[0], item[fieldIdx]])
}];

chart.setOption(opt);
addLegendClick(chart);
Expand Down