From df1dee9f25c7532604f19e56c96ca717cc7c26ff Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2026 06:40:08 +0000 Subject: [PATCH] refactor: extract buildUserProfile helper Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com> --- src/lib/github.ts | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/lib/github.ts b/src/lib/github.ts index d35c21bf..0cec3cf5 100644 --- a/src/lib/github.ts +++ b/src/lib/github.ts @@ -222,22 +222,11 @@ async function fetchPinnedRepos(username: string, token?: string): Promise { - const [profile, orgs, pinnedRepos] = await Promise.all([ - fetchBasicProfile(username, token), - fetchOrganizations(username, token), - fetchPinnedRepos(username, token), - ]); - +function buildUserProfile( + profile: GitHubUser, + orgs: GitHubOrg[], + pinnedRepos: PinnedRepo[] +): UserProfile { return { login: profile.login, avatar_url: profile.avatar_url, @@ -256,6 +245,26 @@ export async function fetchUserProfile( }; } +/** + * Task④: ユーザープロフィール・組織・ピン留めリポジトリを取得 + + * REST /users/:username + /users/:username/orgs + GraphQL pinnedItems + * @throws {UserNotFoundError} ユーザーが存在しない場合 + * @throws {RateLimitError} APIレート制限に達した場合 + */ +export async function fetchUserProfile( + username: string, + token?: string +): Promise { + const [profile, orgs, pinnedRepos] = await Promise.all([ + fetchBasicProfile(username, token), + fetchOrganizations(username, token), + fetchPinnedRepos(username, token), + ]); + + return buildUserProfile(profile, orgs, pinnedRepos); +} + // ===== 2. fetchRepositories ===== type RepoLanguageNode = {