Skip to content
This repository was archived by the owner on Aug 16, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ CSV_COLUMN_NUMBER_FOR_ALTERNATE_ID = ""
IGNORE_SELFOWNED_EVENTS = ""
MINIMUM_NUMBER_OF_CONTRIBUTIONS = 1
GITHUB_IMPORTANT_EVENTS = "CommitCommentEvent,IssueCommentEvent,IssuesEvent,PullRequestEvent,PullRequestReviewEvent,PullRequestReviewCommentEvent"
IGNORE_REPOSITORIES = ""
GITHUB_ORGANIZATIONS = ""
Comment thread
jacksjm marked this conversation as resolved.
Outdated
Comment thread
jacksjm marked this conversation as resolved.
Outdated
// You can edit this list of important event types if these are not the event types you care about.
// Make sure the list is comma-separated with no spaces
// Event types can be found here https://developer.github.com/v3/activity/events/types/
2 changes: 2 additions & 0 deletions .jest/setEnvVars.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ process.env.IGNORE_SELFOWNED_EVENTS = 'false';
process.env.MINIMUM_NUMBER_OF_CONTRIBUTIONS = 2;
process.env.GITHUB_IMPORTANT_EVENTS =
'CommitCommentEvent,IssueCommentEvent,IssuesEvent,PullRequestEvent,PullRequestReviewEvent,PullRequestReviewCommentEvent';
process.env.GITHUB_ORGANIZATIONS = 'indeedeng';
process.env.IGNORE_REPOSITORIES = '';
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ Log in to GitHub and [register a new personal access token](https://github.com/s
- We do not look for PushEvents because those are usually used for personal projects, not actual open source contributions.
- Starfish allows you to filter events based on the specific action taken. For example, you might want to count when a pull request is opened, but not when it is closed. To do that, the list of important events can include basic types (like "PullRequestEvent") or a specific action of a type (like "PullRequestEvent.closed").
You can list multiple actions for the same event type. Visit [GitHub event types](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/github-event-types#event-object-common-properties) for more information.
- `IGNORE_REPOSITORIES` contains repository names to be ignored to check. Names must be separated by a comma.
- One repository to ignore: `IGNORE_REPOSITORIES="indeedeng/starfish"`
- Many repositories to ignore: `IGNORE_REPOSITORIES="indeedeng/starfish,indeedeng/proctor"`
- `GITHUB_ORGANIZATIONS` contains organization login to be filter the events. Logins must be separated by a comma.
- One organization to consider: `GITHUB_ORGANIZATIONS = "indeedeng"`
- Many organizations to consider: `GITHUB_ORGANIZATIONS = "indeedeng,github"`

### Time zones

Expand Down
8 changes: 8 additions & 0 deletions globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ const githubImportantEvents = getOrThrowIfMissingOrEmpty('GITHUB_IMPORTANT_EVENT
const timeZone = process.env.TIMEZONE;
const dateTimes = getDateTimesFromArgv(timeZone);
const csvFilename = process.argv[4];
const githubIgnoreRepositories = (process.env.IGNORE_REPOSITORIES || '')
Comment thread
jacksjm marked this conversation as resolved.
Outdated
.split(',')
.map((repo) => repo.trim());
const githubOrganizations = (process.env.GITHUB_ORGANIZATIONS || '')
Comment thread
jacksjm marked this conversation as resolved.
Outdated
.split(',')
.map((repo) => repo.trim());

const ignoreSelfOwnedEvents = (process.env.IGNORE_SELFOWNED_EVENTS || 'false').toLowerCase();
console.info(`Configuration set to ignore self-owned events? ${ignoreSelfOwnedEvents}`);
Expand All @@ -49,4 +55,6 @@ module.exports = {
githubToken,
ignoreSelfOwnedEvents,
minimumNumberOfContributions,
githubIgnoreRepositories,
githubOrganizations,
};
18 changes: 17 additions & 1 deletion starfish.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const {
githubToken,
ignoreSelfOwnedEvents,
minimumNumberOfContributions,
githubIgnoreRepositories,
githubOrganizations,
} = require('./globals');
const { createLuxonDateTimeFromIso } = require('./dateTimes');
const fetch = require('node-fetch');
Expand Down Expand Up @@ -123,14 +125,28 @@ function isContributionInTimeRange(createdAt, startMoment, endMoment) {
);
}

function filterResponseFor(organization) {
Comment thread
jacksjm marked this conversation as resolved.
Outdated
if (githubOrganizations.length && githubOrganizations[0] !== '') {
return githubOrganizations.indexOf(organization) >= 0;
Comment thread
jacksjm marked this conversation as resolved.
Outdated
}

return true;
}

function didTheyQualify(idObject, dateTimes) {
const startMoment = dateTimes[0];
const endMoment = dateTimes[1];
let numberOfQualifyingContributions = 0;

for (let i = 0; i < idObject.contributions.length; i++) {
const createdAtString = idObject.contributions[i].created_at;
if (isContributionInTimeRange(createdAtString, startMoment, endMoment)) {
const repository = idObject.contributions[i].repo.name;
const organization = idObject.contributions[i].org.login;
if (
Comment thread
jacksjm marked this conversation as resolved.
Outdated
isContributionInTimeRange(createdAtString, startMoment, endMoment) &&
filterResponseFor(organization) &&
githubIgnoreRepositories.indexOf(repository) === -1
) {
numberOfQualifyingContributions++;
}
if (numberOfQualifyingContributions >= minimumNumberOfContributions) {
Expand Down