mirror of
https://github.com/taigrr/wtf
synced 2026-04-14 18:10:46 -07:00
Add new key 'customQueries' to github module
This key allows users to pass an arbitrary amount of queries
that contain custom filters. A simple query that shows all closed
PRs could be written like the following.
```
customQueries:
closedPullRequests:
title: "Closed Requests"
perPage: 10
filter:
- "is:closed"
- "is:pr"
```
Resolves #469
This commit is contained in:
@@ -2,6 +2,7 @@ package github
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
ghb "github.com/google/go-github/v25/github"
|
||||
@@ -152,9 +153,23 @@ func (repo *GithubRepo) myReviewRequests(username string) []*ghb.PullRequest {
|
||||
return prs
|
||||
}
|
||||
|
||||
func (repo *GithubRepo) customIssueQuery(filter string, perPage int) *ghb.IssuesSearchResult {
|
||||
github, err := repo.githubClient()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
opts := &ghb.SearchOptions{}
|
||||
if perPage != 0 {
|
||||
opts.ListOptions.PerPage = perPage
|
||||
}
|
||||
|
||||
prs, _, _ := github.Search.Issues(context.Background(), fmt.Sprintf("%s repo:%s/%s", filter, repo.Owner, repo.Name), opts)
|
||||
return prs
|
||||
}
|
||||
|
||||
func (repo *GithubRepo) loadPullRequests() ([]*ghb.PullRequest, error) {
|
||||
github, err := repo.githubClient()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user