Documentation
¶
Overview ¶
Package explore turns what the user types in Explore into one GitHub search for open pull requests to help on.
Index ¶
Constants ¶
const DefaultSort = "updated-asc"
DefaultSort puts the pull request that has waited longest first, so whoever asked earlier is not pushed further back.
const MaxFallbackRepos = 50
MaxFallbackRepos bounds the repositories an author's search is retried in.
const MaxOwners = 10
MaxOwners bounds the owners free text is scoped to.
const MaxResults = 30
MaxResults is one page: 100 breaks GitHub's per-query resource limit with the candidate fragment, 50 doubles the cost for results nobody scans.
const MetaRecent = "explore_recent"
MetaRecent is the store's key of the recent searches.
Variables ¶
This section is empty.
Functions ¶
func AuthorInRepos ¶
AuthorInRepos is login's search again, split by repository: GitHub search hides some accounts' pull requests unless repo: scopes it.
Types ¶
type Explorer ¶
type Explorer struct {
GitHub GitHub
Store Store
Budget Budget
// Loop names the loop, as the searches of the repositories it knows
// say.
Loop string
// Attempt bounds one search and Pause separates its two tries; zero
// is the default.
Attempt, Pause time.Duration
// contains filtered or unexported fields
}
Explorer runs Explore's searches, one at a time, only when the user asks, never below the budget the sweeps keep.
type GitHub ¶
GitHub is what Explore reads of GitHub: its searches and whether a word is a user's login.
type Lookup ¶
type Lookup struct {
Repos []string // owner/name of the repositories the inventory holds
Owners []string // their owners, the most relevant first
// IsUser answers whether a word is a GitHub user's login; nil, or an
// error, reads the word as text.
IsUser func(ctx context.Context, login string) (bool, error)
}
Lookup is what the inventory and GitHub tell Explore about a bare word.
type Request ¶
type Request struct {
Ref *github.Ref
Query string
Read string // how the input was read, after "as"
Author string // the login when the search lists one author's pull requests
Team string // org/slug when the search lists what one team is asked to review
Sort string // the value of the search's sort: qualifier
// Keep are the updated: qualifiers, which every search of the request
// carries, the fallback's too.
Keep []string
}
Request is one pull request when Ref is set, else a search.
type Result ¶
type Result struct {
Query string `json:"query"`
Read string `json:"read"`
Total int `json:"total"`
Empty string `json:"empty,omitempty"`
RateLimit github.RateLimit `json:"rate_limit"`
Recent []string `json:"recent"`
Candidates []github.Candidate `json:"candidates"`
}
Result is one search: what it read the query as, the pull requests it found and the budget it spent.
type Retry ¶
Retry bounds each attempt of a search and pauses before its second try.
func (Retry) AuthorInRepos ¶
func (r Retry) AuthorInRepos(ctx context.Context, s Searcher, queries []string, sort, viewer string) (merged github.CandidatePage, failed []error, err error)
AuthorInRepos runs the searches SearchesPerRequest to a request and merges them in the order sort asks for; failed holds the searches that failed alone, and only all of them failing fails the merge.
type Searcher ¶
type Searcher interface {
SearchCandidates(ctx context.Context, q, viewer string, first int) (github.CandidatePage, error)
SearchCandidatesEach(ctx context.Context, qs []string, viewer string, first int) ([]github.CandidatePage, []error, error)
CandidateByRef(ctx context.Context, ref github.Ref, viewer string) (github.CandidatePage, error)
}
Searcher is the GitHub search Explore runs.
type Store ¶
type Store interface {
Refs(ctx context.Context) ([]github.Ref, error)
Viewer(ctx context.Context) (string, error)
Meta(ctx context.Context, key string) (string, error)
SetMeta(ctx context.Context, key, value string) error
}
Store is what Explore reads and keeps beside GitHub: the pull requests the plugin holds, the viewer, and the recent searches.