Skip to content

Commit

Permalink
no need to store every commit, just the counts
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdevivo committed Apr 12, 2020
1 parent b57fb8f commit 0e24575
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var rootCmd = &cobra.Command{
type authorAggregate struct {
email string
name string
commits []*object.Commit
commits int
impact int
score float64
}
Expand All @@ -92,15 +92,14 @@ var rootCmd = &cobra.Command{
authorEmail := commit.Author.Email
if _, ok := authors[authorEmail]; !ok {
authors[authorEmail] = &authorAggregate{
email: authorEmail,
name: commit.Author.Name,
commits: make([]*object.Commit, 0),
email: authorEmail,
name: commit.Author.Name,
}
authorEmails = append(authorEmails, authorEmail)
}

agg := authors[authorEmail]
agg.commits = append(authors[authorEmail].commits, commit)
agg.commits++

fileStats, err := commit.Stats()
handleError(err)
Expand Down Expand Up @@ -133,7 +132,7 @@ var rootCmd = &cobra.Command{
if agg.score < 1 {
continue
}
fmt.Fprintf(w, "%d\t%s\t%s\t%d\t%d commits\t%d\n", rank+1, authorEmail, agg.name, int(math.Round(agg.score)), len(agg.commits), agg.impact)
fmt.Fprintf(w, "%d\t%s\t%s\t%d\t%d commits\t%d\n", rank+1, authorEmail, agg.name, int(math.Round(agg.score)), agg.commits, agg.impact)
}
w.Flush()
},
Expand Down

0 comments on commit 0e24575

Please sign in to comment.