Skip to content

Commit

Permalink
Merge branch 'main' into cashe
Browse files Browse the repository at this point in the history
  • Loading branch information
kou7306 authored Feb 2, 2024
2 parents b8f67fc + 54d4387 commit abe8a1c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
11 changes: 5 additions & 6 deletions src/graphs/commit_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"image/color"

"gonum.org/v1/plot"
"gonum.org/v1/plot/font"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
// "github.com/fogleman/gg"
Expand Down Expand Up @@ -43,11 +42,11 @@ func DrawCommitChart(commitsHistory []int, maxCommits int, width int, height int
}
line.Color = color.RGBA{R: 135, G: 206, B: 235, A: 255}
p.Add(line)
plot.DefaultFont = font.Font{
Typeface: "Roboto-Medium.ttf",
Variant: "Roboto-Medium.ttf",
Size: 12.0,
}
// plot.DefaultFont = font.Font{
// Typeface: "Roboto-Medium.ttf",
// Variant: "Roboto-Medium.ttf",
// Size: 12.0,
// }
p.Title.Text = "Contribution History"
p.X.Label.Text = "Days"
p.Y.Label.Text = "Commits"
Expand Down
49 changes: 25 additions & 24 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http"
"strconv"
"os"

)

// func handler(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -72,30 +71,30 @@ import (

// }

// func getHistoryHandler(w http.ResponseWriter, r *http.Request) {
func getHistoryHandler(w http.ResponseWriter, r *http.Request) {

// // queryValues := r.URL.Query()
// // username := queryValues.Get("username")
queryValues := r.URL.Query()
username := queryValues.Get("username")

// // if username == "" {
// // http.Error(w, "username is required", http.StatusBadRequest)
// // return
// // }
if username == "" {
http.Error(w, "username is required", http.StatusBadRequest)
return
}

// username := "kou7306"
// username := "kou7306"

// _, dailyCommits, maxCommits, err := funcs.GetCommitHistory(username)
// if err != nil {
// http.Error(w, err.Error(), http.StatusInternalServerError)
// return
// }
_, dailyCommits, maxCommits, err := funcs.GetCommitHistory(username)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

// err = graphs.DrawCommitChart(dailyCommits, maxCommits, 1000, 700)
// if err != nil {
// fmt.Println(err)
// }
// http.ServeFile(w, r, "./images/commits_history.png")
// }
err = graphs.DrawCommitChart(dailyCommits, maxCommits, 1000, 700)
if err != nil {
fmt.Println(err)
}
http.ServeFile(w, r, "./images/commits_history.png")
}

// func getuserHandler(w http.ResponseWriter, r *http.Request) {

Expand All @@ -116,8 +115,10 @@ import (
// }

// 画像生成エンドポイント

func createhandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "public, max-age=3600")

queryValues := r.URL.Query()
username := queryValues.Get("username")
if r.Method == http.MethodGet {
Expand Down Expand Up @@ -180,13 +181,13 @@ func main() {
// http.HandleFunc("/streak", getCommitStreakHandler)
// http.HandleFunc("/language", getLanguageHandler)
// http.HandleFunc("/character", getCharacterHandler)
// http.HandleFunc("/history", getHistoryHandler)
http.HandleFunc("/history", getHistoryHandler)
// http.HandleFunc("/user", getuserHandler)
// http.HandleFunc("/merge", mergeAllContents)
// http.HandleFunc("/background", getBackgroundHandler)
http.HandleFunc("/create", createhandler)
http.HandleFunc("/create", createHandler)
fmt.Println("Hello, World!")
err := http.ListenAndServe(":8000", nil)
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatalf("HTTP server failed: %v", err)
}
Expand All @@ -211,7 +212,7 @@ func main() {
// fmt.Println("totalIssueContributions: ", totalIssueContributions)
// fmt.Println("totalPullRequestContributions: ", totalPullRequestContributions)
// fmt.Println("totalRepositoryContributions: ", totalRepositoryContributions)

fmt.Println(funcs.JudgeProfession("C+", []string{"Go"}, []float64{100}))
}
// } else if r.Method == http.MethodPost {
// // POSTリクエストの処理
Expand Down

0 comments on commit abe8a1c

Please sign in to comment.