mirror of
https://github.com/tiennm99/ghglance.git
synced 2026-10-18 00:15:06 +00:00
feat: seed-based repo scanning + fork/private visibility flags
Replace the top-10-starred sampling with a seed list built from
contributionsCollection.commitContributionsByRepository, unioned across
every active contributionYear. Commit-history probes now land only on
repos where the user actually committed, covering all owned repos plus
forks and repos owned by others when allowed.
New visibility knobs (default off — public-facing READMEs stay
safe):
- -include-forks / include_forks : include forked repos
- -include-private / include_private: include private repos (requires
PAT with repo scope)
Compatibility:
- -top-repos default changed 10 → 0 (unlimited); still usable as a cap
for fast local runs.
- commitHistoryQuery now takes $owner so probes can target forks or
repos outside the user's ownership.
- FetchProfile now accepts FetchOptions; PublicRepos counts only repos
that pass the visibility filter.
Seed-list approach mirrors github-profile-summary-cards' own repo
sourcing but keeps our byte-weighted commit attribution.
This commit is contained in:
1 parent
0f54d5e885
commit
2943db667c
8 files changed
+179
-57
No files matched your search
@@ -1,8 +1,8 @@
|
||||
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.
|
||||
// cards in one round trip. Fork/private filtering is done client-side so one
|
||||
// query handles all combinations of -include-forks / -include-private.
|
||||
const profileQuery = `
|
||||
query($login: String!, $after: String) {
|
||||
user(login: $login) {
|
||||
@@ -45,13 +45,14 @@ query($login: String!, $after: String) {
|
||||
first: 100
|
||||
after: $after
|
||||
ownerAffiliations: OWNER
|
||||
isFork: false
|
||||
orderBy: { field: STARGAZERS, direction: DESC }
|
||||
) {
|
||||
totalCount
|
||||
pageInfo { hasNextPage endCursor }
|
||||
nodes {
|
||||
name
|
||||
isPrivate
|
||||
isFork
|
||||
stargazerCount
|
||||
forkCount
|
||||
primaryLanguage { name color }
|
||||
@@ -68,10 +69,11 @@ query($login: String!, $after: String) {
|
||||
|
||||
// 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.
|
||||
// productive-time heatmap. Owner is a variable because seed repos may belong
|
||||
// to other users (e.g. forks the user has contributed to).
|
||||
const commitHistoryQuery = `
|
||||
query($login: String!, $repo: String!, $userId: ID!, $after: String) {
|
||||
repository(owner: $login, name: $repo) {
|
||||
query($owner: String!, $repo: String!, $userId: ID!, $after: String) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
defaultBranchRef {
|
||||
target {
|
||||
... on Commit {
|
||||
@@ -85,9 +87,10 @@ query($login: String!, $repo: String!, $userId: ID!, $after: String) {
|
||||
}
|
||||
}`
|
||||
|
||||
// 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.
|
||||
// contributionYearQuery fetches one year's contribution calendar plus the
|
||||
// repos the user actually committed in that year. The calendar feeds the
|
||||
// all-time area chart; commitContributionsByRepository feeds the seed list
|
||||
// that drives commit-history probing.
|
||||
const contributionYearQuery = `
|
||||
query($login: String!, $from: DateTime!, $to: DateTime!) {
|
||||
user(login: $login) {
|
||||
@@ -101,6 +104,22 @@ query($login: String!, $from: DateTime!, $to: DateTime!) {
|
||||
}
|
||||
}
|
||||
}
|
||||
commitContributionsByRepository(maxRepositories: 100) {
|
||||
contributions { totalCount }
|
||||
repository {
|
||||
name
|
||||
owner { login }
|
||||
isPrivate
|
||||
isFork
|
||||
primaryLanguage { name color }
|
||||
languages(first: 20, orderBy: { field: SIZE, direction: DESC }) {
|
||||
edges {
|
||||
size
|
||||
node { name color }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
Reference in new issue
Block a user