OPS-440: Fix N+1 GetTeamByID per team in List()#130
Conversation
ListTeams already returns full Team objects with members_count, repos_count, name, ID, and URL. Remove per-team re-fetch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @arreyder's task in 56s —— View job PR Review: OPS-440 — Fix N+1 GetTeamByID per team in List()
ReviewVerdict: Approve ✅ This is a clean, correct optimization. The change removes an N+1 query pattern where each team returned by Why this is safe:
Impact: For an org with N teams, this reduces API calls from N+1 to 1 per page (up to 100 teams/page with One minor note: The removed line had a No issues found. LGTM. |
ListTeams may not include the Organization nested object, causing GetOrganization().GetID() to return 0. This broke Grants() which uses the stored orgID to look up the org. Pass orgID explicitly from the caller (already in scope) as a fallback when the team's Organization field is empty. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @arreyder's task in 1m 20s —— View job PR Review: OPS-440 — Fix N+1 GetTeamByID per team in List()
Blocking Issues: 0 | Suggestions: 0 Security IssuesNone found. Correctness IssuesNone found. SuggestionsNone. Verdict: Approve ✅ Clean, correct optimization. Reviewed against all applicable criteria:
|
gosec no longer flags this file, so the directive triggers nolintlint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @arreyder's task in 1m 10s —— View job PR Review: OPS-440 — Fix N+1 GetTeamByID per team in List()
Verdict: Approve ✅ This is a clean, well-reasoned optimization that eliminates an N+1 query pattern in team listing. Changes reviewed
No issues found
|
Summary
Remove per-team
GetTeamByIDre-fetch in teamList().ListTeamsalready returns full*github.Teamobjects with all fields needed for resource creation.Problem
After listing teams, each was individually re-fetched:
An org with 50 teams = 51 API calls instead of 1.
Validation
ListTeamsreturns[]*github.Team— same type asGetTeamByIDmembers_count,repos_count,name,id,url,organizationteamResource()usesGetMembersCount(),GetReposCount(),GetOrganization().GetID(),GetName(),GetID(),GetURL()— all populated by list responseGetOrganization()returns zero-value if nil (safe with nil-safe getters)orgIDalready in scopeImpact
Part of 7.9k requests/12h to api.github.com. This is one of several N+1 patterns (user GetByID, org membership are also tracked in OPS-440).
Test plan
go build ./...passes🤖 Generated with Claude Code