Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 53 additions & 6 deletions commands/ContributorsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,61 @@ public function actionGenerate()
$token = trim(file_get_contents($tokenFile));
$client->authenticate($token, null, \Github\Client::AUTH_HTTP_TOKEN);
}

// Get all repositories from yiisoft organization
$orgApi = $client->api('organization');
$orgPaginator = new \Github\ResultPager($client);
$this->stdout("Fetching all repositories from yiisoft organization...\n");
$repositories = $orgPaginator->fetch($orgApi, 'repositories', ['yiisoft']);

while ($orgPaginator->hasNext()) {
$repositories = array_merge($repositories, $orgPaginator->fetchNext());
}

$this->stdout("Found " . count($repositories) . " repositories in yiisoft organization.\n");

// Aggregate contributors from all repositories
$allContributors = [];
$api = $client->api('repo');
$paginator = new \Github\ResultPager($client);
$parameters = ['yiisoft', 'yii2'];
$rawContributors = $paginator->fetch($api, 'contributors', $parameters);

while ($paginator->hasNext() && count($rawContributors) < $contributorLimit) {
$rawContributors = array_merge($rawContributors, $paginator->fetchNext());

foreach ($repositories as $repo) {
$repoName = $repo['name'];
$this->stdout("Fetching contributors from yiisoft/{$repoName}...\n");

try {
$paginator = new \Github\ResultPager($client);
$parameters = ['yiisoft', $repoName];
$repoContributors = $paginator->fetch($api, 'contributors', $parameters);

while ($paginator->hasNext() && count($allContributors) < $contributorLimit) {
$repoContributors = array_merge($repoContributors, $paginator->fetchNext());
}

// Merge contributors, summing contributions for duplicates
foreach ($repoContributors as $contributor) {
$login = $contributor['login'];
if (isset($allContributors[$login])) {
$allContributors[$login]['contributions'] += $contributor['contributions'];
} else {
$allContributors[$login] = $contributor;
}
}

if (count($allContributors) >= $contributorLimit) {
$this->stdout("Reached contributor limit of {$contributorLimit}.\n");
break;
}
} catch (\Exception $e) {
$this->stdout("Warning: Could not fetch contributors from {$repoName}: " . $e->getMessage() . "\n");
continue;
}
}

// Convert back to indexed array and sort by contributions
$rawContributors = array_values($allContributors);
usort($rawContributors, function($a, $b) {
return $b['contributions'] - $a['contributions'];
});

// remove team members
$teamGithubs = array_filter(array_map(function ($member) {
Expand Down
4 changes: 2 additions & 2 deletions views/site/team.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
</div>

<p>
There is a huge community of <a href="https://github.com/yiisoft/yii2/graphs/contributors">contributors</a> working on the Yii Framework code.
There is a huge community of <a href="https://github.com/yiisoft">contributors</a> working on the Yii Framework code.
Without their help it would not be possible to provide and maintain the huge amount of functionality,
documentation, and translations.
</p>
Expand All @@ -156,7 +156,7 @@
</div>
<?php else: ?>
<p>
The following list shows all the people who have contributed to the <a href="https://github.com/yiisoft/yii2">yiisoft/yii2</a> repository on Github.
The following list shows all the people who have contributed to <a href="https://github.com/yiisoft">yiisoft</a> repositories on Github.
If you are one of them, thank you! If not, <?= Html::a('become a part of it', ['site/contribute']) ?>!
</p>

Expand Down