You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-03 23:50:33 +02:00
Fixed stats page
This commit is contained in:
@ -54,9 +54,6 @@ function createChangeLog(releases) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const response = await fetch('https://api.github.com/repos/laurent22/joplin/releases');
|
|
||||||
//const response = await fetch('http://test.local/releases.json');
|
|
||||||
const releases = await response.json();
|
|
||||||
const rows = [];
|
const rows = [];
|
||||||
|
|
||||||
const totals = {
|
const totals = {
|
||||||
@ -65,6 +62,7 @@ async function main() {
|
|||||||
linux_count: 0,
|
linux_count: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const processReleases = (releases) => {
|
||||||
for (let i = 0; i < releases.length; i++) {
|
for (let i = 0; i < releases.length; i++) {
|
||||||
const release = releases[i];
|
const release = releases[i];
|
||||||
if (!release.tag_name.match(/^v\d+\.\d+\.\d+$/)) continue;
|
if (!release.tag_name.match(/^v\d+\.\d+\.\d+$/)) continue;
|
||||||
@ -82,6 +80,21 @@ async function main() {
|
|||||||
|
|
||||||
rows.push(row);
|
rows.push(row);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.info('Build stats: Downloading releases info...');
|
||||||
|
|
||||||
|
const baseUrl = 'https://api.github.com/repos/laurent22/joplin/releases?page=';
|
||||||
|
// const baseUrl = 'http://test.local/releases.json?page='
|
||||||
|
let pageNum = 1;
|
||||||
|
while (true) {
|
||||||
|
console.info('Build stats: Page ' + pageNum);
|
||||||
|
const response = await fetch(baseUrl + (pageNum + ''));
|
||||||
|
const releases = await response.json();
|
||||||
|
if (!releases || !releases.length) break;
|
||||||
|
processReleases(releases);
|
||||||
|
pageNum++;
|
||||||
|
}
|
||||||
|
|
||||||
const changelogText = createChangeLog(rows);
|
const changelogText = createChangeLog(rows);
|
||||||
await fs.writeFile(rootDir + '/readme/changelog.md', changelogText);
|
await fs.writeFile(rootDir + '/readme/changelog.md', changelogText);
|
||||||
@ -91,15 +104,24 @@ async function main() {
|
|||||||
totals.mac_percent = totals.mac_count / grandTotal;
|
totals.mac_percent = totals.mac_count / grandTotal;
|
||||||
totals.linux_percent = totals.linux_count / grandTotal;
|
totals.linux_percent = totals.linux_count / grandTotal;
|
||||||
|
|
||||||
|
const formatter = new Intl.NumberFormat('en-US', { style: 'decimal' });
|
||||||
|
|
||||||
const totalsMd = [
|
const totalsMd = [
|
||||||
{ name: 'Total Windows downloads', value: totals.windows_count },
|
{ name: 'Total Windows downloads', value: formatter.format(totals.windows_count) },
|
||||||
{ name: 'Total macOs downloads', value: totals.mac_count },
|
{ name: 'Total macOs downloads', value: formatter.format(totals.mac_count) },
|
||||||
{ name: 'Total Linux downloads', value: totals.linux_count },
|
{ name: 'Total Linux downloads', value: formatter.format(totals.linux_count) },
|
||||||
{ name: 'Windows %', value: Math.round(totals.windows_percent * 100) + '%' },
|
{ name: 'Windows %', value: Math.round(totals.windows_percent * 100) + '%' },
|
||||||
{ name: 'macOS %', value: Math.round(totals.mac_percent * 100) + '%' },
|
{ name: 'macOS %', value: Math.round(totals.mac_percent * 100) + '%' },
|
||||||
{ name: 'Linux %', value: Math.round(totals.linux_percent * 100) + '%' },
|
{ name: 'Linux %', value: Math.round(totals.linux_percent * 100) + '%' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
for (let i = 0; i < rows.length; i++) {
|
||||||
|
rows[i].mac_count = formatter.format(rows[i].mac_count);
|
||||||
|
rows[i].windows_count = formatter.format(rows[i].windows_count);
|
||||||
|
rows[i].linux_count = formatter.format(rows[i].linux_count);
|
||||||
|
rows[i].total_count = formatter.format(rows[i].total_count);
|
||||||
|
}
|
||||||
|
|
||||||
const statsMd = [];
|
const statsMd = [];
|
||||||
|
|
||||||
statsMd.push('# Joplin statistics');
|
statsMd.push('# Joplin statistics');
|
||||||
|
Reference in New Issue
Block a user