Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A small script to query github releases for download counts, summarizing them by ia32 or not in their file name. Working on providing data for the decision to drop ia32 support for node 10 https://github.com/nodejs/build/issues/885#issuecomment-386893606
#!/usr/bin/env node
const r2 = require('r2');
const API_HOST = 'https://api.github.com/graphql';
const PUBLIC_READ_TOKEN = 'XXX'; // (only needs public repo scope)
const query = `
query {
repository(owner: "node-serialport", name: "node-serialport") {
nameWithOwner
owner {
login
}
diskUsage
releases(last: 20) {
edges {
node {
id
createdAt
description
tag {
id
name
}
releaseAssets(first: 100) {
totalCount
edges {
node {
name
downloadCount
}
}
}
}
}
}
}
}
`;
const inspect = data => console.log(JSON.stringify(data, null, 2));
const getData = async () => {
const response = await r2.post(API_HOST, { headers: { 'Authorization': `bearer ${PUBLIC_READ_TOKEN}` }, json: { query, operationName: null, variables: {} } }).response;
return response.json();
};
const popNode = ({ node }) => node
const notWindows = ({ name }) => !name.match(/win32/)
async function work() {
const { data } = await getData()
const releases = data.repository.releases.edges.map(popNode)
const assestsByTag = releases.reduce((memo, release) => {
return [ ...memo, { tag: release.tag.name, createdAt: release.createdAt, assets: release.releaseAssets.edges.map(popNode) }]
},[])
const downlodCountsByReleaseAndArch = assestsByTag.map(({ tag, assets, createdAt }) => {
const ia32 = assets.filter(notWindows).reduce((count, { name, downloadCount }) => name.match(/ia32/) ? count + downloadCount : count, 0)
const other = assets.filter(notWindows).reduce((count, { name, downloadCount }) => !name.match(/ia32/) ? count + downloadCount : count, 0)
return { tag, createdAt, ia32, other, 'ia32%': Math.round(ia32 / (other + ia32)*100) }
})
console.log(downlodCountsByReleaseAndArch.map(item => JSON.stringify(item)).join('\n'))
}
work()
{"tag":"v1.4.6","createdAt":"2016-04-29T21:29:34Z","ia32":1239,"other":661777,"ia32%":0}
{"tag":"v1.5.0","createdAt":"2016-09-27T12:33:01Z","ia32":526,"other":781420,"ia32%":0}
{"tag":"v1.5.1","createdAt":"2016-12-27T10:36:57Z","ia32":0,"other":2448,"ia32%":0}
{"tag":"v1.5.2","createdAt":"2016-12-29T18:18:18Z","ia32":0,"other":716,"ia32%":0}
{"tag":"v1.5.3","createdAt":"2016-12-30T10:28:40Z","ia32":0,"other":158872,"ia32%":0}
{"tag":"v1.6.0","createdAt":"2017-02-05T16:48:31Z","ia32":0,"other":623999,"ia32%":0}
{"tag":"v1.7.0-0","createdAt":"2017-04-12T11:33:57Z","ia32":0,"other":1139,"ia32%":0}
{"tag":"v1.7.0","createdAt":"2017-05-17T12:21:51Z","ia32":0,"other":32540,"ia32%":0}
{"tag":"v1.7.1","createdAt":"2017-06-01T14:06:20Z","ia32":0,"other":21464,"ia32%":0}
{"tag":"v1.7.2","createdAt":"2017-06-08T09:44:34Z","ia32":0,"other":1324628,"ia32%":0}
{"tag":"v1.8.0","createdAt":"2017-09-13T21:03:59Z","ia32":0,"other":19362,"ia32%":0}
{"tag":"v1.9.0","createdAt":"2017-09-28T18:45:32Z","ia32":0,"other":516270,"ia32%":0}
{"tag":"v2.0.0","createdAt":"2017-10-02T09:24:14Z","ia32":0,"other":11485,"ia32%":0}
{"tag":"v2.0.1","createdAt":"2017-11-11T08:30:09Z","ia32":0,"other":4429,"ia32%":0}
{"tag":"v2.0.2","createdAt":"2017-11-22T23:05:23Z","ia32":0,"other":1637,"ia32%":0}
{"tag":"v2.1.0","createdAt":"2017-11-24T14:08:02Z","ia32":0,"other":1909,"ia32%":0}
{"tag":"v2.1.1","createdAt":"2017-12-02T12:33:42Z","ia32":0,"other":275093,"ia32%":0}
{"tag":"v3.0.0","createdAt":"2018-01-30T22:07:31Z","ia32":0,"other":50162,"ia32%":0}
{"tag":"v3.0.1","createdAt":"2018-04-26T20:23:37Z","ia32":0,"other":6306,"ia32%":0}
{"tag":"v3.0.2","createdAt":"2018-05-05T13:42:25Z","ia32":0,"other":588,"ia32%":0}
{"tag":"v4.0.0","createdAt":"2016-12-10T09:27:12Z","ia32":935,"other":234445,"ia32%":0}
{"tag":"v4.1.0","createdAt":"2016-12-19T07:14:11Z","ia32":586,"other":75887,"ia32%":1}
{"tag":"v4.1.1","createdAt":"2016-12-20T10:20:51Z","ia32":1627,"other":548530,"ia32%":0}
{"tag":"v4.2.0","createdAt":"2017-01-08T04:07:20Z","ia32":788,"other":250699,"ia32%":0}
{"tag":"v4.3.0","createdAt":"2017-01-12T09:42:27Z","ia32":2130,"other":930721,"ia32%":0}
{"tag":"v4.4.0","createdAt":"2017-01-26T03:07:55Z","ia32":911,"other":230025,"ia32%":0}
{"tag":"v4.5.0","createdAt":"2017-01-31T11:35:24Z","ia32":15976,"other":4671501,"ia32%":0}
{"tag":"v4.5.1","createdAt":"2017-03-21T11:07:45Z","ia32":2715,"other":886157,"ia32%":0}
{"tag":"v4.5.2","createdAt":"2017-03-29T06:27:32Z","ia32":13386,"other":5350016,"ia32%":0}
{"tag":"v4.5.3","createdAt":"2017-05-16T14:53:05Z","ia32":92043,"other":32920115,"ia32%":0}
{"tag":"v4.6.0","createdAt":"2017-11-03T09:28:54Z","ia32":4304,"other":2118331,"ia32%":0}
{"tag":"v4.6.1","createdAt":"2017-11-11T21:21:54Z","ia32":4189,"other":1518666,"ia32%":0}
{"tag":"v4.7.0","createdAt":"2017-11-16T10:46:56Z","ia32":397,"other":1951,"ia32%":17}
{"tag":"v4.7.1","createdAt":"2017-11-17T11:09:37Z","ia32":1200,"other":385841,"ia32%":0}
{"tag":"v4.7.2","createdAt":"2017-11-20T21:44:00Z","ia32":25608,"other":23491661,"ia32%":0}
{"tag":"v4.8.0","createdAt":"2018-03-10T09:02:51Z","ia32":313,"other":12080,"ia32%":3}
{"tag":"v4.8.1","createdAt":"2018-03-11T09:44:35Z","ia32":781,"other":208622,"ia32%":0}
{"tag":"v4.8.2","createdAt":"2018-03-13T10:36:21Z","ia32":502,"other":131637,"ia32%":0}
{"tag":"v4.8.3","createdAt":"2018-03-17T21:23:14Z","ia32":6525,"other":4750583,"ia32%":0}
{"tag":"v4.9.0","createdAt":"2018-04-25T10:40:46Z","ia32":1993,"other":1048409,"ia32%":0}
{"tag":"4.0.7","createdAt":"2016-12-12T04:28:52Z","ia32":15165,"other":790664,"ia32%":2}
{"tag":"5.0.0-beta3","createdAt":"2017-01-12T06:09:22Z","ia32":47,"other":1640,"ia32%":3}
{"tag":"5.0.0-beta4","createdAt":"2017-06-17T16:43:58Z","ia32":6,"other":147,"ia32%":4}
{"tag":"5.0.0-beta5","createdAt":"2017-06-20T01:21:33Z","ia32":9,"other":179,"ia32%":5}
{"tag":"5.0.0-beta6","createdAt":"2017-07-05T13:34:11Z","ia32":10,"other":105,"ia32%":9}
{"tag":"5.0.0-beta7","createdAt":"2017-07-10T19:33:12Z","ia32":56,"other":13225,"ia32%":0}
{"tag":"5.0.0-beta8","createdAt":"2017-07-17T13:28:51Z","ia32":82,"other":30298,"ia32%":0}
{"tag":"5.0.0-beta9","createdAt":"2017-07-30T00:20:29Z","ia32":7,"other":53,"ia32%":12}
{"tag":"5.0.0","createdAt":"2017-07-30T04:34:41Z","ia32":1609,"other":86649,"ia32%":2}
{"tag":"v5.1.0-beta5","createdAt":"2017-08-04T02:55:41Z","ia32":21,"other":111,"ia32%":16}
{"tag":"v6.0.0-beta1","createdAt":"2017-08-07T22:38:00Z","ia32":29,"other":289,"ia32%":9}
{"tag":"v6.0.0-beta2","createdAt":"2017-09-07T02:15:27Z","ia32":24,"other":816,"ia32%":3}
{"tag":"v6.0.0-beta3","createdAt":"2017-10-07T13:38:15Z","ia32":39,"other":99,"ia32%":28}
{"tag":"v6.0.0","createdAt":"2017-10-09T22:33:27Z","ia32":124,"other":2375,"ia32%":5}
{"tag":"v6.0.3","createdAt":"2017-10-22T16:03:05Z","ia32":52,"other":897,"ia32%":5}
{"tag":"v6.0.4","createdAt":"2017-10-26T02:55:45Z","ia32":1435,"other":37451,"ia32%":4}
{"tag":"v6.0.5","createdAt":"2018-02-04T23:18:57Z","ia32":691,"other":16615,"ia32%":4}
{"tag":"v6.1.0","createdAt":"2018-02-06T01:54:53Z","ia32":96,"other":840,"ia32%":10}
{"tag":"v6.1.1","createdAt":"2018-02-28T02:18:47Z","ia32":881,"other":21255,"ia32%":4}
{"tag":"v6.2.0","createdAt":"2018-04-18T12:18:46Z","ia32":182,"other":7135,"ia32%":2}
@reconbot

This comment has been minimized.

Copy link
Owner Author

@reconbot reconbot commented May 6, 2018

Going through the top packages that provide binaries with @evilpacket's list here https://gist.github.com/evilpacket/04d94524793d8531b204ab339fbdfe13

@reconbot

This comment has been minimized.

Copy link
Owner Author

@reconbot reconbot commented May 6, 2018

Left a note for sqlite3, I have a hunch they have more ia32 users than others because it's the goto database for embedded systems. mapbox/node-sqlite3#982

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment