mirror of
https://github.com/tiennm99/ghstats.git
synced 2026-08-31 12:28:13 +00:00
- Add GraphQL client fetching profile, stats, language aggregation, and per-repo commit histograms for the productive-time heatmap. - Render real SVG cards (profile details, top languages, stats grid, weekday×hour heatmap) with XML escaping and thousands-formatted numbers. - Expand theme palette to 30 built-ins ported from github-readme-stats; add -list-themes, multi-theme rendering, and 'all' shortcut. - Package as Docker-based GitHub Action (action.yml, Dockerfile, entrypoint.sh) with optional auto-commit of generated cards. - Release workflow publishes GHCR image and cross-platform binaries on v* tags. - Unit tests cover rendering, XML escape, number formatting, language sort.
69 lines
1.7 KiB
Go
69 lines
1.7 KiB
Go
package github
|
|
|
|
import "time"
|
|
|
|
// Profile is the aggregate of data other packages render into cards.
|
|
type Profile struct {
|
|
ID string
|
|
Login string
|
|
Name string
|
|
Bio string
|
|
AvatarURL string
|
|
Company string
|
|
Location string
|
|
Website string
|
|
CreatedAt time.Time
|
|
|
|
Followers int
|
|
Following int
|
|
PublicRepos int
|
|
|
|
// Totals for the stats card.
|
|
TotalStars int
|
|
TotalForks int
|
|
TotalCommits int
|
|
TotalPRs int
|
|
TotalIssues int
|
|
TotalReviews int
|
|
TotalContributedTo int
|
|
TotalContributions int // lifetime contributions from calendar + restricted
|
|
|
|
// Sorted desc by bytes. Color is GitHub's linguist color or "" if absent.
|
|
Languages []LangStat
|
|
|
|
// Commit-count histogram indexed by [day-of-week 0=Sunday][hour-of-day 0-23].
|
|
Productive [7][24]int
|
|
|
|
// TopRepos is the list of owned repo names sorted by stargazer count desc,
|
|
// populated by FetchProfile. Used as the seed set for FetchProductive.
|
|
TopRepos []string
|
|
}
|
|
|
|
// LangStat is one row in the top-languages card.
|
|
type LangStat struct {
|
|
Name string
|
|
Color string
|
|
Bytes int64
|
|
}
|
|
|
|
// repoNode is the GraphQL shape of one repository node; kept here because
|
|
// it's shared by the profile fetcher and the productive-time fetcher.
|
|
type repoNode struct {
|
|
Name string `json:"name"`
|
|
StargazerCount int `json:"stargazerCount"`
|
|
ForkCount int `json:"forkCount"`
|
|
PrimaryLanguage *struct {
|
|
Name string `json:"name"`
|
|
Color string `json:"color"`
|
|
} `json:"primaryLanguage"`
|
|
Languages struct {
|
|
Edges []struct {
|
|
Size int64 `json:"size"`
|
|
Node struct {
|
|
Name string `json:"name"`
|
|
Color string `json:"color"`
|
|
} `json:"node"`
|
|
} `json:"edges"`
|
|
} `json:"languages"`
|
|
}
|