Documentation
¶
Index ¶
- type Achievement
- type Author
- type ChartData
- type Commit
- type ContributorMetrics
- type DashboardConfig
- type DashboardData
- type GlobalMetrics
- type Issue
- type IssueComment
- type IssueState
- type LeaderboardEntry
- type PRSize
- type PRState
- type Period
- type PullRequest
- type RawData
- type RepositoryMetrics
- type Review
- type ReviewComment
- type ReviewState
- type Score
- type ScoreBreakdown
- type TeamMetrics
- type TimeSeries
- type TimeSeriesPoint
- type VelocityTimeline
- type VelocityTimelineSeries
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Achievement ¶
type Achievement struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Icon string `json:"icon"`
EarnedBy string `json:"earned_by"` // Login of user who earned it
EarnedAt string `json:"earned_at"` // When it was earned (period label)
}
Achievement represents an earned achievement badge
type Author ¶
type Author struct {
ID int64 `json:"id,omitempty"`
Login string `json:"login"`
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
}
Author represents a Git/GitHub author
func (*Author) DisplayName ¶
DisplayName returns the best available name for display
type ChartData ¶
type ChartData struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Type string `json:"type"` // line, bar, pie, doughnut
Labels []string `json:"labels"`
Series []TimeSeries `json:"series"`
}
ChartData holds data formatted for charts
type Commit ¶
type Commit struct {
SHA string `json:"sha"`
Message string `json:"message"`
Author Author `json:"author"`
Committer Author `json:"committer"`
Date time.Time `json:"date"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
FilesChanged int `json:"files_changed"`
FilesModified []string `json:"files_modified,omitempty"` // List of file paths modified in this commit
Repository string `json:"repository"` // owner/repo format
URL string `json:"url"`
// Meaningful line counts (excludes comments and whitespace)
MeaningfulAdditions int `json:"meaningful_additions"`
MeaningfulDeletions int `json:"meaningful_deletions"`
// Comment line counts (all types of comments)
CommentAdditions int `json:"comment_additions"`
CommentDeletions int `json:"comment_deletions"`
// Documentation comment counts (JSDoc, Rust doc comments, docstrings, etc.)
DocCommentAdditions int `json:"doc_comment_additions"`
DocCommentDeletions int `json:"doc_comment_deletions"`
// Commented-out code counts (code that was commented rather than deleted)
CommentedCodeAdditions int `json:"commented_code_additions"`
CommentedCodeDeletions int `json:"commented_code_deletions"`
// Derived fields
HasTests bool `json:"has_tests"`
}
Commit represents a Git commit
type ContributorMetrics ¶
type ContributorMetrics struct {
Login string `json:"login"`
Name string `json:"name"`
AvatarURL string `json:"avatar_url"`
Period Period `json:"period"`
// Commit metrics
CommitCount int `json:"commit_count"`
CommitsWithTests int `json:"commits_with_tests"` // Commits that include test files
LinesAdded int `json:"lines_added"`
LinesDeleted int `json:"lines_deleted"`
FilesChanged int `json:"files_changed"`
// Meaningful line counts (excludes comments and whitespace)
MeaningfulLinesAdded int `json:"meaningful_lines_added"`
MeaningfulLinesDeleted int `json:"meaningful_lines_deleted"`
// Comment and documentation line counts
CommentLinesAdded int `json:"comment_lines_added"`
CommentLinesDeleted int `json:"comment_lines_deleted"`
// PR metrics
PRsOpened int `json:"prs_opened"`
PRsMerged int `json:"prs_merged"`
PRsClosed int `json:"prs_closed"`
AvgPRSize float64 `json:"avg_pr_size"`
AvgTimeToMerge float64 `json:"avg_time_to_merge_hours"`
LargestPRSize int `json:"largest_pr_size"` // Biggest single PR by lines changed
SmallPRCount int `json:"small_pr_count"` // PRs under 100 lines (good practice)
PerfectPRs int `json:"perfect_prs"` // PRs merged without changes requested
// Review metrics
ReviewsGiven int `json:"reviews_given"`
ReviewComments int `json:"review_comments"`
ApprovalsGiven int `json:"approvals_given"`
ChangesRequested int `json:"changes_requested"`
AvgReviewTime float64 `json:"avg_review_time_hours"`
// Issue metrics
IssuesOpened int `json:"issues_opened"`
IssuesClosed int `json:"issues_closed"`
IssueComments int `json:"issue_comments"`
IssueReferencesInCommits int `json:"issue_references_in_commits"` // Commits referencing issues (fixes #123, etc.)
// Activity patterns
ActiveDays int `json:"active_days"` // Unique days with activity
CurrentStreak int `json:"current_streak"` // Current consecutive days
LongestStreak int `json:"longest_streak"` // Longest consecutive days
WorkWeekStreak int `json:"work_week_streak"` // Longest consecutive weekdays (Mon-Fri, weekends don't break streak)
EarlyBirdCount int `json:"early_bird_count"` // Commits before 9am
NightOwlCount int `json:"night_owl_count"` // Commits after 9pm
MidnightCount int `json:"midnight_count"` // Commits between midnight and 4am
WeekendWarrior int `json:"weekend_warrior"` // Weekend commits
OutOfHoursCount int `json:"out_of_hours_count"` // Commits outside 9am-5pm (legacy, kept for achievements)
// Time-based commit counts for multiplier scoring
RegularHoursCount int `json:"regular_hours_count"` // Commits 9am-5pm (x1 multiplier)
EveningCount int `json:"evening_count"` // Commits 5pm-9pm (x2 multiplier)
LateNightCount int `json:"late_night_count"` // Commits 9pm-midnight (x2.5 multiplier)
OvernightCount int `json:"overnight_count"` // Commits midnight-6am (x5 multiplier)
EarlyMorningCount int `json:"early_morning_count"` // Commits 6am-9am (x2 multiplier)
// Repository participation
RepositoriesContributed []string `json:"repositories_contributed,omitempty"`
UniqueReviewees int `json:"unique_reviewees"`
// Scoring
Score Score `json:"score"`
Achievements []string `json:"achievements"` // Achievement IDs
}
ContributorMetrics holds aggregated metrics for a single contributor
type DashboardConfig ¶
type DashboardConfig struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
Repositories []string `json:"repositories"`
Teams []string `json:"teams,omitempty"`
Granularities []string `json:"granularities"`
ScoringEnabled bool `json:"scoring_enabled"`
ShowAchievements bool `json:"show_achievements"`
}
DashboardConfig holds UI configuration
type DashboardData ¶
type DashboardData struct {
GeneratedAt time.Time `json:"generated_at"`
Period Period `json:"period"`
GlobalMetrics GlobalMetrics `json:"global_metrics"`
Charts []ChartData `json:"charts"`
Achievements []Achievement `json:"achievements"`
Configuration DashboardConfig `json:"configuration"`
}
DashboardData holds all data needed for the dashboard
type GlobalMetrics ¶
type GlobalMetrics struct {
Period Period `json:"period"`
Repositories []RepositoryMetrics `json:"repositories"`
Contributors []ContributorMetrics `json:"contributors"` // Aggregated across all repos
Teams []TeamMetrics `json:"teams"`
Leaderboard []LeaderboardEntry `json:"leaderboard"`
TopAchievers map[string]string `json:"top_achievers"` // category -> login
// Summary stats
TotalContributors int `json:"total_contributors"`
TotalCommits int `json:"total_commits"`
TotalPRs int `json:"total_prs"`
TotalReviews int `json:"total_reviews"`
TotalLinesAdded int `json:"total_lines_added"`
TotalLinesDeleted int `json:"total_lines_deleted"`
// Meaningful line counts (excludes comments and whitespace)
TotalMeaningfulLinesAdded int `json:"total_meaningful_lines_added"`
TotalMeaningfulLinesDeleted int `json:"total_meaningful_lines_deleted"`
// Velocity timeline (weekly granularity)
VelocityTimeline *VelocityTimeline `json:"velocity_timeline,omitempty"`
}
GlobalMetrics holds metrics aggregated across all repositories
type Issue ¶
type Issue struct {
Number int `json:"number"`
Title string `json:"title"`
State IssueState `json:"state"`
Author Author `json:"author"`
Repository string `json:"repository"` // owner/repo format
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ClosedAt *time.Time `json:"closed_at,omitempty"`
ClosedBy *Author `json:"closed_by,omitempty"`
Comments int `json:"comments"`
Labels []string `json:"labels,omitempty"`
URL string `json:"url"`
// Derived fields
TimeToClose *time.Duration `json:"time_to_close,omitempty"`
}
Issue represents a GitHub issue
func (*Issue) CalculateTimeToClose ¶
CalculateTimeToClose calculates the time from issue creation to close
type IssueComment ¶
type IssueComment struct {
ID int64 `json:"id"`
Issue int `json:"issue"`
Repository string `json:"repository"`
Author Author `json:"author"`
Body string `json:"body"`
CreatedAt time.Time `json:"created_at"`
}
IssueComment represents a comment on an issue
type IssueState ¶
type IssueState string
IssueState represents the state of an issue
const ( IssueStateOpen IssueState = "open" IssueStateClosed IssueState = "closed" )
type LeaderboardEntry ¶
type LeaderboardEntry struct {
Rank int `json:"rank"`
Login string `json:"login"`
Name string `json:"name"`
AvatarURL string `json:"avatar_url"`
Score int `json:"score"`
Team string `json:"team,omitempty"`
TopCategory string `json:"top_category,omitempty"` // What they're best at
Achievements []string `json:"achievements,omitempty"` // Achievement IDs earned
}
LeaderboardEntry represents a single entry in the leaderboard
type Period ¶
type Period struct {
Start time.Time `json:"start"`
End time.Time `json:"end"`
Granularity string `json:"granularity"` // daily, weekly, monthly, custom
Label string `json:"label"` // e.g., "Week 42", "December 2024", "Q1 2024"
}
Period represents a time period for metrics aggregation
type PullRequest ¶
type PullRequest struct {
Number int `json:"number"`
Title string `json:"title"`
State PRState `json:"state"`
Author Author `json:"author"`
Repository string `json:"repository"` // owner/repo format
BaseBranch string `json:"base_branch"` // Target branch (e.g., main, master)
HeadBranch string `json:"head_branch"` // Source branch
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
MergedAt *time.Time `json:"merged_at,omitempty"`
ClosedAt *time.Time `json:"closed_at,omitempty"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
FilesChanged int `json:"files_changed"`
CommitCount int `json:"commit_count"`
Comments int `json:"comments"`
Reviews []Review `json:"reviews,omitempty"`
URL string `json:"url"`
// Meaningful line counts (excludes comments and whitespace)
MeaningfulAdditions int `json:"meaningful_additions"`
MeaningfulDeletions int `json:"meaningful_deletions"`
// Derived fields
TimeToMerge *time.Duration `json:"time_to_merge,omitempty"`
TimeToFirstReview *time.Duration `json:"time_to_first_review,omitempty"`
}
PullRequest represents a GitHub pull request
func (*PullRequest) CalculateTimeToFirstReview ¶
func (pr *PullRequest) CalculateTimeToFirstReview() *time.Duration
CalculateTimeToFirstReview calculates the time from PR creation to first review
func (*PullRequest) CalculateTimeToMerge ¶
func (pr *PullRequest) CalculateTimeToMerge() *time.Duration
CalculateTimeToMerge calculates the time from PR creation to merge
func (*PullRequest) IsMerged ¶
func (pr *PullRequest) IsMerged() bool
IsMerged returns true if the PR has been merged
func (*PullRequest) Size ¶
func (pr *PullRequest) Size() PRSize
Size returns the size category of the PR based on total changes
func (*PullRequest) TotalChanges ¶
func (pr *PullRequest) TotalChanges() int
TotalChanges returns the total lines changed (additions + deletions)
type RawData ¶
type RawData struct {
Commits []Commit
PullRequests []PullRequest
Reviews []Review
Issues []Issue
IssueComments []IssueComment
}
RawData holds the raw collected data from GitHub
type RepositoryMetrics ¶
type RepositoryMetrics struct {
Owner string `json:"owner"`
Name string `json:"name"`
FullName string `json:"full_name"` // owner/name
Period Period `json:"period"`
Contributors []ContributorMetrics `json:"contributors"`
TotalCommits int `json:"total_commits"`
TotalPRs int `json:"total_prs"`
TotalReviews int `json:"total_reviews"`
ActiveContributors int `json:"active_contributors"`
TotalLinesAdded int `json:"total_lines_added"`
TotalLinesDeleted int `json:"total_lines_deleted"`
// Meaningful line counts (excludes comments and whitespace)
TotalMeaningfulLinesAdded int `json:"total_meaningful_lines_added"`
TotalMeaningfulLinesDeleted int `json:"total_meaningful_lines_deleted"`
}
RepositoryMetrics holds aggregated metrics for a single repository
type Review ¶
type Review struct {
ID int64 `json:"id"`
PullRequest int `json:"pull_request"`
Repository string `json:"repository"` // owner/repo format
Author Author `json:"author"`
State ReviewState `json:"state"`
SubmittedAt time.Time `json:"submitted_at"`
Body string `json:"body,omitempty"`
CommentsCount int `json:"comments_count"`
// Derived fields
ResponseTime *time.Duration `json:"response_time,omitempty"` // Time from PR creation or review request to review
}
Review represents a GitHub pull request review
func (*Review) IsApproval ¶
IsApproval returns true if the review is an approval
func (*Review) IsSubstantive ¶
IsSubstantive returns true if the review has meaningful content (not just a simple approval)
func (*Review) RequestsChanges ¶
RequestsChanges returns true if the review requests changes
type ReviewComment ¶
type ReviewComment struct {
ID int64 `json:"id"`
ReviewID int64 `json:"review_id"`
PullRequest int `json:"pull_request"`
Repository string `json:"repository"`
Author Author `json:"author"`
Body string `json:"body"`
Path string `json:"path,omitempty"`
Line int `json:"line,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
ReviewComment represents a comment on a pull request review
type ReviewState ¶
type ReviewState string
ReviewState represents the state of a review
const ( ReviewApproved ReviewState = "APPROVED" ReviewChangesRequested ReviewState = "CHANGES_REQUESTED" ReviewCommented ReviewState = "COMMENTED" ReviewPending ReviewState = "PENDING" ReviewDismissed ReviewState = "DISMISSED" )
type Score ¶
type Score struct {
Total int `json:"total"`
Breakdown ScoreBreakdown `json:"breakdown"`
Rank int `json:"rank"`
PercentileRank float64 `json:"percentile_rank"`
}
Score holds the calculated score and breakdown
type ScoreBreakdown ¶
type ScoreBreakdown struct {
Commits int `json:"commits"`
PRs int `json:"prs"`
Reviews int `json:"reviews"`
Comments int `json:"comments"` // PR review comments (not code comments)
Issues int `json:"issues"` // Issue-related points (opened, closed, comments, references)
ResponseBonus int `json:"response_bonus"`
LineChanges int `json:"line_changes"`
TestsBonus int `json:"tests_bonus"` // Bonus for commits that include test files
OutOfHours int `json:"out_of_hours"` // Bonus for out-of-hours commits
}
ScoreBreakdown shows how the score was calculated
type TeamMetrics ¶
type TeamMetrics struct {
Name string `json:"name"`
Color string `json:"color"`
Members []string `json:"members"`
Period Period `json:"period"`
AggregatedMetrics ContributorMetrics `json:"aggregated_metrics"`
MemberMetrics []ContributorMetrics `json:"member_metrics"`
TotalScore int `json:"total_score"`
AvgScore float64 `json:"avg_score"`
}
TeamMetrics holds aggregated metrics for a team
type TimeSeries ¶
type TimeSeries struct {
Name string `json:"name"`
Color string `json:"color,omitempty"`
Points []TimeSeriesPoint `json:"points"`
}
TimeSeries represents a series of data points over time
type TimeSeriesPoint ¶
type TimeSeriesPoint struct {
Date time.Time `json:"date"`
Label string `json:"label"`
Value float64 `json:"value"`
}
TimeSeriesPoint represents a single data point in a time series
type VelocityTimeline ¶
type VelocityTimeline struct {
Labels []string `json:"labels"` // Week labels (e.g., "Dec 2", "Dec 9")
Series []VelocityTimelineSeries `json:"series"` // Data series (commits, PRs, reviews, score)
}
VelocityTimeline holds weekly velocity data for trend visualization
type VelocityTimelineSeries ¶
type VelocityTimelineSeries struct {
Name string `json:"name"` // Series name (e.g., "Commits", "PRs", "Score")
Color string `json:"color"` // Series color
Data []float64 `json:"data"` // Values for each week
}
VelocityTimelineSeries represents a single data series in the velocity timeline