Skip to content
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
18 changes: 0 additions & 18 deletions OnedayCommits.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@ import (
"time"
)

type Actor struct {
ID int
Login string
GravatarID string
URL string
AvatarURL string
}

type Repo struct {
ID int
Name string
URL string `json:"url"`
}

type Payload struct {
PushID int
Size int
Expand All @@ -42,12 +28,8 @@ type Commits struct {
}

type Data struct {
ID string `json:"id"`
Type string `json:"type"`
Actor Actor `json:"actor"`
Repo Repo `json:"repo"`
PayLoad Payload `json:"payload"`
Public string `json:"public"`
CreatedAt string `json:"created_at"`
}

Expand Down
71 changes: 71 additions & 0 deletions ReviewComment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package main
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ʕ ◔ϖ◔ʔ < コメントテスト3


import (
"bufio"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ʕ ◔ϖ◔ʔ < コメントテスト1

"encoding/json"
"fmt"
"net/http"
"os"
"strings"
"time"
)

type Payload struct {
Action string
Comment []Comment
Number int
}

type Comment struct {
body string
CreatedAT string
}

type Data struct {
Type string `json:"type"`
PayLoad Payload `json:"payload"`
CreatedAt string `json:"created_at"`
}

func main() {
fmt.Println("ユーザー名を入力してください")
fmt.Print("YourName: ")
comments := PullRequestComments()
fmt.Println(comments)
}

func PullRequestComments() (pullreqtotal int) {
ownerName := getUserName() + "/events"
url := "https://api.github.com/users/" + ownerName
req, _ := http.NewRequest("GET", url, nil)
client := new(http.Client)
resp, _ := client.Do(req)
defer resp.Body.Close()
dec := json.NewDecoder(resp.Body)
var d []Data
dec.Decode(&d)
var count = 0
for _, json := range d {
// 日付文字列パース
var ts = strings.Replace(json.CreatedAt, "T", " ", 1)
ts = strings.Replace(ts, "Z", " UTC", 1)
// JST置換
t, _ := time.Parse("2006-01-02 15:04:05 MST", ts)
jst := time.FixedZone("Asia/Tokyo", 9*60*60)
tJst := t.In(jst)
// 日付比較
nowJst := time.Now()
if tJst.Format("2006-01-02") == nowJst.Format("2006-01-02") &&
json.Type == "PushEvent" {
count += len(json.PayLoad.Comment)
}
}
return count
}

func getUserName() (stringReturned string) {
sc := bufio.NewScanner(os.Stdin)
sc.Scan()
stringReturned = sc.Text()
return
}
20 changes: 10 additions & 10 deletions versus.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ import (
"time"
)

type Data struct {
ID string `json:"id"`
Type string `json:"type"`
Actor Actor `json:"actor"`
Repo Repo `json:"repo"`
PayLoad Payload `json:"payload"`
Public string `json:"public"`
CreatedAt string `json:"created_at"`
}

type Actor struct {
ID int
Login string
Expand Down Expand Up @@ -41,15 +51,6 @@ type Commits struct {
URL string
}

type Data struct {
ID string `json:"id"`
Type string `json:"type"`
Actor Actor `json:"actor"`
Repo Repo `json:"repo"`
PayLoad Payload `json:"payload"`
Public string `json:"public"`
CreatedAt string `json:"created_at"`
}

func main() {
fmt.Println("ユーザー名を入力してください")
Expand All @@ -69,7 +70,6 @@ func main() {
fmt.Println("DROW")
fmt.Printf("MyCommits: %d\nPlayer Commits: %d", player1, player2)
}

}

// commitCount is counts the number of commits .
Expand Down