🧹 [Code Health] Extract GraphQL fragment for contributionsCollection - #560
🧹 [Code Health] Extract GraphQL fragment for contributionsCollection#560is0692vs 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: 44 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 (2)
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 QodoExtract shared GraphQL fragment + type for contributionsCollection queries
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Code Review by Qodo
1. ContributionsCollectionData not in types.ts
|
| export type ContributionsCollectionData = { | ||
| totalCommitContributions: number; | ||
| totalPullRequestContributions: number; | ||
| totalIssueContributions: number; | ||
| totalPullRequestReviewContributions: number; |
There was a problem hiding this comment.
1. contributionscollectiondata not in types.ts 📘 Rule violation ⌂ Architecture
ContributionsCollectionData is exported from src/lib/github.ts but is imported and used by src/lib/githubYearInReview.ts, making it a cross-module shared type that should be centralized in src/lib/types.ts. Keeping shared types outside src/lib/types.ts increases duplication risk and violates the project’s type-centralization rule.
Agent Prompt
## Issue description
A shared TypeScript type (`ContributionsCollectionData`) is defined/exported from `src/lib/github.ts` but is consumed by multiple modules, so it should live in `src/lib/types.ts` per the compliance rule.
## Issue Context
`src/lib/types.ts` is already the central location for shared types and is already imported by `src/lib/githubYearInReview.ts`.
## Fix Focus Areas
- src/lib/github.ts[486-500]
- src/lib/githubYearInReview.ts[1-57]
- src/lib/types.ts[1-120]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| import { headers, handleRateLimit } from "@/lib/github"; | ||
| import { buildHourlyHeatmapFromCommitDates, getMostActiveDayFromCalendar, getMostActiveHour } from "@/lib/yearInReviewUtils"; | ||
| import { logger } from "@/lib/logger"; | ||
| import { CONTRIBUTIONS_COLLECTION_FRAGMENT, ContributionsCollectionData } from "@/lib/github"; |
There was a problem hiding this comment.
2. Duplicate github imports 🐞 Bug ⚙ Maintainability
src/lib/githubYearInReview.ts now imports from "@/lib/github" twice, which adds noise and complicates future import refactors. Also, ContributionsCollectionData is only used in a type position and should be imported with type for clarity/consistency.
Agent Prompt
### Issue description
`src/lib/githubYearInReview.ts` has two separate import statements from `@/lib/github`, and `ContributionsCollectionData` is only used as a TypeScript type. This is unnecessary duplication and makes the import section harder to maintain.
### Issue Context
- There is already an existing import from `@/lib/github` for `headers` and `handleRateLimit`.
- The PR adds a second import from the same module for `CONTRIBUTIONS_COLLECTION_FRAGMENT` and `ContributionsCollectionData`.
- `ContributionsCollectionData` is used only in the `YearInReviewResponse` type.
### Fix
Merge the imports into a single statement and import the type using `type`:
```ts
import {
headers,
handleRateLimit,
CONTRIBUTIONS_COLLECTION_FRAGMENT,
type ContributionsCollectionData,
} from "@/lib/github";
```
### Fix Focus Areas
- src/lib/githubYearInReview.ts[4-8]
- src/lib/githubYearInReview.ts[48-57]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
🎯 What: Extracted the GraphQL fields for
contributionsCollectioninto a reusable fragmentCONTRIBUTIONS_COLLECTION_FRAGMENTinsrc/lib/github.tsand shared it withsrc/lib/githubYearInReview.ts. Additionally, extracted the duplicated data types into a sharedContributionsCollectionDatatype.💡 Why: Both
github.tsandgithubYearInReview.tscontained large, duplicate sections of GraphQL queries asking for exactly the same contribution data (totalCommitContributions,contributionCalendar, etc.). Sharing fragments prevents errors and drifting definitions across different parts of the application, thereby improving code maintainability.✅ Verification:
ContributionsCollectionDatawas applied perfectly in both queries and response shapes.npm run testwhich confirmed all functionality remains intact (0 regressions).npm run build.✨ Result: A more maintainable and DRY codebase without any duplicated boilerplate for the
contributionsCollectionfetch logic.PR created automatically by Jules for task 11168113056124209276 started by @is0692vs
Greptile Summary
contributionsCollectionの共通 GraphQL フィールドとレスポンス型をgithub.tsに集約し、通常のコントリビューション取得と Year in Review の両方で再利用するリファクタリングです。CONTRIBUTIONS_COLLECTION_FRAGMENTを追加ContributionsCollectionData型を追加Confidence Score: 5/5
このPRは安全にマージできると判断します。
共通化後も両クエリの選択フィールド、Year in Review 固有フィールド、およびレスポンス型の構造が維持されており、具体的な実行時・ビルド時の不具合は確認されませんでした。
Important Files Changed
Reviews (1): Last reviewed commit: "🧹 Extract and share GraphQL fragment fo..." | Re-trigger Greptile
Context used (3)