mirror of
https://github.com/System-End/github-readme-stats.git
synced 2026-04-20 00:35:23 +00:00
Fix NaN and undefined for empty profiles (#1965)
* totalCommits: don't return NaN * rank: B+ should cover everyone Empty profile used to show "undefined" as the rank. Now empty profile shows "A+"... is B+ possible?
This commit is contained in:
parent
579cb7d175
commit
a481021dab
2 changed files with 9 additions and 8 deletions
|
|
@ -65,10 +65,10 @@ function calculateRank({
|
|||
|
||||
const level = (() => {
|
||||
if (normalizedScore < RANK_S_VALUE) return "S+";
|
||||
if (normalizedScore >= RANK_S_VALUE && normalizedScore < RANK_DOUBLE_A_VALUE) return "S";
|
||||
if (normalizedScore >= RANK_DOUBLE_A_VALUE && normalizedScore < RANK_A2_VALUE) return "A++";
|
||||
if (normalizedScore >= RANK_A2_VALUE && normalizedScore < RANK_A3_VALUE) return "A+"
|
||||
if (normalizedScore >= RANK_A3_VALUE && normalizedScore < RANK_B_VALUE) return "B+"
|
||||
if (normalizedScore < RANK_DOUBLE_A_VALUE) return "S";
|
||||
if (normalizedScore < RANK_A2_VALUE) return "A++";
|
||||
if (normalizedScore < RANK_A3_VALUE) return "A+"
|
||||
return "B+";
|
||||
})()
|
||||
|
||||
return { level, score: normalizedScore };
|
||||
|
|
|
|||
|
|
@ -86,15 +86,16 @@ const totalCommitsFetcher = async (username) => {
|
|||
|
||||
try {
|
||||
let res = await retryer(fetchTotalCommits, { login: username });
|
||||
if (res.data.total_count) {
|
||||
let total_count = res.data.total_count;
|
||||
if (!!total_count && !isNaN(total_count)) {
|
||||
return res.data.total_count;
|
||||
}
|
||||
} catch (err) {
|
||||
logger.log(err);
|
||||
// just return 0 if there is something wrong so that
|
||||
// we don't break the whole app
|
||||
return 0;
|
||||
}
|
||||
// just return 0 if there is something wrong so that
|
||||
// we don't break the whole app
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue