Skip to content

Commit

Permalink
Exclude bots from random contributor (#476)
Browse files Browse the repository at this point in the history
Don't credit bots with authorship
  • Loading branch information
gdams committed May 10, 2022
1 parent 9263cbc commit be63522
Showing 1 changed file with 10 additions and 5 deletions.
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 excludedContributors = ['dependabot-preview[bot]', 'dependabot[bot]', 'eclipse-temurin-bot'];

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 (excludedContributors.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;
}
}

0 comments on commit be63522

Please sign in to comment.