Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exclude bots from random contributor #476

Merged
merged 3 commits into from
May 10, 2022
Merged
Changes from 2 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
15 changes: 10 additions & 5 deletions src/hooks/useAdoptiumContributorsApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { useEffect, useState } from 'react';

// List of repos that will be checked for contributions
const repositories = [
'temurin-build', 'ci-jenkins-pipelines', 'infrastructure', 'aqa-tests', 'adoptium.net', 'api.adoptium.net', 'blog.adoptium.net', 'containers', 'installer',
'temurin-build', 'ci-jenkins-pipelines', 'infrastructure', 'aqa-tests', 'website-v2', 'api.adoptium.net', 'blog.adoptium.net', 'containers', 'installer',
'STF', 'run-aqa', 'TKG', 'aqa-test-tooks', 'aqa-systemtest', 'bumblebench', 'jenkins-helper'
];

]
// List of users to exclude from random contributor
const whitelistedContributors = ['dependabot-preview[bot]', 'dependabot[bot]', 'eclipse-temurin-bot'];
gdams marked this conversation as resolved.
Show resolved Hide resolved

const randomValue = (list) => {
return list[Math.floor(Math.random() * list.length)];
Expand Down Expand Up @@ -46,7 +48,7 @@ function linkParser(linkHeader: string): {
}

/**
* Retrieves max amount of contributors for Node.js main repo.
* Retrieves max amount of contributors for Adoptium repos.
* Returns array with random contributor index and max contributors found.
*/
async function getMaxContributors(): Promise<[number, number]> {
Expand Down Expand Up @@ -117,7 +119,10 @@ async function fetchRandomContributor() {
}
const [randomPage, lastPage] = await getMaxContributors();

const contributor = await getContributor(randomPage);
let contributor = await getContributor(randomPage);
while (whitelistedContributors.includes(contributor.login)) {
contributor = await getContributor(randomPage);
}

if (window.localStorage) {
window.localStorage.setItem('fetch_date', String(Date.now()));
Expand Down Expand Up @@ -176,4 +181,4 @@ export interface Contributor {
contributionsCount: number;
commitsListUri: string;
repo: string;
}
}