Skip to content

Commit c58d618

Browse files
committed
ENH add stats to website
1 parent c200fa7 commit c58d618

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

css/theme.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,9 @@ body {
416416
max-width: 100%;
417417
height: auto;
418418
}
419+
420+
/* https://stackoverflow.com/a/25517025 */
421+
.vcenter {
422+
display: flex;
423+
align-items: center;
424+
}

index.html.tmpl

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<meta name="viewport" content="width=device-width, initial-scale=1">
99
<meta name="description" content="">
1010
<meta name="author" content="">
11-
11+
1212
<link rel="shortcut icon" href="img/favicon.ico">
1313

1414
<title>conda-forge | community driven packaging for conda</title>
@@ -121,6 +121,28 @@
121121
each repository, also known as a feedstock, automatically
122122
builds its own recipe in a clean and repeatable way on Windows, Linux and OSX.
123123
</p>
124+
</div>
125+
</div>
126+
127+
<div class="row vcenter" style="display: none;" id="stats1">
128+
<div class="col-md-4 col-md-offset-2 padded">
129+
<p class="text-center" id="stats-downloads"></p>
130+
</div>
131+
<div class="col-md-4 padded">
132+
<p class="text-center" id="stats-members"></p>
133+
</div>
134+
</div>
135+
<div class="row vcenter" style="display: none;" id="stats2">
136+
<div class="col-md-4 col-md-offset-2 padded">
137+
<p class="text-center" id="stats-data"></p>
138+
</div>
139+
<div class="col-md-4 padded">
140+
<p class="text-center" id="stats-issues-prs"></p>
141+
</div>
142+
</div>
143+
144+
<div class="row">
145+
<div class="col-lg-8 col-lg-offset-2 padded">
124146
<p>
125147
The built distributions are uploaded to <a href="http://anaconda.org/conda-forge">anaconda.org/conda-forge</a>
126148
and can be <a href="http://conda.pydata.org/docs/intro.html">installed with conda</a>. For example, to install a
@@ -394,6 +416,9 @@
394416
<!-- Custom Theme JavaScript -->
395417
<script src="js/theme.js"></script>
396418

419+
<!-- stats -->
420+
<script src="js/stats.js"></script>
421+
397422
</body>
398423

399424
</html>

js/stats.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
function loadStatsJSON (url, callback) {
2+
var xobj = new XMLHttpRequest()
3+
xobj.overrideMimeType('application/json')
4+
xobj.open('GET', url, true)
5+
xobj.onreadystatechange = function () {
6+
if (xobj.readyState === 4 && xobj.status === 200) {
7+
// Required use of an anonymous callback as .open will NOT return a value
8+
// but simply returns undefined in asynchronous mode
9+
callback(xobj.responseText)
10+
}
11+
}
12+
xobj.send(null)
13+
}
14+
15+
function displayStatsJSON (reportText) {
16+
var stats = JSON.parse(reportText)
17+
18+
var div = document.getElementById('stats-downloads')
19+
var mlns = stats.downloads.month / 1e6
20+
var blns = stats.downloads.all / 1e9
21+
div.innerHTML = (
22+
mlns.toFixed(0) + ' million monthly downloads<br>' +
23+
blns.toFixed(0) + ' billion all-time downloads'
24+
)
25+
26+
div = document.getElementById('stats-members')
27+
div.innerHTML = (
28+
stats.n_members_core + ' core devs<br>' +
29+
stats.n_members_staged_recipes + ' staged-recipes maintainers<br>' +
30+
(stats.n_members / 1e3).toFixed(1) + 'k feedstock maintainers'
31+
)
32+
33+
div = document.getElementById('stats-data')
34+
div.innerHTML = (
35+
(stats.n_repos / 1e3).toFixed(1) + 'k feedstocks<br>' +
36+
(stats.n_packages / 1e3).toFixed(1) + 'k packages<br>' +
37+
(stats.n_artifacts / 1e3).toFixed(1) + 'k artifacts'
38+
)
39+
40+
div = document.getElementById('stats-issues-prs')
41+
div.innerHTML = (
42+
((stats.n_prs + stats.n_issues) / 1e3).toFixed(1) + 'k issues+PRs<br>' +
43+
((stats.n_open_prs + stats.n_open_issues) / 1e3).toFixed(1) + 'k/' +
44+
((stats.n_closed_prs + stats.n_closed_issues) / 1e3).toFixed(1) + 'k open/closed'
45+
)
46+
47+
div = document.getElementById('stats1')
48+
div.style.display = ''
49+
div = document.getElementById('stats2')
50+
div.style.display = ''
51+
}
52+
53+
var url = 'https://raw.githubusercontent.com/conda-forge/by-the-numbers/main/data/live_counts.json'
54+
loadStatsJSON(url, displayStatsJSON)

0 commit comments

Comments
 (0)