Documentation
¶
Overview ¶
Package counters counts live activity through the GitHub API.
It reuses the token `gh auth login` already stored (or GH_TOKEN), so nobody creates a token for this tool. Without one it falls back to the public REST API: merged PRs and stars still count, GraphQL-only data (answers, sponsorships, highlight flags) does not.
Package counters aggregates public contribution metrics including pull requests, repository stars, and accepted discussion answers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRateLimited = errors.New("GitHub's API rate limit for anonymous use was hit; run `gh auth login`")
ErrRateLimited is the unauthenticated API saying no; `gh auth login` lifts it.
Functions ¶
This section is empty.
Types ¶
type Facts ¶
type Facts struct {
AcceptedAnswers int
Sponsoring int
Flags map[string]bool // highlight GraphQL field → value
}
Facts are the GraphQL-only user fields.
type MergedPRs ¶
type MergedPRs struct {
Total int // GitHub search's issueCount: right even past the listing cap
Refs []string // "owner/repo#123", oldest merge first; may be shorter than Total
}
MergedPRs is the result of counting a user's merged pull requests.
func (MergedPRs) IsComplete ¶
IsComplete reports whether every merged PR was listed, which calibration needs.
type Source ¶
type Source interface {
IsAuthenticated() bool
MergedPRs(user string) (MergedPRs, error)
MaxOwnedStars(user string) (stars int, repo string, err error)
RepoStars(repo string) (int, error)
Facts(user string, flagFields []string) (*Facts, error) // nil without a token
}
Source counts activity for one user.
func NewWithToken ¶
NewWithToken counts with an explicit token: the site's bot token, or a signed-in user's token for one request. Host, AuthToken, Transport and APIHost are all set, so go-gh takes no host, token or API host from a gh config. LogIgnoreEnv stops GH_DEBUG from turning on request logging: a user's token must never be written to a log.