🧹 Refactor: Extract GraphQL fragment for contributionsCollection - #558
🧹 Refactor: Extract GraphQL fragment for contributionsCollection#558is0692vs wants to merge 1 commit into
Conversation
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Warning Review limit reached
Next review available in: 46 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoRefactor: Deduplicate contributionsCollection GraphQL fields via shared fragment
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Code Review by Qodo
1. BaseContributionsCollection outside types.ts
|
| export type BaseContributionsCollection = { | ||
| totalCommitContributions: number; | ||
| totalPullRequestContributions: number; | ||
| totalIssueContributions: number; |
There was a problem hiding this comment.
1. basecontributionscollection outside types.ts 📘 Rule violation ⌂ Architecture
BaseContributionsCollection is a shared exported type used by multiple modules, but it is defined in src/lib/githubQueries.ts instead of being centralized in src/lib/types.ts. This increases the risk of shared-type drift and violates the project’s type centralization requirement.
Agent Prompt
## Issue description
A shared exported TypeScript type (`BaseContributionsCollection`) is defined in `src/lib/githubQueries.ts` even though it is imported by multiple modules. Per compliance, cross-module/shared types must be centralized in `src/lib/types.ts`.
## Issue Context
`BaseContributionsCollection` is imported/used by both `src/lib/github.ts` and `src/lib/githubYearInReview.ts`, so it qualifies as a shared type.
## Fix Focus Areas
- src/lib/githubQueries.ts[19-33]
- src/lib/types.ts[1-120]
- src/lib/github.ts[1-20]
- src/lib/githubYearInReview.ts[1-12]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| import "server-only"; | ||
| import { cache } from 'react'; | ||
| import { CONTRIBUTIONS_COLLECTION_FRAGMENT, type BaseContributionsCollection } from "./githubQueries"; | ||
| import { logger } from "@/lib/logger"; |
There was a problem hiding this comment.
2. Mixed import path styles 🐞 Bug ⚙ Maintainability
The new githubQueries module is imported with two different specifiers (./githubQueries vs @/lib/githubQueries), which reduces consistency and can make refactors/searches harder (and in some toolchains can create duplicate module identities). Standardizing on one import style for this module will avoid these issues.
Agent Prompt
## Issue description
`src/lib/githubQueries.ts` is imported via two different module specifiers:
- relative import in `src/lib/github.ts`
- alias import in `src/lib/githubYearInReview.ts`
This inconsistency makes the codebase less uniform and may cause tooling/bundler edge-cases where the same file is treated as two separate module identities.
## Issue Context
Both imports were introduced as part of this PR when extracting the shared GraphQL fragment and base type.
## Fix Focus Areas
- src/lib/github.ts[1-4]
- src/lib/githubYearInReview.ts[3-8]
## Suggested fix
Pick one convention and apply it consistently for `githubQueries`, e.g. change `src/lib/github.ts` to:
```ts
import { CONTRIBUTIONS_COLLECTION_FRAGMENT, type BaseContributionsCollection } from "@/lib/githubQueries";
```
(or alternatively switch `githubYearInReview.ts` to a relative import).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
🎯 What: Extracted the duplicated GraphQL query fragment for
contributionsCollectioninto a shared configuration.💡 Why: This improves maintainability and readability by deduplicating the query definition between
fetchContributions(insrc/lib/github.ts) andYEAR_IN_REVIEW_QUERY(insrc/lib/githubYearInReview.ts), minimizing the risk of modifying the shape of the data in one place but forgetting the other. A shared TypeScript typeBaseContributionsCollectionhas been introduced as well to unify the response types.✅ Verification: Verified by checking that
npm run test,npm run build, andnpm run lintpass successfully. The application logic logic remains unchanged while standardizing the query requests.✨ Result: Improved maintainability and DRYer codebase regarding GitHub GraphQL API usage.
PR created automatically by Jules for task 6402684108824583430 started by @is0692vs
Greptile Summary
contributionsCollectionの共通フィールドを共有 GraphQL フラグメントと TypeScript 型へ抽出するリファクタリングです。既存の取得フィールドとアプリケーションロジックは維持されています。CONTRIBUTIONS_COLLECTION_FRAGMENTとBaseContributionsCollectionを追加Confidence Score: 5/5
このPRは安全にマージできると判断します。
生成される GraphQL クエリは従来と同じフィールドを要求し、Year in Review 固有のフィールドも保持されているため、ブロッキングとなる動作変更は確認されませんでした。
Important Files Changed
Reviews (1): Last reviewed commit: "Refactor: Extract common GraphQL fragmen..." | Re-trigger Greptile
Context used: