-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from tomoish/error
Error
- Loading branch information
Showing
17 changed files
with
149 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,102 @@ | ||
package funcs | ||
|
||
// import ( | ||
// "fmt" | ||
import ( | ||
// 他の import ステートメント | ||
"math" | ||
"sort" | ||
) | ||
|
||
// ) | ||
func JudgeRank(languages []LanguageStat, stats UserStats) (string, int) { | ||
// データを取得 | ||
|
||
// func JudgeRank()[ | ||
// // データを取得 | ||
// totalCommitContributions, totalStarredRepositories, totalIssueContributions, totalPullRequestContributions, totalRepositoryContributions, err := fetchDataInTimeRange(token, username) | ||
// rank := "C-" | ||
total := stats.TotalStars + stats.ContributedTo + stats.TotalIssues + stats.TotalPRs + stats.TotalCommits | ||
|
||
// switch { | ||
// case rank < 25: | ||
// rank="C-" | ||
// case rank < 100: | ||
// rank="C" | ||
// case rank < 400: | ||
// rank="C+" | ||
// case rank < 625: | ||
// rank="B-" | ||
// case rank < 1225: | ||
// rank="B" | ||
// case rank < 2500: | ||
// rank="B+" | ||
// case rank < 4900: | ||
// rank="A-" | ||
// case rank < 8100: | ||
// rank="A" | ||
// case rank < 10000: | ||
// rank="A+" | ||
// case 10000 <= rank: | ||
// rank="S" | ||
// default: | ||
// rank="C-" | ||
level := int(math.Sqrt(float64(total))) | ||
|
||
// } | ||
rank := "" | ||
|
||
// // 言語ごとの割合を持ってくる | ||
// languages, err := funcs.CreateLanguageImg(username, token) | ||
switch { | ||
case total < 25: | ||
rank = "C-" | ||
case total < 100: | ||
rank = "C" | ||
case total < 400: | ||
rank = "C+" | ||
case total < 625: | ||
rank = "B-" | ||
case total < 1225: | ||
rank = "B" | ||
case total < 2500: | ||
rank = "B+" | ||
case total < 4900: | ||
rank = "A-" | ||
case total < 8100: | ||
rank = "A" | ||
case total < 10000: | ||
rank = "A+" | ||
case 10000 <= total: | ||
rank = "S" | ||
default: | ||
rank = "C-" | ||
|
||
// // Percent の大きい順にソート | ||
// sort.Slice(languages, func(i, j int) bool { | ||
// return languages[i].Percent > languages[j].Percent | ||
// }) | ||
} | ||
|
||
// //上位2つの言語を保持 | ||
// topLanguage := []funcs.LanguageStat{} | ||
// // 一時的に保持する | ||
// temp := []funcs.LanguageStat{} | ||
// Percent の大きい順にソート | ||
sort.Slice(languages, func(i, j int) bool { | ||
return languages[i].Percent > languages[j].Percent | ||
}) | ||
|
||
// // ソートされた languages を使用する | ||
// // 一位がHTML,CSS,JavaScript,TypeScriptじゃない場合 | ||
// if languages[0].Name != "HTML" && languages[0].Name != "CSS" && languages[0].Name != "JavaScript" && languages[0].Name != "TypeScript"{ | ||
// topLanguage = append(topLanguage, languages[0]) | ||
//上位2つの言語を保持 | ||
topLanguage := []string{} | ||
// パーセントを保持 | ||
percentages := []float64{} | ||
// 一時的に保持する | ||
temp := []LanguageStat{} | ||
|
||
// } else { | ||
// temp = append(temp, languages[0]) | ||
// } | ||
// ソートされた languages を使用する | ||
// 一位がHTML,CSS,JavaScript,TypeScriptじゃない場合 | ||
if languages[0].Name != "HTML" && languages[0].Name != "CSS" && languages[0].Name != "JavaScript" && languages[0].Name != "TypeScript" { | ||
topLanguage = append(topLanguage, languages[0].Name) | ||
percentages = append(percentages, languages[0].Percent) | ||
|
||
// if topLanguage != [] { | ||
// topLanguage = append(topLanguage, languages[1]) | ||
// } | ||
// else{ | ||
// if languages[1].Name != "HTML" && languages[1].Name != "CSS" && languages[1].Name != "JavaScript" && languages[1].Name != "TypeScript"{ | ||
// topLanguage = append(topLanguage, languages[1]) | ||
// topLanguage = append(topLanguage, temp[0]) | ||
// } | ||
} else { | ||
temp = append(temp, languages[0]) | ||
} | ||
|
||
// // 上位2つの言語がHTML,CSS,JavaScript,TypeScriptの場合 | ||
// else{ | ||
// temp = append(temp, languages[1]) | ||
// // HTML,CSS,JavaScript,TypeScriptじゃない中の一位の言語を探す | ||
// for i, language := range languages[2:] { | ||
// if language.Name != "HTML" && language.Name != "CSS" && language.Name != "JavaScript" && language.Name != "TypeScript"{ | ||
// if language.Percent >= 15.0{ | ||
// topLanguage = append(topLanguage, language) | ||
// topLanguage = append(topLanguage, temp[0]) | ||
// } | ||
// else{ | ||
// topLanguage = append(topLanguage, temp[0]) | ||
// topLanguage = append(topLanguage, temp[1]) | ||
// } | ||
if len(topLanguage) != 0 { | ||
topLanguage = append(topLanguage, languages[1].Name) | ||
percentages = append(percentages, languages[1].Percent) | ||
} else { | ||
|
||
// } | ||
// } | ||
// } | ||
// } | ||
if languages[1].Name != "HTML" && languages[1].Name != "CSS" && languages[1].Name != "JavaScript" && languages[1].Name != "TypeScript" { | ||
topLanguage = append(topLanguage, languages[1].Name) | ||
percentages = append(percentages, languages[1].Percent) | ||
topLanguage = append(topLanguage, temp[0].Name) | ||
percentages = append(percentages, temp[0].Percent) | ||
topLanguage = append(topLanguage, temp[0].Name) | ||
percentages = append(percentages, temp[0].Percent) | ||
} else { | ||
// 上位2つの言語がHTML,CSS,JavaScript,TypeScriptの場合 | ||
|
||
// return rank | ||
// ] | ||
temp = append(temp, languages[1]) | ||
// HTML,CSS,JavaScript,TypeScriptじゃない中の一位の言語を探す | ||
for _, language := range languages[2:] { | ||
if language.Name != "HTML" && language.Name != "CSS" && language.Name != "JavaScript" && language.Name != "TypeScript" { | ||
if language.Percent >= 15.0 { | ||
topLanguage = append(topLanguage, language.Name) | ||
percentages = append(percentages, language.Percent) | ||
topLanguage = append(topLanguage, temp[0].Name) | ||
percentages = append(percentages, temp[0].Percent) | ||
} else { | ||
topLanguage = append(topLanguage, temp[0].Name) | ||
topLanguage = append(topLanguage, temp[1].Name) | ||
percentages = append(percentages, temp[0].Percent) | ||
percentages = append(percentages, temp[1].Percent) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return JudgeProfession(rank, topLanguage, percentages), level | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.