diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2b0f3d2 --- /dev/null +++ b/Makefile @@ -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 diff --git a/check-logins.coffee b/check-logins.coffee new file mode 100644 index 0000000..dd7bab8 --- /dev/null +++ b/check-logins.coffee @@ -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 diff --git a/format-languages.coffee b/format-languages.coffee new file mode 100644 index 0000000..fffa594 --- /dev/null +++ b/format-languages.coffee @@ -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' diff --git a/format-users.coffee b/format-users.coffee new file mode 100644 index 0000000..1bb2006 --- /dev/null +++ b/format-users.coffee @@ -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. + +
# | +Username | +Contributions | +Language | +Location | ++ \n + """ + + rows = stats.slice(0, maxNumber).map (stat, index) -> + """ + |
---|---|---|---|---|---|
##{index + 1} | +#{stat.login}#{if stat.name then ' (' + stat.name + ')' else ''} | +#{stat.contributions} | +#{stat.language} | +#{stat.location} | +