Skip to content

Commit

Permalink
Extract github search page depth to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Flexicon committed Sep 2, 2022
1 parent d6f6f9b commit ccbaacb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 1 addition & 3 deletions fetch_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
const (
// CommitMessageMax is the maximum amount of characters of a commit message that we want to save before truncating
CommitMessageMax = 180
// SearchPageDepth determines how deep to look into the search results
SearchPageDepth = 5
)

var (
Expand Down Expand Up @@ -99,7 +97,7 @@ func searchCommits(query string, page int) ([]SearchResultItem, error) {
}

// Recursively search for commits up to the set max page depth
if len(results.Items) < results.TotalCount && page < SearchPageDepth {
if len(results.Items) < results.TotalCount && page < viper.GetInt("github.search_page_depth") {
// Wait a bit before searching again - GitHub doesn't like rapid fire search requests now
time.Sleep(5 * time.Second)

Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func ViperInit() error {

// Defaults
viper.SetDefault("port", 80)
viper.SetDefault("github.search_page_depth", 5)

if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
Expand Down

0 comments on commit ccbaacb

Please sign in to comment.