Skip to content

Commit

Permalink
Update errors
Browse files Browse the repository at this point in the history
  • Loading branch information
irevenko committed Apr 13, 2021
1 parent 905c9d9 commit c44db25
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion github/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func SearchUser(ctx context.Context, restClient *github.Client, username string)

users, _, err := restClient.Search.Users(ctx, username, opts)
if err != nil {
log.Fatal(err)
log.Fatalf("Error while searching for: %v: %v", username, err)
}

return users
Expand Down
6 changes: 5 additions & 1 deletion github/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package github

import (
"context"
"log"
"time"

"github.com/google/go-github/v33/github"
Expand All @@ -15,7 +16,10 @@ func FetchUserStats(ctx context.Context, restClient *github.Client, qlClient *gi
totalForks := r.TotalForks(restClient, allRepos)

year, _, _ := time.Now().Date()
contribs := g.AllContributions(qlClient, username, year-1, year)
contribs, err := g.AllContributions(qlClient, username, year-1, year)
if err != nil {
log.Fatalf("Couldn't get all contribs for: %v: %v", username, err)
}

var totalCommits int
var totalIssues int
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/gizak/termui/v3 v3.1.0
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-github/v33 v33.0.0
github.com/irevenko/octostats v0.0.0-20210322102759-1b4637d700ca
github.com/irevenko/octostats v0.0.0-20210413090023-47f2285d6299
github.com/mattn/go-runewidth v0.0.10 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/nsf/termbox-go v1.1.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/irevenko/octostats v0.0.0-20210322102759-1b4637d700ca h1:ekdEDLVLRCEtaGikLHSXP75bk8PfGlAdF6oOlAcknL4=
github.com/irevenko/octostats v0.0.0-20210322102759-1b4637d700ca/go.mod h1:FHV+ChJ76Xesp7qr4dyUkbxoNTTF/Rd31RFiP8q4rBA=
github.com/irevenko/octostats v0.0.0-20210413090023-47f2285d6299 h1:1ESPPFTAkhSwQSEtbHxzz3GDXQHGhX5EzK8ur4lx5EA=
github.com/irevenko/octostats v0.0.0-20210413090023-47f2285d6299/go.mod h1:FHV+ChJ76Xesp7qr4dyUkbxoNTTF/Rd31RFiP8q4rBA=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
Expand Down
20 changes: 16 additions & 4 deletions tui/render_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ func RenderStats(username string, accType string, s *spinner.Spinner) {
}

func renderUser(username string, s *spinner.Spinner) {
user := g.UserDetails(qlClient, username)
allRepos := r.AllRepos(Ctx, RestClient, username)
user, err := g.UserDetails(qlClient, username)
if err != nil {
log.Fatalf("Couldn't get user details for: %v: %v", username, err)
}
allRepos, err := r.AllRepos(Ctx, RestClient, username)
if err != nil {
log.Fatalf("Couldn't get all repos for: %v: %v", username, err)
}

img, images := SetupImage(user.AvatarURL, user.Login)
p := SetupProfileInfo(user)
Expand Down Expand Up @@ -75,8 +81,14 @@ func renderUser(username string, s *spinner.Spinner) {
}

func renderOrganization(username string, s *spinner.Spinner) {
org := g.OrganizationDetails(qlClient, username)
allRepos := r.AllRepos(Ctx, RestClient, username)
org, err := g.OrganizationDetails(qlClient, username)
if err != nil {
log.Fatalf("Couldn't get org details for: %v: %v", username, err)
}
allRepos, err := r.AllRepos(Ctx, RestClient, username)
if err != nil {
log.Fatalf("Couldn't get all repos for: %v: %v", username, err)
}

img, images := SetupImage(org.AvatarURL, org.Login)
p := SetupOrgInfo(org)
Expand Down
10 changes: 8 additions & 2 deletions tui/widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ func SetupImage(profileImg string, login string) (*widgets.Image, []image.Image)

func SetupLangsByCommits(user g.User) *widgets.PieChart {
year, _, _ := time.Now().Date()
langs, commits := g.LanguagesByCommit(qlClient, user.Login, year-1, year)
langs, commits, err := g.LanguagesByCommit(qlClient, user.Login, year-1, year)
if err != nil {
log.Fatalf("Couldn't get langs by commit for: %v: %v", user.Login, err)
}

pc := widgets.NewPieChart()
pc.Title = "Languages by commit"
Expand Down Expand Up @@ -251,7 +254,10 @@ func SetupForksPerLangs(allRepos []*github.Repository, accType string) *widgets.
}

func SetupContribsSparkline(user g.User) *widgets.SparklineGroup {
_, contribs := g.YearActivity(qlClient, user.Login)
_, contribs, err := g.YearActivity(qlClient, user.Login)
if err != nil {
log.Fatalf("Couldn't get year activity for: %v: %v", user.Login, err)
}
timeSpan := 75

sl := widgets.NewSparkline()
Expand Down

0 comments on commit c44db25

Please sign in to comment.