mirror of
https://github.com/tiennm99/ghstats.git
synced 2026-09-02 22:17:40 +00:00
feat: count org repos and fix contribution-window truncation
Split each contribution year into quarterly windows. commitContributionsByRepository caps at 100 repos per query and drops the remainder without signalling it, which a prolific year hits: 2026 returned exactly 100 where the quarterly union returns 108. Warn when a window still comes back at the ceiling instead of reporting a complete list. Add -include-org-repos / include_org_repos so org-owned repos the user administers count toward stars, repo count, repos-per-language and top-starred. Off by default, since enabling it moves those totals for every existing caller. Commit-driven cards already covered org repos through the seed list. Org repos carrying only read or write access are dropped via viewerPermission. Rename Profile.PublicRepos to RepoCount and drop "public" from the card label: the count tracks the fetch filters and includes private repos whenever the token can see them.
This commit is contained in:
@@ -26,6 +26,8 @@ main.go
|
||||
▼
|
||||
FetchProfile(ctx, login, opts)
|
||||
│ profileQuery × N pages (owned repos, STARGAZERS desc, 100/page)
|
||||
│ ownerAffiliations = [OWNER] (+ ORGANIZATION_MEMBER when
|
||||
│ opts.IncludeOrgRepos; non-ADMIN org repos dropped client-side)
|
||||
│ yields: Profile.{identity, stars, forks, PRs, issues,
|
||||
│ TopRepos, ReposByLanguage,
|
||||
│ ContributionYears,
|
||||
@@ -34,10 +36,12 @@ FetchProfile(ctx, login, opts)
|
||||
│
|
||||
▼
|
||||
FetchContributionsAllTime(ctx, profile, opts)
|
||||
│ contributionYearQuery × len(ContributionYears)
|
||||
│ per year: totalCommitContributions +
|
||||
│ contributionYearQuery × 4 quarters × len(ContributionYears)
|
||||
│ per quarter: totalCommitContributions +
|
||||
│ contributionCalendar.weeks +
|
||||
│ commitContributionsByRepository(maxRepositories: 100)
|
||||
│ quarters keep each window under the 100-repo ceiling, which a
|
||||
│ year-wide window silently truncates at
|
||||
│ yields: SeedRepos (deduped),
|
||||
│ DailyContributionsAllTime,
|
||||
│ TotalCommitsAllTime
|
||||
@@ -64,14 +68,14 @@ All three queries live in `internal/github/queries.go`.
|
||||
| Query | Purpose | Cost estimate |
|
||||
| --- | --- | --- |
|
||||
| `profileQuery` | Profile identity + totals + owned repos + last-year calendar | 1–10 calls (100 repos/page × ≤10 pages safety cap) |
|
||||
| `contributionYearQuery` | Per-year calendar + seed list | 1 call per active year (typically 1–10) |
|
||||
| `contributionYearQuery` | Per-quarter calendar + seed list | 4 calls per active year (typically 4–40) |
|
||||
| `commitHistoryQuery` | Authored commits on default branch | 1 call per 100 commits per seed repo |
|
||||
|
||||
Typical run (8 active years, 30 seed repos, avg 50 commits each):
|
||||
- profile: 1 call
|
||||
- year loop: 8 calls
|
||||
- quarter loop: 8 × 4 = 32 calls
|
||||
- commit history: 30 × 1 = 30 calls
|
||||
- **≈ 39 GraphQL calls, 0 REST calls**
|
||||
- **≈ 63 GraphQL calls, 0 REST calls**
|
||||
|
||||
## Attribution model
|
||||
|
||||
|
||||
Reference in New Issue
Block a user