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

Increase weight of funded PRs #27

Merged
merged 3 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion analyse-contributions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"devDependencies": {
"@octokit/types": "^6.34.0",
"@types/node": "^16.11.9",
"@types/node": "^18.8.0",
"ts-node": "^10.4.0",
"tslib": "^2.3.1",
"typescript": "^4.5.2"
Expand Down
13 changes: 12 additions & 1 deletion analyse-contributions/src/contribution-calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export type UserContributions = {
};
};

const FUNDED_LABEL = "funded";
const FUNDED_MULTIPLIER = 10;

export async function calculateScore({
members,
pullRequests,
Expand All @@ -54,9 +57,17 @@ export async function calculateScore({
prComments: memberPrComments,
issues: memberIssues,
};
const fundedPullRequests = contributions.pullRequests.filter((pr) =>
pr.labels.some((label) => label.name === FUNDED_LABEL)
);
const normalPullRequests = contributions.pullRequests.filter(
(pr) => !fundedPullRequests.includes(pr)
);

const score = {
pullRequests: contributions.pullRequests.length * 2,
pullRequests:
normalPullRequests.length * 2 +
fundedPullRequests.length * FUNDED_MULTIPLIER,
issueComments: contributions.issueComments.length,
prComments: contributions.prComments.length,
issues: contributions.issues.length,
Expand Down
10 changes: 10 additions & 0 deletions analyse-contributions/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ export type PullRequest = Links &
head: {
repo: Repository;
};
labels: Label[];
};

export type Label = {
id: number;
url: string;
name: string;
color: string;
default: boolean;
description: string;
};

export type Issue = Timestamps & {
id: number;
user: User;
Expand Down
7 changes: 6 additions & 1 deletion analyse-contributions/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,16 @@
resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.1.tgz#c48c2e27b65d2a153b19bfc1a317e30872e01eef"
integrity sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==

"@types/node@*", "@types/node@^16.11.9":
"@types/node@*":
version "16.11.9"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.9.tgz#879be3ad7af29f4c1a5c433421bf99fab7047185"
integrity sha512-MKmdASMf3LtPzwLyRrFjtFFZ48cMf8jmX5VRYrDQiJa8Ybu5VAmkqBWqKU8fdCwD8ysw4mQ9nrEHvzg6gunR7A==

"@types/node@^18.8.0":
version "18.8.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.8.0.tgz#b8ee8d83a99470c0661bd899417fcd77060682fe"
integrity sha512-u+h43R6U8xXDt2vzUaVP3VwjjLyOJk6uEciZS8OSyziUQGOwmk+l+4drxcsDboHXwyTaqS1INebghmWMRxq3LA==

acorn-walk@^8.1.1:
version "8.2.0"
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1"
Expand Down