forked from mirrored/github-readme-stats
refactor: run prettier
This commit is contained in:
+21
-21
@@ -1,39 +1,39 @@
|
||||
function expsf(x, lambda=1.) {
|
||||
function expsf(x, lambda = 1) {
|
||||
return 2 ** (-lambda * x);
|
||||
}
|
||||
|
||||
function calculateRank({
|
||||
totalRepos, // unused
|
||||
totalRepos, // unused
|
||||
totalCommits,
|
||||
contributions, // unused
|
||||
contributions, // unused
|
||||
followers,
|
||||
prs,
|
||||
issues,
|
||||
stargazers,
|
||||
}) {
|
||||
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 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 = (
|
||||
COMMITS_WEIGHT +
|
||||
FOLLOWERS_WEIGHT +
|
||||
PRS_ISSUES_WEIGHT +
|
||||
STARS_WEIGHT
|
||||
);
|
||||
const TOTAL_WEIGHT =
|
||||
COMMITS_WEIGHT + FOLLOWERS_WEIGHT + PRS_ISSUES_WEIGHT + STARS_WEIGHT;
|
||||
|
||||
const rank = (
|
||||
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 =
|
||||
(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.025;
|
||||
const RANK_S = 0.1;
|
||||
const RANK_A_PLUS = 0.25;
|
||||
const RANK_A = 0.50;
|
||||
const RANK_A = 0.5;
|
||||
const RANK_B_PLUS = 0.75;
|
||||
|
||||
const level = (() => {
|
||||
@@ -45,7 +45,7 @@ function calculateRank({
|
||||
return "B";
|
||||
})();
|
||||
|
||||
return {level, score: rank * 100};
|
||||
return { level, score: rank * 100 };
|
||||
}
|
||||
|
||||
module.exports = calculateRank;
|
||||
|
||||
@@ -13,7 +13,7 @@ describe("Test calculateRank", () => {
|
||||
issues: 0,
|
||||
stargazers: 0,
|
||||
}),
|
||||
).toStrictEqual({level: "B", score: 100.});
|
||||
).toStrictEqual({ level: "B", score: 100 });
|
||||
});
|
||||
|
||||
it("average user gets A rank", () => {
|
||||
@@ -27,7 +27,7 @@ describe("Test calculateRank", () => {
|
||||
issues: 13,
|
||||
stargazers: 100,
|
||||
}),
|
||||
).toStrictEqual({level: "A", score: 50.});
|
||||
).toStrictEqual({ level: "A", score: 50 });
|
||||
});
|
||||
|
||||
it("Linus Torvalds gets S+ rank", () => {
|
||||
@@ -41,6 +41,6 @@ describe("Test calculateRank", () => {
|
||||
issues: 2,
|
||||
stargazers: 109100,
|
||||
}),
|
||||
).toStrictEqual({level: "S+", score: 1.8875322153011722});
|
||||
).toStrictEqual({ level: "S+", score: 1.8875322153011722 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user