feat: add --org flag to filter contributions by organization#108
feat: add --org flag to filter contributions by organization#108omercnet wants to merge 2 commits intogithub:mainfrom
Conversation
Add support for generating skylines scoped to a specific GitHub organization. This is useful for teams who want to visualize contributions to their org's repos specifically, rather than a user's entire GitHub activity. Implementation details: - New --org flag accepts organization login name - Uses contributionsByRepository GraphQL queries (commits, PRs, issues, reviews) - Queries each quarter separately to work around GitHub's 100 repo limit - Filters results client-side by repository owner - Aggregates into the same contribution grid format for STL generation Example usage: gh skyline --user employee --org mycompany --year 2024
There was a problem hiding this comment.
Pull request overview
This PR adds support for filtering GitHub contributions by organization through a new --org flag. Users can now generate skyline visualizations scoped to contributions made to a specific organization's repositories, rather than all their GitHub activity.
Key changes:
- Adds
--orgflag to filter contributions by organization - Implements quarterly GraphQL queries to work around GitHub's 100 repository per request limit
- Introduces client-side filtering logic to aggregate organization-specific contributions into the standard contribution grid format
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/root.go | Adds the --org flag and passes it to the skyline generation function |
| internal/types/types.go | Defines OrgContributionsResponse struct for repository-grouped contribution data from GraphQL API |
| internal/github/client.go | Implements FetchOrgContributions method with quarterly queries to fetch contribution data by repository |
| cmd/skyline/skyline.go | Adds org filtering logic in fetchOrgContributionData and buildContributionGrid helper function |
| internal/testutil/mocks/github.go | Extends mock client to support org contribution testing with GenerateOrgContributionsResponse |
| cmd/skyline/skyline_test.go | Adds comprehensive test coverage for org filtering functionality |
| internal/github/client_test.go | Adds unit tests for FetchOrgContributions validation and error handling |
- Replace unsafe string slice with proper time.Parse for RFC3339 timestamps - Fix potential infinite loop in buildContributionGrid with cleaner termination - Simplify complex year condition to straightforward date comparison - Extract addContributionDate helper to reduce code duplication - Add GoDoc comment to GenerateOrgContributionsResponse
Review Comments Addressed ✅All 9 review comments from Copilot have been addressed in commit 9022747: Critical Fixes
Code Quality
All threads resolved via GraphQL API. |
|
Thank you all. He deserved. 👍 |
Summary
Add support for generating skylines scoped to a specific GitHub organization. This is useful for teams who want to visualize contributions to their org's repos specifically, rather than a user's entire GitHub activity.
Usage
Implementation Details
--orgflag accepts organization login namecontributionsByRepositoryGraphQL queries to get commits, PRs, issues, and reviews grouped by repositoryWhy quarterly queries?
GitHub's GraphQL API limits
contributionsByRepositoryto 100 repositories per request with no pagination cursor. By querying each quarter separately, we can capture contributions across up to 400 repos per year, which covers virtually all real-world usage patterns.Example Output
Tests Added
TestFetchOrgContributions- validation and error handling for the new client methodTestGenerateSkylineWithOrg- integration tests with org flagTestBuildContributionGrid- unit tests for the contribution grid builderTestFetchOrgContributionDataFiltering- verifies org filtering excludes non-org reposFiles Changed
cmd/root.go--orgflaginternal/types/types.goOrgContributionsResponsetypeinternal/github/client.goFetchOrgContributionswith quarterly queriescmd/skyline/skyline.gobuildContributionGridinternal/testutil/mocks/github.gocmd/skyline/skyline_test.gointernal/github/client_test.goFetchOrgContributions