feat: add pinned repositories support to user profile - #474
Conversation
Partially Resolves PRODHOSH#146 ### 📝 Description This PR updates the profile page to respect a user's curated GitHub profile by fetching and displaying their "Pinned repositories." Previously, the application only displayed popular repositories by star count, which ignored user curation. ### 🛠️ Changes Made * **GraphQL Query Updated:** Added `pinnedItems(first: 6, types: REPOSITORY)` to `CONTRIBUTOR_QUERY` in `src/lib/github.ts`. * **TypeScript Types Updated:** Expanded the `GitHubContributor` interface to properly type the incoming `pinnedItems` nodes. * **UI Fallback Logic Added:** The profile page now checks for pinned repositories first. If the user has pinned items, they are displayed under a "Pinned repositories" heading. If none exist, it gracefully falls back to the original "Popular repositories" display. ### ✅ Definition of Done - [x] Pinned repos appear in a labeled section when the user has them. - [x] Falls back to popular repos when nothing is pinned. - [x] TypeScript types are updated. - [x] PR is linked to the original issue.
Welcome to OSSfolio, @mspandey! 🎉Thank you for opening this pull request and contributing to the open-source community! 🚀 To ensure a smooth review process, please make sure you have:
We will review your PR as soon as possible. Happy coding! 💻✨ |
📝 WalkthroughWalkthroughGitHub contributor queries now retrieve up to six pinned repositories, and ChangesContributor data updates
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/github.ts`:
- Around line 103-114: Update the types argument in the pinnedItems query to use
GraphQL list syntax, wrapping REPOSITORY in brackets to match the expected
[PinnableItemType!] type. Leave the rest of the pinnedItems selection unchanged.
- Around line 165-174: Update fetchContributorProfile to bump the Redis cache
key version, invalidating profiles cached before the required pinnedItems field
was added. Keep pinnedItems required and ensure all newly fetched profiles use
the new cache key so downstream access to pinnedItems.nodes remains safe.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 389dc0bc-0c98-4ca0-bfec-9afbf8a64c4f
📒 Files selected for processing (1)
src/lib/github.ts
| pinnedItems(first: 6, types: REPOSITORY) { | ||
| nodes { | ||
| ... on Repository { | ||
| name | ||
| description | ||
| stargazerCount | ||
| forkCount | ||
| primaryLanguage { name color } | ||
| url | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
Use list syntax for the types argument.
While GraphQL engines gracefully coerce single values into lists, the types argument on pinnedItems strictly expects a list of enums ([PinnableItemType!]). It is safer and more idiomatic to use list syntax to prevent potential parser warnings.
♻️ Proposed refactor
- pinnedItems(first: 6, types: REPOSITORY) {
+ pinnedItems(first: 6, types: [REPOSITORY]) {
nodes {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| pinnedItems(first: 6, types: REPOSITORY) { | |
| nodes { | |
| ... on Repository { | |
| name | |
| description | |
| stargazerCount | |
| forkCount | |
| primaryLanguage { name color } | |
| url | |
| } | |
| } | |
| } | |
| pinnedItems(first: 6, types: [REPOSITORY]) { | |
| nodes { | |
| ... on Repository { | |
| name | |
| description | |
| stargazerCount | |
| forkCount | |
| primaryLanguage { name color } | |
| url | |
| } | |
| } | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/lib/github.ts` around lines 103 - 114, Update the types argument in the
pinnedItems query to use GraphQL list syntax, wrapping REPOSITORY in brackets to
match the expected [PinnableItemType!] type. Leave the rest of the pinnedItems
selection unchanged.
| pinnedItems: { | ||
| nodes: { | ||
| name: string; | ||
| description: string | null; | ||
| stargazerCount: number; | ||
| forkCount: number; | ||
| primaryLanguage: { name: string; color: string } | null; | ||
| url: string; | ||
| }[]; | ||
| }; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
Bump the Redis cache key to avoid crashes from schema mismatch.
You added pinnedItems as a required field to GitHubContributor. However, user profiles that are already cached in Redis will not have this field. When these cached profiles are loaded, pinnedItems will be undefined, violating this TypeScript contract. If downstream UI code attempts to access contributor.pinnedItems.nodes without optional chaining (as the strict type suggests), it will crash the profile page.
To prevent runtime errors and ensure the new feature is immediately visible to all users, bump the cache key version in fetchContributorProfile.
🛠️ Proposed fix outside the selected lines
Apply this change around line 217 to invalidate the cache:
export async function fetchContributorProfile(
login: string,
token: string
): Promise<GitHubContributor> {
- const cacheKey = `github:profile:${login.toLowerCase()}`;
+ const cacheKey = `github:profile:v2:${login.toLowerCase()}`;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/lib/github.ts` around lines 165 - 174, Update fetchContributorProfile to
bump the Redis cache key version, invalidating profiles cached before the
required pinnedItems field was added. Keep pinnedItems required and ensure all
newly fetched profiles use the new cache key so downstream access to
pinnedItems.nodes remains safe.
|
🎉 Your PR just got merged, @mspandey — thank you for contributing to OSSfolio! Your work is now part of the project. Here's what to do next:
We really appreciate you taking the time. See you in the next PR! 🚀 |
|
@all-contributors add @mspandey for code im adding u to the contributors list in readme |
|
I've put up a pull request to add @mspandey! 🎉 |
Partially Resolves #146
📝 Description
This PR updates the profile page to respect a user's curated GitHub profile by fetching and displaying their "Pinned repositories." Previously, the application only displayed popular repositories by star count, which ignored user curation.
🛠️ Changes Made
pinnedItems(first: 6, types: REPOSITORY)toCONTRIBUTOR_QUERYinsrc/lib/github.ts.GitHubContributorinterface to properly type the incomingpinnedItemsnodes.✅ Definition of Done
Summary by CodeRabbit