Skip to content

Updated rank calculation logic in calculateRank.js and added detailed… #4201

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Empty file added docs/rank-calculation.md
Empty file.
10 changes: 4 additions & 6 deletions src/calculateRank.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,16 @@ function log_normal_cdf(x) {
* @param {number} params.prs The number of pull requests.
* @param {number} params.issues The number of issues.
* @param {number} params.reviews The number of reviews.
* @param {number} params.repos Total number of repos.
* @param {number} params.stars The number of stars.
* @param {number} params.followers The number of followers.
* @returns {{level: string, percentile: number}}} The users rank.
* @returns {{level: string, percentile: number}} The users rank.
*/
function calculateRank({
all_commits,
commits,
prs,
issues,
reviews,
// eslint-disable-next-line no-unused-vars
repos, // unused
stars,
followers,
}) {
Expand Down Expand Up @@ -78,10 +75,11 @@ function calculateRank({
FOLLOWERS_WEIGHT * log_normal_cdf(followers / FOLLOWERS_MEDIAN)) /
TOTAL_WEIGHT;

const level = LEVELS[THRESHOLDS.findIndex((t) => rank * 100 <= t)];
const levelIndex = THRESHOLDS.findIndex((t) => rank * 100 <= t);
const level = levelIndex !== -1 ? LEVELS[levelIndex] : LEVELS[LEVELS.length - 1];

return { level, percentile: rank * 100 };
}

export { calculateRank };
export default calculateRank;
export default calculateRank;