-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
WikiTeams
committed
Jun 16, 2013
1 parent
85152d4
commit 990f027
Showing
6 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
all: get format | ||
|
||
get: | ||
../node_modules/coffee-script/bin/coffee -c get-repositories.coffee | ||
../node_modules/coffee-script/bin/coffee -c get-details.coffee | ||
|
||
format: | ||
../node_modules/coffee-script/bin/coffee format-languages.coffee | ||
../node_modules/coffee-script/bin/coffee format-users.coffee | ||
../node_modules/coffee-script/bin/coffee format-repositories.coffee |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env coffee | ||
utils = require './utils' | ||
fs = require 'fs' | ||
data = require './raw/github-users-stats.json' | ||
prev = require './old-logins.json' | ||
curr = require './temp-logins.json' | ||
|
||
filtered = prev | ||
.filter(utils.isNotIn(curr)) | ||
.map(utils.reverseFind(data)) | ||
.filter((_) -> _) | ||
.map (_) -> | ||
login: _.login, followers: _.followers | ||
.sort (a, b) -> | ||
b.followers - a.followers | ||
|
||
console.log filtered | ||
console.log JSON.stringify filtered.map(utils.prop 'login'), null, 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env coffee | ||
utils = require './utils' | ||
|
||
getLanguageStats = (inputFile, outFile) -> | ||
stats = require inputFile | ||
total = stats.length | ||
unsorted = Total: total | ||
stats.forEach (stat) -> | ||
{language} = stat | ||
return unless language | ||
unsorted[language] ?= 0 | ||
unsorted[language] += 1 | ||
|
||
languages = {} | ||
Object.keys(unsorted) | ||
.sort (a, b) -> | ||
unsorted[b] - unsorted[a] | ||
.forEach (language) -> | ||
languages[language] = unsorted[language] | ||
|
||
utils.writeStats outFile, languages | ||
|
||
getLanguageStats './raw/github-users-stats.json', './raw/github-languages-stats.json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 = 176 | ||
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env coffee | ||
cheerio = require 'cheerio' | ||
utils = require './utils' | ||
|
||
stats = {} | ||
|
||
getStats = (html, url) -> | ||
$ = cheerio.load html | ||
byProp = (field) -> $("[itemprop='#{field}']") | ||
getInt = (text) -> parseInt text.replace ',', '' | ||
getOrgName = (index, item) -> $(item).attr('title') | ||
getFollowers = -> | ||
text = $('.stats li:nth-child(1) a').text().trim() | ||
multiplier = if text.indexOf('k') > 0 then 1000 else 1 | ||
(parseFloat text) * multiplier | ||
|
||
pageDesc = $('meta[name="description"]').attr('content') | ||
|
||
userStats = | ||
name: byProp('name').text().trim() | ||
login: byProp('additionalName').text().trim() | ||
location: byProp('homeLocation').text().trim() | ||
language: (/\sin ([\w-]+)/.exec(pageDesc)?[1] ? '') | ||
gravatar: byProp('image').attr('href') | ||
followers: getFollowers() | ||
organizations: $('.orgs li > a').map(getOrgName) | ||
contributions: getInt $('.contrib-day > .num').text() | ||
contributionsStreak: getInt $('.contrib-streak > .num').text() | ||
contributionsCurrentStreak: getInt $('.contrib-streak-current > .num').text() | ||
|
||
stats[userStats.login] = userStats | ||
userStats | ||
|
||
sortStats = (stats) -> | ||
minContributions = 1 | ||
Object.keys(stats) | ||
.filter (login) -> | ||
stats[login].contributions >= minContributions | ||
.sort (a, b) -> | ||
stats[b].contributions - stats[a].contributions | ||
.map (login) -> | ||
stats[login] | ||
|
||
saveStats = -> | ||
logins = require './temp-logins.json' | ||
urls = logins.map (login) -> "https://github.com/#{login}" | ||
utils.batchGet urls, getStats, -> | ||
utils.writeStats './raw/github-users-stats.json', sortStats stats | ||
|
||
saveStats() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env coffee | ||
fs = require 'fs' | ||
utils = require './utils' | ||
|
||
saveTopLogins = -> | ||
MIN_FOLLOWERS = 170 | ||
MAX_PAGES = 10 | ||
urls = utils.range(1, MAX_PAGES + 1).map (page) -> | ||
"https://api.github.com/legacy/user/search/followers:%3E#{MIN_FOLLOWERS}?sort=followers&order=desc&start_page=#{page}" | ||
|
||
parse = (text) -> | ||
JSON.parse(text).users.map (_) -> _.username | ||
|
||
utils.batchGet urls, parse, (all) -> | ||
logins = [].concat.apply [], all | ||
utils.writeStats './temp-logins.json', logins | ||
|
||
saveTopLogins() |