MCPcopy Create free account
hub / github.com/KartikLabhshetwar/foliox / GitHubProfileFetcher

Class GitHubProfileFetcher

lib/modules/github/fetcher.ts:223–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221`;
222
223export class GitHubProfileFetcher {
224 static async fetchPRStatistics(username: string, userToken?: string | null): Promise<GitHubMetrics> {
225 const token = userToken || Settings.GITHUB_TOKEN;
226 if (!token) {
227 return {
228 prs_merged: 0,
229 prs_open: 0,
230 total_contributions: 0,
231 issues_opened: 0,
232 issues_closed: 0,
233 };
234 }
235
236 const graphqlClient = getGraphQLClient(token);
237
238 try {
239 const result = await graphqlClient<{
240 user: {
241 mergedPRs: {
242 totalCount: number;
243 };
244 openPRs: {
245 totalCount: number;
246 };
247 contributionsCollection: {
248 totalCommitContributions: number;
249 totalIssueContributions: number;
250 totalPullRequestContributions: number;
251 totalPullRequestReviewContributions: number;
252 };
253 } | null;
254 }>(PR_STATS_QUERY, { username });
255
256 if (!result.user) {
257 return {
258 prs_merged: 0,
259 prs_open: 0,
260 total_contributions: 0,
261 issues_opened: 0,
262 issues_closed: 0,
263 };
264 }
265
266 const merged = result.user.mergedPRs.totalCount;
267 const open = result.user.openPRs.totalCount;
268 const contributions = result.user.contributionsCollection;
269
270 return {
271 prs_merged: merged,
272 prs_open: open,
273 total_contributions:
274 contributions.totalCommitContributions +
275 contributions.totalIssueContributions +
276 contributions.totalPullRequestContributions +
277 contributions.totalPullRequestReviewContributions,
278 issues_opened: contributions.totalIssueContributions,
279 issues_closed: 0,
280 };

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected