-
Notifications
You must be signed in to change notification settings - Fork 0
/
format-users.coffee
85 lines (68 loc) · 2.64 KB
/
format-users.coffee
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env coffee
fs = require 'fs'
top = (stats, field, type) ->
get = (stat) ->
value = stat[field]
if type is 'list' then value.length else value
format = (stat) ->
value = get stat
switch type
when 'thousands' then "#{(value / 1000)}k"
else value
stats
.slice()
.sort (a, b) ->
get(b) - get(a)
.slice(0, 15)
.map (stat) ->
login = stat.login
"[#{login}](https://github.com/#{login}) (#{format stat})"
.join ', '
stats2markdown = (datafile, mdfile, title) ->
minFollowers = 188
maxNumber = 256
stats = require(datafile)
today = new Date()
from = new Date()
from.setYear today.getFullYear() - 1
out = """
# Most active GitHub users ([git.io/top](http://git.io/top))
The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from **#{from.toGMTString()}** till **#{today.toGMTString()}**.
Only first 1000 GitHub users according to the count of followers are taken.
This is because of limitations of GitHub search. Sorting algo in pseudocode:
```coffeescript
githubUsers
.filter((user) -> user.followers > #{minFollowers})
.sortBy('contributions')
.slice(0, #{maxNumber})
```
Made with data mining of GitHub.com ([raw data](https://gist.github.com/4524946), [script](https://github.com/paulmillr/top-github-users)) by [@paulmillr](https://github.com/paulmillr) with contribs of [@lifesinger](https://githubcom/lifesinger). Updated every sunday.
<table cellspacing="0"><thead>
<th scope="col">#</th>
<th scope="col">Username</th>
<th scope="col">Contributions</th>
<th scope="col">Language</th>
<th scope="col">Location</th>
<th scope="col" width="30"></th>
</thead><tbody>\n
"""
rows = stats.slice(0, maxNumber).map (stat, index) ->
"""
<tr>
<th scope="row">##{index + 1}</th>
<td><a href="https://github.com/#{stat.login}">#{stat.login}</a>#{if stat.name then ' (' + stat.name + ')' else ''}</td>
<td>#{stat.contributions}</td>
<td>#{stat.language}</td>
<td>#{stat.location}</td>
<td><img width="30" height="30" src="#{stat.gravatar.replace('?s=400', '?s=30')}"></td>
</tr>
""".replace(/\n/g, '')
out += "#{rows.join('\n')}\n</tbody></table>\n\n"
out += """## Top 10 users from this list by other metrics:
* **Followers:** #{top stats, 'followers', 'thousands'}
* **Current contributions streak:** #{top stats, 'contributionsCurrentStreak'}
* **Organisations:** #{top stats, 'organizations', 'list'}
"""
fs.writeFileSync mdfile, out
console.log 'Saved to', mdfile
stats2markdown './raw/github-users-stats.json', './formatted/active.md'