Lower average stats and S+ threshold

This commit is contained in:
François Rozet
2021-07-18 15:57:47 +02:00
parent 7a652bf144
commit 9c01a95a23
2 changed files with 20 additions and 23 deletions
+12 -15
View File
@@ -1,24 +1,22 @@
function expsf(x, lambda=1.) {
return Math.exp(-lambda * x);
return 2 ** (-lambda * x);
}
function calculateRank({
totalRepos,
totalRepos, // unused
totalCommits,
contributions,
contributions, // unused
followers,
prs,
issues,
stargazers,
}) {
const REPOS_MEAN = 10, REPOS_WEIGHT = 0.125;
const COMMITS_MEAN = 1000, COMMITS_WEIGHT = 0.125;
const FOLLOWERS_MEAN = 50, FOLLOWERS_WEIGHT = 0.5;
const PRS_ISSUES_MEAN = 50, PRS_ISSUES_WEIGHT = 0.25;
const COMMITS_MEAN = 500, COMMITS_WEIGHT = 0.25;
const FOLLOWERS_MEAN = 50, FOLLOWERS_WEIGHT = 0.25;
const PRS_ISSUES_MEAN = 25, PRS_ISSUES_WEIGHT = 0.25;
const STARS_MEAN = 100, STARS_WEIGHT = 1.0;
const TOTAL_WEIGHT = (
REPOS_WEIGHT +
COMMITS_WEIGHT +
FOLLOWERS_WEIGHT +
PRS_ISSUES_WEIGHT +
@@ -26,14 +24,13 @@ function calculateRank({
);
const rank = (
REPOS_WEIGHT * expsf(totalRepos, 1 / REPOS_MEAN) +
COMMITS_WEIGHT * expsf(totalCommits, 1 / COMMITS_MEAN) +
FOLLOWERS_WEIGHT * expsf(followers, 1 / FOLLOWERS_MEAN) +
PRS_ISSUES_WEIGHT * expsf(prs + issues, 1 / PRS_ISSUES_MEAN) +
STARS_WEIGHT * expsf(stargazers, 1 / STARS_MEAN)
) / TOTAL_WEIGHT;
const RANK_S_PLUS = 0.01;
const RANK_S_PLUS = 0.025;
const RANK_S = 0.1;
const RANK_A_PLUS = 0.25;
const RANK_A = 0.50;
@@ -41,15 +38,15 @@ function calculateRank({
let level = "";
if (rank < RANK_S_PLUS)
if (rank <= RANK_S_PLUS)
level = "S+";
else if (rank < RANK_S)
else if (rank <= RANK_S)
level = "S";
else if (rank < RANK_A_PLUS)
else if (rank <= RANK_A_PLUS)
level = "A+";
else if (rank < RANK_A)
else if (rank <= RANK_A)
level = "A";
else if (rank < RANK_B_PLUS)
else if (rank <= RANK_B_PLUS)
level = "B+";
else
level = "B";
+8 -8
View File
@@ -20,20 +20,20 @@ describe("Test calculateRank", () => {
expect(
calculateRank({
totalRepos: 10,
totalCommits: 1000,
contributions: 1000,
totalCommits: 500,
contributions: 500,
followers: 50,
prs: 25,
issues: 25,
prs: 12,
issues: 13,
stargazers: 100,
}),
).toStrictEqual({"A", score: 36.787944117144235});
).toStrictEqual({"A", score: 50.});
});
it("Linus Torvalds gets S rank", () => {
it("Linus Torvalds gets S+ rank", () => {
expect(
calculateRank({
totalRepos: 4, // few repos
totalRepos: 4,
totalCommits: 20000,
contributions: 20000,
followers: 132000,
@@ -41,6 +41,6 @@ describe("Test calculateRank", () => {
issues: 2,
stargazers: 109100,
}),
).toStrictEqual({ level: "S", score: 7.092453734726941});
).toStrictEqual({level: "S+", score: 1.8875322153011722});
});
});