Skip to content

Commit

Permalink
Avoid fetching commits if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuelef committed Nov 21, 2023
1 parent eae6e80 commit a1d22ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,7 @@ func main() {
// pipenv Pipfile
result, _ = clientGQL.GetAllStats(ctx, "zappa/Zappa")
fmt.Println(result)

result, _ = clientGQL.GetAllStats(ctx, "omeid/uconfig")
fmt.Println(result)
}
13 changes: 9 additions & 4 deletions repostats/gqlstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,15 @@ func (c *ClientGQL) GetAllStats(ctx context.Context, ghRepo string) (*stats.Repo
}

// 30d commits history
result.CommitsHistory, err = c.getCommitsShortHistory(ctx, repoSplit[0], repoSplit[1], result.Commits)
if err != nil {
log.Printf("%v\n", err)
return &result, err
currentTime := time.Now()
days := currentTime.Sub(result.LastCommitDate).Hours() / 24

if days < 30 {
result.CommitsHistory, err = c.getCommitsShortHistory(ctx, repoSplit[0], repoSplit[1], result.Commits)
if err != nil {
log.Printf("%v\n", err)
return &result, err
}
}

if depFetcher := deps.CreateFetcher(result.Language); depFetcher != nil {
Expand Down

0 comments on commit a1d22ae

Please sign in to comment.