Add Description along with user and org avatar#523
Open
DuttaNeel07 wants to merge 11 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the OSS contributions pipeline to carry contribution descriptions and avatar/profile metadata through scraping → persistence → API → dashboard UI, and introduces admin endpoints to backfill these fields for existing records.
Changes:
- Added
descand avatar URL fields to contribution/org/user models and OSS data types. - Enhanced GitLab scraping to populate org + user avatar URLs; updated aggregations/API responses to include description/avatar fields and to exclude Point Blank orgs.
- Added admin backfill routes/functions to populate missing descriptions and avatar fields for existing contributions; updated dashboard cards to render avatars.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/server/scrapers/types.ts | Extends RawContribution with optional desc and userAvatarUrl. |
| lib/server/scrapers/gitlab.ts | Adds URL normalization + caching and populates org/user avatar + org URL for GitLab MRs. |
| lib/server/scrapers/github.ts | Persists PR body into desc during GitHub scraping. |
| lib/server/contributionsV2.ts | Stores new fields, filters Point Blank orgs, extends aggregates/queries, and adds backfill functions. |
| lib/oss.ts | Threads description/avatar fields into normalized OSS org/contributor outputs. |
| lib/db/models/users.ts | Adds avatarUrl to User schema. |
| lib/db/models/orgsV2.ts | Makes org avatar/html URLs optional with defaults. |
| lib/db/models/contributionsV2.ts | Adds desc, orgAvatarUrl, orgHtmlUrl, userAvatarUrl to schema/interface. |
| hooks/useOssDashboardData.ts | Removes an unused type import. |
| components/oss/widgets/OssStatCard.tsx | Simplifies stat card props (removes icon). |
| components/oss/widgets/OssOrganizationPreviewCard.tsx | Renders org avatar (or initial) in preview card layout. |
| components/oss/widgets/OssOrganizationCard.tsx | Renders org avatar (or initial) in full org card layout. |
| components/oss/widgets/OssContributorPreviewCard.tsx | Renders contributor avatar in preview card layout. |
| components/oss/widgets/OssContributorCard.tsx | Renders contributor avatar in full contributor card layout. |
| components/oss/types.ts | Adds description/avatar fields to OSS dashboard TS types. |
| components/oss/OssDashboard.tsx | Wires org/contributor avatar + descriptions into dashboard view-models; adds empty-array constants. |
| components/oss/modules/OssOverviewSection.tsx | Removes icon usage for stat cards. |
| app/api/contributionsV2/route.ts | Excludes Point Blank orgs in view=user and returns desc/avatar fields per PR entry. |
| app/api/contributionsV2/backfillAvatar/route.ts | Adds admin endpoint to start avatar backfill job. |
| app/api/contributionsV2/backfill/route.ts | Adds admin endpoint to start description backfill job. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }; | ||
| } | ||
|
|
||
| export async function getGlobalStats() { |
Comment on lines
+123
to
+129
| if (c.desc != null && c.desc !== "") { | ||
| setFields.desc = c.desc; | ||
| } | ||
|
|
||
| for (const c of contributions) { | ||
| if (c.userAvatarUrl) { | ||
| setFields.userAvatarUrl = normalizeExternalUrl(c.userAvatarUrl); | ||
| } |
Comment on lines
262
to
+270
| $group: { | ||
| _id: "$orgLogin", | ||
| totalMergedPRs: { $sum: 1 }, | ||
| contributors: { $addToSet: "$username" }, | ||
| memberNames: { $addToSet: "$memberName" }, | ||
| platforms: { $addToSet: "$platform" }, | ||
| descriptions: { $addToSet: "$desc" }, | ||
| contributionOrgAvatars: { $addToSet: "$orgAvatarUrl" }, | ||
| contributionOrgUrls: { $addToSet: "$orgHtmlUrl" }, |
Comment on lines
+342
to
357
| $group: { | ||
| _id: "$memberName", | ||
| usernames: { $addToSet: "$username" }, | ||
| memberName: { $first: "$memberName" }, | ||
| totalMergedPRs: { $sum: 1 }, | ||
| githubPRs: { | ||
| $sum: { $cond: [{ $eq: ["$platform", "github"] }, 1, 0] }, | ||
| }, | ||
| }, | ||
| { | ||
| $project: { | ||
| _id: 0, | ||
| username: { $arrayElemAt: ["$usernames", 0] }, // pick one | ||
| memberName: 1, | ||
| totalMergedPRs: 1, | ||
| githubPRs: 1, | ||
| gitlabPRs: 1, | ||
| orgs: 1, | ||
| platforms: 1, | ||
| totalOrgs: { $size: "$orgs" }, | ||
| gitlabPRs: { | ||
| $sum: { $cond: [{ $eq: ["$platform", "gitlab"] }, 1, 0] }, | ||
| }, | ||
| orgs: { $addToSet: "$orgLogin" }, | ||
| platforms: { $addToSet: "$platform" }, | ||
| userAvatarUrl: { $max: "$userAvatarUrl" }, | ||
| descriptions: { $addToSet: "$desc" }, | ||
| }, |
Comment on lines
296
to
302
| orgAvatarUrl, | ||
| orgHtmlUrl, | ||
| title: pr.title, | ||
| desc: pr.body as string, | ||
| url: pr.html_url, | ||
| mergedAt: new Date(mergedAt), | ||
| }); |
Comment on lines
403
to
412
| memberName, username, platform: "github", | ||
| repoFullName, | ||
| orgLogin: eff.owner.login, | ||
| orgAvatarUrl: eff.owner.avatar_url, | ||
| orgHtmlUrl: `https://github.com/${eff.owner.login}`, | ||
| title: pr.title, | ||
| desc: pr.body as string, | ||
| url: pr.html_url, | ||
| mergedAt: new Date(mergedAt), | ||
| }); |
Comment on lines
87
to
94
| contributors: org.contributors.map((login) => ({ | ||
| id: login, | ||
| name: loginToName.get(login) ?? login, | ||
| login, | ||
| platform: getPreferredPlatform(org.platforms), | ||
| avatarUrl: contributorsJson.data.find((c) => c.username === login) | ||
| ?.userAvatarUrl, | ||
| })), |
Comment on lines
+133
to
+145
| const fullPath = group?.full_path ?? namespace.full_path; | ||
| if (!fullPath?.includes("/")) return ""; | ||
|
|
||
| const pathParts = fullPath.split("/").filter(Boolean); | ||
| while (pathParts.length > 1) { | ||
| pathParts.pop(); | ||
| const parentPath = pathParts.join("/"); | ||
| const parentGroup = await fetchGitLabJson<GitLabGroup>( | ||
| `/groups/${encodeURIComponent(parentPath)}`, | ||
| ); | ||
| const parentAvatar = normalizeGitLabUrl(parentGroup?.avatar_url); | ||
| if (parentAvatar) return parentAvatar; | ||
| } |
| import { NextRequest, NextResponse } from "next/server"; | ||
| import { backfillOrgAndUserAvatars } from "@/lib/server/contributionsV2"; | ||
|
|
||
| // POST /api/admin/backfill-avatars?key=<SCRAPE_SECRET> |
Comment on lines
+74
to
+88
| const GITLAB_ORIGIN = "https://gitlab.com"; | ||
| const POINT_BLANK_ORG_PATTERNS = [ | ||
| /^point[-_\s]?blank$/i, | ||
| /^point[-_\s]?blank[-_\s]?club$/i, | ||
| ]; | ||
| const POINT_BLANK_ORG_EXCLUSION = { | ||
| $nor: POINT_BLANK_ORG_PATTERNS.map((pattern) => ({ orgLogin: pattern })), | ||
| }; | ||
|
|
||
| function normalizeExternalUrl(url?: string | null) { | ||
| if (!url) return ""; | ||
| if (url.startsWith("http://") || url.startsWith("https://")) return url; | ||
| if (url.startsWith("/")) return `${GITLAB_ORIGIN}${url}`; | ||
| return url; | ||
| } |
* Activites card mobile responsive update * Domain Addition
* feat: add Dockerfile and .dockerignore for containerization * feat: refactor API calls to use server functions and some changes in dockerfile
…ntblank-club#528) feat: add GitHub Actions workflow to automate staging deployment and manifest updates
* Add isAlumni prop to Members component * Alumini UI update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary: What does this PR do?
Changes Made
Describe the changes you've made in this PR:
Type of Change
How Has This Been Tested?
Describe the tests you ran:
Please describe the test cases and expected behavior:
Screenshots (if applicable)
Documentation
Comments:
Reviewer Notes