mirror of
https://github.com/tiennm99/ghstats.git
synced 2026-05-31 22:17:22 +00:00
208629cf8f
Four time-bounded cards ("last year") now have all-time counterparts, and
the stats card gains a lifetime commits row.
New cards:
- 6-most-commit-language-all-time.svg (byte-weighted, all lifetime commits)
- 7-productive-time-all-time.svg (hour histogram over all lifetime commits)
- 8-contributions-all-time.svg (area chart spanning every active year)
Data pipeline:
- Drop the "since" filter from commitHistoryQuery; FetchProductive now
paginates unbounded commits and splits each commit into last-year and
all-time buckets in a single pass — no extra API calls.
- New contributionYearQuery iterates user.contributionYears to
concatenate calendar data and accumulate TotalCommitsAllTime.
- -commits-per-repo default bumped 100 → 500 to give all-time depth.
Polish:
- Productive-time title embeds the configured tz as "UTC±N.NN" (e.g.
UTC+7.00) on both last-year and all-time cards.
- Contribution x-axis flipped to mm/yy with an "mm/yy" footer caption
paralleling productive-time's "hour of day".
- Contribution x-axis label stride now targets ~6 labels regardless of
bucket count so the all-time chart (~100 months) stays readable while
the underlying curve still samples every month.
107 lines
2.7 KiB
Go
107 lines
2.7 KiB
Go
package github
|
|
|
|
// profileQuery pulls everything needed for the profile, stats and languages
|
|
// cards in one round trip. Repo pagination is handled by the caller if the
|
|
// user owns more than 100 repos.
|
|
const profileQuery = `
|
|
query($login: String!, $after: String) {
|
|
user(login: $login) {
|
|
id
|
|
login
|
|
name
|
|
bio
|
|
avatarUrl
|
|
company
|
|
location
|
|
websiteUrl
|
|
createdAt
|
|
followers { totalCount }
|
|
following { totalCount }
|
|
pullRequests { totalCount }
|
|
issues { totalCount }
|
|
repositoriesContributedTo(
|
|
first: 1
|
|
contributionTypes: [COMMIT, PULL_REQUEST, ISSUE, PULL_REQUEST_REVIEW]
|
|
) { totalCount }
|
|
contributionsCollection {
|
|
contributionYears
|
|
totalCommitContributions
|
|
totalIssueContributions
|
|
totalPullRequestContributions
|
|
totalPullRequestReviewContributions
|
|
totalRepositoryContributions
|
|
restrictedContributionsCount
|
|
contributionCalendar {
|
|
totalContributions
|
|
weeks {
|
|
contributionDays {
|
|
contributionCount
|
|
date
|
|
}
|
|
}
|
|
}
|
|
}
|
|
repositories(
|
|
first: 100
|
|
after: $after
|
|
ownerAffiliations: OWNER
|
|
isFork: false
|
|
orderBy: { field: STARGAZERS, direction: DESC }
|
|
) {
|
|
totalCount
|
|
pageInfo { hasNextPage endCursor }
|
|
nodes {
|
|
name
|
|
stargazerCount
|
|
forkCount
|
|
primaryLanguage { name color }
|
|
languages(first: 20, orderBy: { field: SIZE, direction: DESC }) {
|
|
edges {
|
|
size
|
|
node { name color }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}`
|
|
|
|
// commitHistoryQuery fetches commit timestamps in the default branch of one
|
|
// repo, filtered to commits authored by the target user. Used to build the
|
|
// productive-time heatmap.
|
|
const commitHistoryQuery = `
|
|
query($login: String!, $repo: String!, $userId: ID!, $after: String) {
|
|
repository(owner: $login, name: $repo) {
|
|
defaultBranchRef {
|
|
target {
|
|
... on Commit {
|
|
history(first: 100, after: $after, author: { id: $userId }) {
|
|
pageInfo { hasNextPage endCursor }
|
|
nodes { committedDate }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}`
|
|
|
|
// contributionYearQuery fetches a single year's contribution calendar days
|
|
// plus the commit total for that year. Looped in Go over user.contributionYears
|
|
// to build the all-time contribution series and lifetime commit count.
|
|
const contributionYearQuery = `
|
|
query($login: String!, $from: DateTime!, $to: DateTime!) {
|
|
user(login: $login) {
|
|
contributionsCollection(from: $from, to: $to) {
|
|
totalCommitContributions
|
|
contributionCalendar {
|
|
weeks {
|
|
contributionDays {
|
|
contributionCount
|
|
date
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}`
|