diff --git a/docs/configuration.md b/docs/configuration.md index e8d139c..c9dd473 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -907,7 +907,7 @@ https://www.youtube.com...&list={ID}&... The maximum number of videos to show. ##### `sort-by` -Used to specify the order in which the videos should get returned. Possible values are `none`, `updated`, and `posted`. +Used to specify the order in which the videos should get returned. Possible values are `none`, `updated`, and `posted`. Default value is `posted`. ##### `collapse-after` @@ -2504,7 +2504,7 @@ Example: pull-requests-limit: 5 issues-limit: 3 commits-limit: 3 - exclude-draft-prs: true + exclude-draft-pull-requests: true ``` Preview: @@ -2520,7 +2520,7 @@ Preview: | pull-requests-limit | integer | no | 3 | | issues-limit | integer | no | 3 | | commits-limit | integer | no | -1 | -| exclude-draft-prs | boolean | no | false | +| exclude-draft-pull-requests | boolean | no | false | ##### `repository` The owner and repository name that will have their information displayed. @@ -2537,7 +2537,7 @@ The maximum number of latest open issues to show. Set to `-1` to not show any. ##### `commits-limit` The maximum number of lastest commits to show from the default branch. Set to `-1` to not show any. -##### `exclude-draft-prs` +##### `exclude-draft-pull-requests` Wheter to exclude draft pull requests from the list. Set to `false` by default to include them. ### Bookmarks diff --git a/internal/glance/widget-repository.go b/internal/glance/widget-repository.go index fe9b324..4f4cc9e 100644 --- a/internal/glance/widget-repository.go +++ b/internal/glance/widget-repository.go @@ -19,7 +19,7 @@ type repositoryWidget struct { PullRequestsLimit int `yaml:"pull-requests-limit"` IssuesLimit int `yaml:"issues-limit"` CommitsLimit int `yaml:"commits-limit"` - ExcludeDraftPRs bool `yaml:"exclude-draft-prs"` + ExcludeDraftPRs bool `yaml:"exclude-draft-pull-requests"` Repository repository `yaml:"-"` } @@ -113,23 +113,18 @@ type gitHubCommitResponseJson struct { } `json:"commit"` } -func buildPRQuery(repo string, excludeDraftPRs bool) string { - query := fmt.Sprintf("is:pr+is:open+repo:%s", repo) - if excludeDraftPRs { - query += "+-is:draft" - } - return query -} - func fetchRepositoryDetailsFromGithub(repo string, token string, maxPRs int, maxIssues int, maxCommits int, excludeDraftPRs bool) (repository, error) { repositoryRequest, err := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/repos/%s", repo), nil) if err != nil { return repository{}, fmt.Errorf("%w: could not create request with repository: %v", errNoContent, err) } - prQuery := buildPRQuery(repo, excludeDraftPRs) + RRsQuery := fmt.Sprintf("is:pr+is:open+repo:%s", repo) + if excludeDraftPRs { + RRsQuery += "+-is:draft" + } - PRsRequest, _ := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/search/issues?q=%s&per_page=%d", prQuery, maxPRs), nil) + PRsRequest, _ := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/search/issues?q=%s&per_page=%d", RRsQuery, maxPRs), nil) issuesRequest, _ := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/search/issues?q=is:issue+is:open+repo:%s&per_page=%d", repo, maxIssues), nil) CommitsRequest, _ := http.NewRequest("GET", fmt.Sprintf("https://api.github.com/repos/%s/commits?per_page=%d", repo, maxCommits), nil)