{"modulePath":"github.com/wloophq/wloop","version":"v0.7.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package explore\n\nPackage explore turns what the user types in Explore into one GitHub search for open pull requests to help on.\n\n## Constants\n\n```go\nconst DefaultSort = \"updated-asc\"\n```\nDefaultSort puts the pull request that has waited longest first, so whoever asked earlier is not pushed further back.\n\n```go\nconst MaxFallbackRepos = 50\n```\nMaxFallbackRepos bounds the repositories an author's search is retried in.\n\n```go\nconst MaxOwners = 10\n```\nMaxOwners bounds the owners free text is scoped to.\n\n```go\nconst MaxResults = 30\n```\nMaxResults is one page: 100 breaks GitHub's per-query resource limit with the candidate fragment, 50 doubles the cost for results nobody scans.\n\n```go\nconst MetaRecent = \"explore_recent\"\n```\nMetaRecent is the store's key of the recent searches.\n\n## Functions\n\n```go\nfunc AuthorInRepos(login string, repos []string, sort string, keep []string) []string\n```\nAuthorInRepos is login's search again, split by repository: GitHub search hides some accounts' pull requests unless repo: scopes it.\n\n```go\nfunc Order(sort string) func(a, b github.Candidate) int\n```\nOrder compares candidates as GitHub's sort does, nil for a sort it cannot tell from a candidate.\n\n## Types\n\n```go\ntype Budget func() (ok bool, l github.Limit)\n```\nBudget says whether the budget lets a search run; l is the bucket it read.\n\n```go\ntype Explorer struct {\n\tGitHub GitHub\n\tStore  Store\n\tBudget Budget\n\t// Loop names the loop, as the searches of the repositories it knows\n\t// say.\n\tLoop string\n\t// Attempt bounds one search and Pause separates its two tries; zero\n\t// is the default.\n\tAttempt, Pause time.Duration\n\t// contains filtered or unexported fields\n}\n```\nExplorer runs Explore's searches, one at a time, only when the user asks, never below the budget the sweeps keep.\n\n```go\nfunc (x *Explorer) Recent(ctx context.Context) ([]string, error)\n```\nRecent are the last searches, the newest first.\n\n```go\nfunc (x *Explorer) Search(ctx context.Context, input string) (Result, error)\n```\nSearch runs one search of input.\n\n```go\ntype GitHub interface {\n\tSearcher\n\tIsUser(ctx context.Context, login string) (bool, error)\n}\n```\nGitHub is what Explore reads of GitHub: its searches and whether a word is a user's login.\n\n```go\ntype Lookup struct {\n\tRepos  []string // owner/name of the repositories the inventory holds\n\tOwners []string // their owners, the most relevant first\n\t// IsUser answers whether a word is a GitHub user's login; nil, or an\n\t// error, reads the word as text.\n\tIsUser func(ctx context.Context, login string) (bool, error)\n}\n```\nLookup is what the inventory and GitHub tell Explore about a bare word.\n\n```go\ntype Request struct {\n\tRef    *github.Ref\n\tQuery  string\n\tRead   string // how the input was read, after \"as\"\n\tAuthor string // the login when the search lists one author's pull requests\n\tTeam   string // org/slug when the search lists what one team is asked to review\n\tSort   string // the value of the search's sort: qualifier\n\t// Keep are the updated: qualifiers, which every search of the request\n\t// carries, the fallback's too.\n\tKeep []string\n}\n```\nRequest is one pull request when Ref is set, else a search.\n\n```go\nfunc Parse(ctx context.Context, input string, l Lookup) (Request, error)\n```\n\n```go\ntype Result struct {\n\tQuery      string             `json:\"query\"`\n\tRead       string             `json:\"read\"`\n\tTotal      int                `json:\"total\"`\n\tEmpty      string             `json:\"empty,omitempty\"`\n\tRateLimit  github.RateLimit   `json:\"rate_limit\"`\n\tRecent     []string           `json:\"recent\"`\n\tCandidates []github.Candidate `json:\"candidates\"`\n}\n```\nResult is one search: what it read the query as, the pull requests it found and the budget it spent.\n\n```go\ntype Retry struct {\n\tAttempt, Pause time.Duration\n}\n```\nRetry bounds each attempt of a search and pauses before its second try.\n\n```go\nfunc (r Retry) AuthorInRepos(ctx context.Context, s Searcher, queries []string, sort, viewer string) (merged github.CandidatePage, failed []error, err error)\n```\nAuthorInRepos 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.\n\n```go\nfunc (r Retry) Search(ctx context.Context, s Searcher, q, viewer string) (github.CandidatePage, error)\n```\nSearch gives a search GitHub could not finish in time one more try after a pause: a gateway error or a timeout often passes.\n\n```go\ntype Searcher interface {\n\tSearchCandidates(ctx context.Context, q, viewer string, first int) (github.CandidatePage, error)\n\tSearchCandidatesEach(ctx context.Context, qs []string, viewer string, first int) ([]github.CandidatePage, []error, error)\n\tCandidateByRef(ctx context.Context, ref github.Ref, viewer string) (github.CandidatePage, error)\n}\n```\nSearcher is the GitHub search Explore runs.\n\n```go\ntype Store interface {\n\tRefs(ctx context.Context) ([]github.Ref, error)\n\tViewer(ctx context.Context) (string, error)\n\tMeta(ctx context.Context, key string) (string, error)\n\tSetMeta(ctx context.Context, key, value string) error\n}\n```\nStore is what Explore reads and keeps beside GitHub: the pull requests the plugin holds, the viewer, and the recent searches.\n\n","path":"github.com/wloophq/wloop/plugins/github/explore","name":"explore","synopsis":"Package explore turns what the user types in Explore into one GitHub search for open pull requests to help on.","isRedistributable":true}
