pullmetrics

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package pullmetrics provides functionality to analyze GitHub Pull Requests and generate comprehensive metrics and details.

This package allows you to analyze GitHub Pull Requests programmatically, extracting detailed information including review metrics, timestamps, and performance indicators.

Example usage:

config := pullmetrics.Config{
	GitHubToken: "your_github_token",
}

analyzer, err := pullmetrics.NewAnalyzer(config)
if err != nil {
	log.Fatal(err)
}

details, err := analyzer.AnalyzePR(context.Background(), "microsoft", "vscode", 12345)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("PR %d has %d comments and %d approvers\n",
	details.PRNumber, details.NumComments, details.NumApprovers)

Package pullmetrics provides functionality to analyze GitHub Pull Requests and generate comprehensive metrics and details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyzePRToJSON

func AnalyzePRToJSON(ctx context.Context, config Config, org, repo string, prNumber int) ([]byte, error)

AnalyzePRToJSON is a convenience function that analyzes a PR and returns JSON output

func AnalyzePRToJSONString

func AnalyzePRToJSONString(ctx context.Context, config Config, org, repo string, prNumber int) (string, error)

AnalyzePRToJSONString is a convenience function that analyzes a PR and returns JSON as a string

Types

type Analyzer

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

Analyzer provides the core functionality for analyzing GitHub Pull Requests

func NewAnalyzer

func NewAnalyzer(config Config) (*Analyzer, error)

NewAnalyzer creates a new PR analyzer with the given configuration

func (*Analyzer) AnalyzePR

func (a *Analyzer) AnalyzePR(ctx context.Context, org, repo string, prNumber int) (*PRDetails, error)

AnalyzePR analyzes a GitHub Pull Request and returns comprehensive details

type Config

type Config struct {
	GitHubToken string
}

Config represents the configuration for the PR analysis

type PRDetails

type PRDetails struct {
	OrganizationName        string        `json:"organization_name"`
	RepositoryName          string        `json:"repository_name"`
	PRNumber                int           `json:"pr_number"`
	PRTitle                 string        `json:"pr_title"`
	PRWebURL                string        `json:"pr_web_url"`
	PRNodeID                string        `json:"pr_node_id"`
	AuthorUsername          string        `json:"author_username"`
	ApproverUsernames       []string      `json:"approver_usernames"`
	CommenterUsernames      []string      `json:"commenter_usernames"`
	State                   string        `json:"state"`
	NumComments             int           `json:"num_comments"`
	NumCommenters           int           `json:"num_commenters"`
	NumApprovers            int           `json:"num_approvers"`
	NumRequestedReviewers   int           `json:"num_requested_reviewers"`
	ChangeRequestsCount     int           `json:"change_requests_count"`
	LinesChanged            int           `json:"lines_changed"`
	FilesChanged            int           `json:"files_changed"`
	CommitsAfterFirstReview int           `json:"commits_after_first_review"`
	JiraIssue               string        `json:"jira_issue"`
	IsBot                   bool          `json:"is_bot"`
	Metrics                 *PRMetrics    `json:"metrics,omitempty"`
	ReleaseName             *string       `json:"release_name,omitempty"`
	Timestamps              *PRTimestamps `json:"timestamps,omitempty"`
	GeneratedAt             string        `json:"generated_at"`
}

PRDetails represents the complete analysis of a GitHub Pull Request

type PRMetrics

type PRMetrics struct {
	DraftTimeHours                float64  `json:"draft_time_hours"`
	TimeToFirstReviewRequestHours *float64 `json:"time_to_first_review_request_hours,omitempty"`
	TimeToFirstReviewHours        *float64 `json:"time_to_first_review_hours,omitempty"`
	ReviewCycleTimeHours          *float64 `json:"review_cycle_time_hours,omitempty"`
	BlockingNonBlockingRatio      *float64 `json:"blocking_non_blocking_ratio,omitempty"`
	ReviewerParticipationRatio    *float64 `json:"reviewer_participation_ratio,omitempty"`
}

PRMetrics represents calculated performance metrics for the PR review process

type PRSize

type PRSize struct {
	LinesChanged int
	FilesChanged int
}

PRSize represents the size metrics of a Pull Request

type PRTimestamps

type PRTimestamps struct {
	FirstCommit        *string `json:"first_commit,omitempty"`
	CreatedAt          *string `json:"created_at,omitempty"`
	FirstReviewRequest *string `json:"first_review_request,omitempty"`
	FirstComment       *string `json:"first_comment,omitempty"`
	FirstApproval      *string `json:"first_approval,omitempty"`
	SecondApproval     *string `json:"second_approval,omitempty"`
	MergedAt           *string `json:"merged_at,omitempty"`
	ClosedAt           *string `json:"closed_at,omitempty"`
	ReleaseCreatedAt   *string `json:"release_created_at,omitempty"`
}

PRTimestamps represents the JSON output structure for PR timestamps

type ReleaseInfo

type ReleaseInfo struct {
	Name      string
	CreatedAt string
}

ReleaseInfo holds both the name and creation timestamp of a release

type Timestamps

type Timestamps struct {
	FirstCommit        *string
	CreatedAt          *string
	FirstReviewRequest *string
	FirstComment       *string
	FirstApproval      *string
	SecondApproval     *string
	MergedAt           *string
	ClosedAt           *string
}

Timestamps represents internal timestamp data for PR analysis

Jump to

Keyboard shortcuts

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