Created
December 15, 2010 16:59
-
-
Save baturin/742252 to your computer and use it in GitHub Desktop.
git-rating
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
<?php | |
require_once('php-github-api/lib/phpGitHubApi.php'); | |
$github = new phpGitHubApi(); | |
$repositories = array( | |
array('jquery', 'jquery'), array('madrobby', 'scriptaculous'), | |
array('jashkenas', 'coffee-script'), array('yui', 'yui3'), | |
array('sstephenson', 'prototype'), array('mootools', 'mootools-core') | |
); | |
function add(&$array, $key, $value){ | |
if (!array_key_exists($key, $array)) { $array[$key] = 0; } | |
$array[$key] += $value; | |
} | |
foreach ($repositories as $repository) { | |
list($user, $reponame) = $repository; | |
echo "Processing repository '$reponame' of user '$user'" . PHP_EOL; | |
echo 'Getting watchers' . PHP_EOL; | |
$watchers = $github->getRepoApi()->getRepoWatchers($user, $reponame); | |
foreach ($watchers as $watcher) { add($rating, $watcher, 10); } | |
echo 'Getting contributors' . PHP_EOL; | |
$contributors = $github->getRepoApi()->getRepoContributors($user, $reponame); | |
foreach ($contributors as $contributor) { add($rating, $contributor['login'], $contributor['contributions']); } | |
} | |
asort($rating); | |
foreach ($rating as $person => $ratingValue) { | |
echo implode(',', array($person, $ratingValue)) . PHP_EOL; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment