Skip to content

Commit

Permalink
chore: logs
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Oct 27, 2021
1 parent a565b0d commit f174876
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cmd/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"log"
"time"

"github.com/caarlos0/org-stats/csv"
Expand Down Expand Up @@ -82,6 +83,7 @@ func (m InitialModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.err = msg.error
return m, nil
case gotResults:
log.Println("got results", len(msg.stats.Logins()), "logins")
highlights := NewHighlightsModel(msg.stats, m.top, m.includeReviewStats)
return highlights, tea.Batch(
writeCsv(m.csv, msg.stats, m.includeReviewStats),
Expand Down
13 changes: 10 additions & 3 deletions orgstats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func Gather(
return Stats{}, err
}

log.Println("total authors stats:", len(allStats.data))

if !includeReviewStats {
return allStats, nil
}
Expand Down Expand Up @@ -141,6 +143,7 @@ func gatherLineStats(

for _, repo := range allRepos {
if isBlacklisted(repoBlacklist, repo.GetName()) {
log.Println("ignoring blacklisted repo:", repo.GetName())
continue
}
stats, serr := getStats(ctx, client, org, *repo.Name)
Expand All @@ -149,8 +152,10 @@ func gatherLineStats(
}
for _, cs := range stats {
if isBlacklisted(userBlacklist, cs.Author.GetLogin()) {
log.Println("ignoring blacklisted author:", cs.Author.GetLogin())
continue
}
log.Println("recording stats for author", cs.Author.GetLogin(), "on repo", repo.GetName())
allStats.add(cs)
}
}
Expand All @@ -173,10 +178,10 @@ func (s *Stats) addReviewStats(user string, reviewed int) {
}

func (s *Stats) add(cs *github.ContributorStats) {
if cs.Author == nil {
if cs.GetAuthor() == nil {
return
}
stat := s.data[*cs.Author.Login]
stat := s.data[cs.GetAuthor().GetLogin()]
var adds int
var rms int
var commits int
Expand All @@ -195,7 +200,7 @@ func (s *Stats) add(cs *github.ContributorStats) {
// ignore users with no activity when running with a since time
return
}
s.data[*cs.Author.Login] = stat
s.data[cs.GetAuthor().GetLogin()] = stat
}

func repos(ctx context.Context, client *github.Client, org string) ([]*github.Repository, error) {
Expand All @@ -218,6 +223,8 @@ func repos(ctx context.Context, client *github.Client, org string) ([]*github.Re
}
opt.ListOptions.Page = resp.NextPage
}

log.Println("got", len(allRepos), "repositories")
return allRepos, nil
}

Expand Down

0 comments on commit f174876

Please sign in to comment.