github

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type GHFetcher

type GHFetcher struct {
	// contains filtered or unexported fields
}

func NewGHFetcher

func NewGHFetcher(
	ghClient GithubClient,
	rClient *redis.Client,
	repos map[string][]string,
	logger *slog.Logger,
	interval time.Duration) *GHFetcher

func (*GHFetcher) Fetch

func (f *GHFetcher) Fetch(ctx context.Context) error

type GithubClient

type GithubClient interface {
	ListRepositoryEvents(ctx context.Context, owner, repo string, page int) ([]*github.Event, *github.Response, error)
	ListPullRequests(ctx context.Context, owner string, repo string, cursor string) ([]PullRequest, string, error)
	ListIssues(ctx context.Context, owner string, repo string, page int) ([]*github.Issue, *github.Response, error)
}

type GithubClientImpl

type GithubClientImpl struct {
	// contains filtered or unexported fields
}

func NewGithubClientImpl

func NewGithubClientImpl(cl *github.Client, gr graphql.Client) *GithubClientImpl

func (*GithubClientImpl) ListIssues

func (lre *GithubClientImpl) ListIssues(ctx context.Context, owner string, repo string, page int) ([]*github.Issue, *github.Response, error)

ListIssues implements GithubClient.

func (*GithubClientImpl) ListPullRequests

func (lre *GithubClientImpl) ListPullRequests(ctx context.Context, owner string, repo string, cursor string) ([]PullRequest, string, error)

ListPullRequests implements GithubClient.

func (*GithubClientImpl) ListRepositoryEvents

func (lre *GithubClientImpl) ListRepositoryEvents(ctx context.Context, owner, repo string, page int) ([]*github.Event, *github.Response, error)

type PullRequest

type PullRequest interface {
	CreatedAt() time.Time
	Title() string
	Number() int
	CommitsCount() int
	State() string
	Author() string
	Reviews() []Review
}

type PullRequestGapi

type PullRequestGapi struct {
	// contains filtered or unexported fields
}

func (*PullRequestGapi) Author

func (p *PullRequestGapi) Author() string

Author implements PullRequest.

func (*PullRequestGapi) CommitsCount

func (p *PullRequestGapi) CommitsCount() int

CommitsCount implements PullRequest.

func (*PullRequestGapi) CreatedAt

func (p *PullRequestGapi) CreatedAt() time.Time

CreatedAt implements PullRequest.

func (*PullRequestGapi) Number

func (p *PullRequestGapi) Number() int

Number implements PullRequest.

func (*PullRequestGapi) Reviews

func (p *PullRequestGapi) Reviews() []Review

Reviews implements PullRequest.

func (*PullRequestGapi) State

func (p *PullRequestGapi) State() string

State implements PullRequest.

func (*PullRequestGapi) Title

func (p *PullRequestGapi) Title() string

Title implements PullRequest.

type PullRequestGql

type PullRequestGql struct {
	// contains filtered or unexported fields
}

func (*PullRequestGql) Author

func (p *PullRequestGql) Author() string

Author implements PullRequest.

func (*PullRequestGql) CommitsCount

func (p *PullRequestGql) CommitsCount() int

CommitsCount implements PullRequest.

func (*PullRequestGql) CreatedAt

func (p *PullRequestGql) CreatedAt() time.Time

CreatedAt implements PullRequest.

func (*PullRequestGql) Number

func (p *PullRequestGql) Number() int

Number implements PullRequest.

func (*PullRequestGql) Reviews

func (p *PullRequestGql) Reviews() []Review

Reviews implements PullRequest.

func (*PullRequestGql) State

func (p *PullRequestGql) State() string

Status implements PullRequest.

func (*PullRequestGql) Title

func (p *PullRequestGql) Title() string

Title implements PullRequest.

type PullRequestReviewState

type PullRequestReviewState string

The possible states of a pull request review.

const (
	// A review allowing the pull request to merge.
	PullRequestReviewStateApproved PullRequestReviewState = "APPROVED"
	// A review blocking the pull request from merging.
	PullRequestReviewStateChangesRequested PullRequestReviewState = "CHANGES_REQUESTED"
	// An informational review.
	PullRequestReviewStateCommented PullRequestReviewState = "COMMENTED"
	// A review that has been dismissed.
	PullRequestReviewStateDismissed PullRequestReviewState = "DISMISSED"
	// A review that has not yet been submitted.
	PullRequestReviewStatePending PullRequestReviewState = "PENDING"
)

type PullRequestState

type PullRequestState string

The possible states of a pull request.

const (
	// A pull request that has been closed without being merged.
	PullRequestStateClosed PullRequestState = "CLOSED"
	// A pull request that has been closed by being merged.
	PullRequestStateMerged PullRequestState = "MERGED"
	// A pull request that is still open.
	PullRequestStateOpen PullRequestState = "OPEN"
)

type RedisRewarder

type RedisRewarder struct {
	// contains filtered or unexported fields
}

func NewRedisRewarder

func NewRedisRewarder(cli *redis.Client, cfg *RewarderCfg) *RedisRewarder

func (*RedisRewarder) Apply

func (r *RedisRewarder) Apply(ctx context.Context, user string, amount int) error

func (*RedisRewarder) GetReward

func (r *RedisRewarder) GetReward(ctx context.Context, user string) (int, error)

Reward implements Rewarder.

type Review

type Review interface {
	State() string
	Author() string
}

type ReviewGql

type ReviewGql struct {
	// contains filtered or unexported fields
}

func (*ReviewGql) Author

func (r *ReviewGql) Author() string

Author implements Review.

func (*ReviewGql) State

func (r *ReviewGql) State() string

State implements Review.

type Rewarder

type Rewarder interface {
	GetReward(ctx context.Context, user string) (int, error)
	Apply(ctx context.Context, user string, amount int) error
}

type RewarderCfg

type RewarderCfg struct {
	MaxReward int

	PRFactor     float64 // Merged PRs
	ReviewFactor float64 // Approved, Changes-Requested PR Reviews
	IssueFactor  float64 // Opened issues
	CommitFactor float64 // Commits merged into main branch
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL