forked from conda-forge/conda-forge.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.js
54 lines (47 loc) · 1.85 KB
/
stats.js
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
function loadStatsJSON (url, callback) {
var xobj = new XMLHttpRequest()
xobj.overrideMimeType('application/json')
xobj.open('GET', url, true)
xobj.onreadystatechange = function () {
if (xobj.readyState === 4 && xobj.status === 200) {
// Required use of an anonymous callback as .open will NOT return a value
// but simply returns undefined in asynchronous mode
callback(xobj.responseText)
}
}
xobj.send(null)
}
function displayStatsJSON (reportText) {
var stats = JSON.parse(reportText)
var div = document.getElementById('stats-downloads')
var mlns = stats.downloads.month / 1e6
var blns = stats.downloads.all / 1e9
div.innerHTML = (
mlns.toFixed(0) + ' million monthly downloads<br>' +
blns.toFixed(1) + ' billion all-time downloads'
)
div = document.getElementById('stats-members')
div.innerHTML = (
stats.n_members_core + ' core devs<br>' +
stats.n_members_staged_recipes + ' staged-recipes maintainers<br>' +
(stats.n_members / 1e3).toFixed(1) + 'k feedstock maintainers'
)
div = document.getElementById('stats-data')
div.innerHTML = (
(stats.n_repos / 1e3).toFixed(1) + 'k feedstocks<br>' +
(stats.n_packages / 1e3).toFixed(1) + 'k packages<br>' +
(stats.n_artifacts / 1e6).toFixed(1) + 'M artifacts'
)
div = document.getElementById('stats-issues-prs')
div.innerHTML = (
((stats.n_prs + stats.n_issues) / 1e3).toFixed(1) + 'k issues+PRs<br>' +
((stats.n_open_prs + stats.n_open_issues) / 1e3).toFixed(1) + 'k/' +
((stats.n_closed_prs + stats.n_closed_issues) / 1e3).toFixed(1) + 'k open/closed'
)
div = document.getElementById('stats1')
div.style.display = ''
div = document.getElementById('stats2')
div.style.display = ''
}
var url = 'https://raw.githubusercontent.com/conda-forge/by-the-numbers/main/data/live_counts.json'
loadStatsJSON(url, displayStatsJSON)